diff --git a/.github/workflows/build-&-push-normal-wasm.yaml b/.github/workflows/build-&-push-normal-wasm.yaml new file mode 100644 index 000000000..417b38c21 --- /dev/null +++ b/.github/workflows/build-&-push-normal-wasm.yaml @@ -0,0 +1,60 @@ +name: Build & Push Normal Wasm + +concurrency: + group: "build-release-wasm-${{ github.ref }}" + cancel-in-progress: true + +on: + push: + # branches: [ master, staging, qa ] + tags: + - 'v*.*.*' + # pull_request: + workflow_dispatch: + +jobs: + build-wasm: + name: Build-wasm + runs-on: [self-hosted, arc-runner] + outputs: + build_version: ${{ steps.wasm_build.outputs.BUILD_TAG }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Build wasm binary using go version 1.22.5 + id: wasm_build + run: | + docker run --rm -v $PWD:/gosdk -w /gosdk golang:1.22.5 sh -c "git config --global --add safe.directory /gosdk; make wasm-build" + BUILD_TAG=zcn-$(git describe --tags --exact-match)-normal.wasm + BUILD_TAG="${BUILD_TAG:0:4}${BUILD_TAG:5}" + mv zcn.wasm $BUILD_TAG + echo "BUILD_TAG=$BUILD_TAG" >>$GITHUB_OUTPUT + + - name: 'Upload Artifact' + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.wasm_build.outputs.BUILD_TAG }} + path: ${{ steps.wasm_build.outputs.BUILD_TAG }} + + - name: Install AWS cli + run: | + sudo apt update -y + sudo apt install awscli -y + + - name: Copy the wasm binary to aws s3. + run: | + export AWS_ACCESS_KEY_ID=${{ secrets.WEBAPP_STATIC_ACCESS_KEY }} + export AWS_SECRET_ACCESS_KEY=${{ secrets.WEBAPP_STATIC_SECRET_ACCESS_KEY }} + export AWS_DEFAULT_REGION=${{ secrets.WEBAPP_STATIC_REGION }} + gzip -9 ${{ steps.wasm_build.outputs.BUILD_TAG }} && mv ${{ steps.wasm_build.outputs.BUILD_TAG }}.gz ${{ steps.wasm_build.outputs.BUILD_TAG }} + aws s3 cp ${{ steps.wasm_build.outputs.BUILD_TAG }} s3://${{ secrets.WEBAPP_STATIC_BUCKET }}/wasm/${{ steps.wasm_build.outputs.BUILD_TAG }} --content-encoding gzip + + - name: Invalidate wasm binary + run: | + export AWS_ACCESS_KEY_ID=${{ secrets.WEBAPP_STATIC_ACCESS_KEY }} + export AWS_SECRET_ACCESS_KEY=${{ secrets.WEBAPP_STATIC_SECRET_ACCESS_KEY }} + export AWS_DEFAULT_REGION=${{ secrets.WEBAPP_STATIC_REGION }} + aws cloudfront create-invalidation --distribution-id ${{ secrets.WEBAPP_STATIC_DISTRIBUTION_ID }} --paths '/wasm/*'