|
| 1 | +name: Build & Push Normal Wasm |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: "build-release-wasm-${{ github.ref }}" |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + # branches: [ master, staging, qa ] |
| 10 | + tags: |
| 11 | + - 'v*.*.*' |
| 12 | + # pull_request: |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-wasm: |
| 17 | + name: Build-wasm |
| 18 | + runs-on: [self-hosted, arc-runner] |
| 19 | + outputs: |
| 20 | + build_version: ${{ steps.wasm_build.outputs.BUILD_TAG }} |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Build wasm binary using go version 1.22.5 |
| 28 | + id: wasm_build |
| 29 | + run: | |
| 30 | + docker run --rm -v $PWD:/gosdk -w /gosdk golang:1.22.5 sh -c "git config --global --add safe.directory /gosdk; make wasm-build" |
| 31 | + BUILD_TAG=zcn-$(git describe --tags --exact-match)-normal.wasm |
| 32 | + BUILD_TAG="${BUILD_TAG:0:4}${BUILD_TAG:5}" |
| 33 | + mv zcn.wasm $BUILD_TAG |
| 34 | + echo "BUILD_TAG=$BUILD_TAG" >>$GITHUB_OUTPUT |
| 35 | +
|
| 36 | + - name: 'Upload Artifact' |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: ${{ steps.wasm_build.outputs.BUILD_TAG }} |
| 40 | + path: ${{ steps.wasm_build.outputs.BUILD_TAG }} |
| 41 | + |
| 42 | + - name: Install AWS cli |
| 43 | + run: | |
| 44 | + sudo apt update -y |
| 45 | + sudo apt install awscli -y |
| 46 | + |
| 47 | + - name: Copy the wasm binary to aws s3. |
| 48 | + run: | |
| 49 | + export AWS_ACCESS_KEY_ID=${{ secrets.WEBAPP_STATIC_ACCESS_KEY }} |
| 50 | + export AWS_SECRET_ACCESS_KEY=${{ secrets.WEBAPP_STATIC_SECRET_ACCESS_KEY }} |
| 51 | + export AWS_DEFAULT_REGION=${{ secrets.WEBAPP_STATIC_REGION }} |
| 52 | + gzip -9 ${{ steps.wasm_build.outputs.BUILD_TAG }} && mv ${{ steps.wasm_build.outputs.BUILD_TAG }}.gz ${{ steps.wasm_build.outputs.BUILD_TAG }} |
| 53 | + aws s3 cp ${{ steps.wasm_build.outputs.BUILD_TAG }} s3://${{ secrets.WEBAPP_STATIC_BUCKET }}/wasm/${{ steps.wasm_build.outputs.BUILD_TAG }} --content-encoding gzip |
| 54 | +
|
| 55 | + - name: Invalidate wasm binary |
| 56 | + run: | |
| 57 | + export AWS_ACCESS_KEY_ID=${{ secrets.WEBAPP_STATIC_ACCESS_KEY }} |
| 58 | + export AWS_SECRET_ACCESS_KEY=${{ secrets.WEBAPP_STATIC_SECRET_ACCESS_KEY }} |
| 59 | + export AWS_DEFAULT_REGION=${{ secrets.WEBAPP_STATIC_REGION }} |
| 60 | + aws cloudfront create-invalidation --distribution-id ${{ secrets.WEBAPP_STATIC_DISTRIBUTION_ID }} --paths '/wasm/*' |
0 commit comments