name: Release
on:
release:
types: [created]
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (build but do not upload)'
required: false
default: 'false'
type: boolean
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-builder
jobs:
build-runtimes:
name: Build WASM Runtimes
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: wasmhub-builder:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build all runtimes
run: |
docker run --rm \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
wasmhub-builder:latest \
./scripts/build-all.sh
- name: Install optimization tools
run: |
sudo apt-get update
sudo apt-get install -y brotli
npm install -g binaryen || true
- name: Optimize WASM binaries
run: ./scripts/optimize-wasm.sh
- name: Prepare release assets
run: |
mkdir -p release-assets
# Copy WASM binaries and compressed variants
find runtimes -name "*.wasm" -exec cp {} release-assets/ \;
find runtimes -name "*.wasm.gz" -exec cp {} release-assets/ \; 2>/dev/null || true
find runtimes -name "*.wasm.br" -exec cp {} release-assets/ \; 2>/dev/null || true
# Copy per-runtime manifests with language prefix to avoid naming conflicts
for manifest in runtimes/*/manifest.json; do
lang=$(basename "$(dirname "$manifest")")
cp "$manifest" "release-assets/${lang}-manifest.json"
done
# Copy global manifest
cp manifest.json release-assets/manifest.json
# Generate SHA256SUMS
cd release-assets
sha256sum * > SHA256SUMS
cd ..
echo "=== Release assets ==="
ls -lh release-assets/
- name: Upload release assets
if: ${{ !inputs.dry_run }}
uses: softprops/action-gh-release@v2
with:
files: release-assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload build artifacts (dry run)
if: ${{ inputs.dry_run }}
uses: actions/upload-artifact@v4
with:
name: wasm-runtimes
path: release-assets/*
build-cli:
name: Build CLI (${{ matrix.artifact }})
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: wasmhub-linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact: wasmhub-linux-aarch64
- os: macos-latest
target: x86_64-apple-darwin
artifact: wasmhub-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact: wasmhub-macos-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: wasmhub-windows-x86_64.exe
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build CLI
run: cargo build --release --features cli --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Rename binary (Unix)
if: runner.os != 'Windows'
run: cp target/${{ matrix.target }}/release/wasmhub ${{ matrix.artifact }}
- name: Rename binary (Windows)
if: runner.os == 'Windows'
run: cp target/${{ matrix.target }}/release/wasmhub.exe ${{ matrix.artifact }}
- name: Upload CLI binary
if: ${{ !inputs.dry_run }}
uses: softprops/action-gh-release@v2
with:
files: ${{ matrix.artifact }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload build artifact (dry run)
if: ${{ inputs.dry_run }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}