on: push: tags: - "wasm-go-*-v*.*.*" # 匹配 wasm-go-{pluginName}-vX.Y.Z 格式的标签 workflow_dispatch: inputs: plugin_name: description: 'Name of the plugin' required: true type: string version: description: 'Version of the plugin (optional, without leading v)' required: false type: string
jobs: build-and-push-image: runs-on: ubuntu-latest environment: name: image-registry-msg env: IMAGE_REGISTRY_SERVICE: ${{ vars.IMAGE_REGISTRY_SERVICE || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }} IMAGE_REPOSITORY: ${{ vars.IMAGE_REPOSITORY || 'plugins' }} GO_VERSION: 1.19 TINYGO_VERSION: 0.25.0 ORAS_VERSION: 1.0.0 steps: - name: Set plugin_name and version from inputs or ref_name id: set_vars run: | if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then plugin_name="${{ github.event.inputs.plugin_name }}" version="${{ github.event.inputs.version }}" else ref_name=${{ github.ref_name }} plugin_name=${ref_name#*-*-} # 删除插件名前面的字段(wasm-go-) plugin_name=${plugin_name%-*} # 删除插件名后面的字段(-vX.Y.Z) version=$(echo "$ref_name" | awk -F'v' '{print $2}') fi
- name: Checkout code uses: actions/checkout@v3 - name: File Check run: | workspace=${{ github.workspace }}/plugins/wasm-go/extensions/${PLUGIN_NAME} push_command="./plugin.tar.gz:application/vnd.oci.image.layer.v1.tar+gzip" # 查找spec.yaml if [ -f "${workspace}/spec.yaml" ]; then echo "spec.yaml exists" push_command="$push_command ./spec.yaml:application/vnd.module.wasm.spec.v1+yaml" fi
# 查找README.md case "$(ls ${workspace}/README*.md 2>/dev/null)" in *"README.md"*) echo "README.md exists" push_command="$push_command ./README.md:application/vnd.module.wasm.doc.v1+markdown" ;; esac # 查找README_{lang}.md for file in ${workspace}/README_*.md; do if [ -f "$file" ]; then file_name=$(basename $file) echo "$file_name exists" lang=$(basename $file | sed 's/README_//; s/.md//') push_command="$push_command ./$file_name:application/vnd.module.wasm.doc.v1.$lang+markdown" fi done