Skip to content

improved async tasks (#547) #466

improved async tasks (#547)

improved async tasks (#547) #466

Workflow file for this run

name: build-wasm
on:
push:
tags:
- 'v*'
- 'beta'
branches:
- master
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
build-wasm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: true
- name: Set Git info
id: info
run: |
RAW_TAG="${{ github.ref_name }}"
# Explicitly initialize outputs to avoid brittle logic
PUSH_LATEST="false"
IS_TAG="false"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
IS_TAG="true"
VERSION=$RAW_TAG
VERSION_CLEAN=$(echo $VERSION | sed 's/^v//')
if [[ "$RAW_TAG" != "beta" ]]; then
PUSH_LATEST="true"
fi
else
VERSION=${{ github.sha }}
VERSION_CLEAN=${VERSION:0:7}
fi
echo "VERSION=${VERSION_CLEAN}" >> $GITHUB_OUTPUT
echo "RAW_TAG=${VERSION}" >> $GITHUB_OUTPUT
echo "IS_TAG=${IS_TAG}" >> $GITHUB_OUTPUT
echo "PUSH_LATEST=${PUSH_LATEST}" >> $GITHUB_OUTPUT
echo "FILE=mmapper-${VERSION_CLEAN}-wasm.zip" >> $GITHUB_OUTPUT
echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
if: steps.info.outputs.IS_TAG == 'true'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Load Image
uses: docker/build-push-action@v7
with:
context: .
load: true
build-args: |
JOBS=1
tags: local-wasm-build:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract Artifacts from Image
run: |
docker create --name extract local-wasm-build:latest
mkdir -p demo
docker cp extract:/usr/share/nginx/html/. ./demo/
docker rm extract
zip -r ${{ steps.info.outputs.FILE }} demo
- name: Upload Zip Package
uses: actions/upload-artifact@v7
with:
name: mmapper-${{ steps.info.outputs.VERSION }}-wasm
path: ${{ steps.info.outputs.FILE }}
- name: Finalize Image Push to GHCR
if: steps.info.outputs.IS_TAG == 'true'
run: |
# Instead of rebuilding, we just tag the local image and push it
IMAGE_BASE="ghcr.io/${{ steps.info.outputs.REPO_LC }}"
TAG_VERSION="$IMAGE_BASE:${{ steps.info.outputs.RAW_TAG }}"
docker tag local-wasm-build:latest "$TAG_VERSION"
docker push "$TAG_VERSION"
if [[ "${{ steps.info.outputs.PUSH_LATEST }}" == "true" ]]; then
docker tag local-wasm-build:latest "$IMAGE_BASE:latest"
docker push "$IMAGE_BASE:latest"
fi