Skip to content

Build Wasm Examples #75

Build Wasm Examples

Build Wasm Examples #75

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# See README.md in this directory for more information about workflow_call
name: Build Wasm Examples
on:
workflow_dispatch: {}
workflow_call:
inputs:
docs_only:
description: Skip building if docs only
required: false
type: string
default: "false"
schedule:
# Run at 1am UTC daily
- cron: '0 1 * * *'
permissions:
packages: write
contents: read
jobs:
build-wasm-examples:
if: ${{ inputs.docs_only == 'false' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Remove default clang
run: sudo rm /usr/bin/clang
- name: Hyperlight setup workflow
uses: hyperlight-dev/[email protected]
with:
rust-toolchain: "1.85.0"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull wasm-clang-builder
continue-on-error: true
run: |
docker pull ghcr.io/${{ github.repository_owner }}/wasm-clang-builder:latest
- name: Set up Docker image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/wasm-clang-builder
- name: Calculate ghcr cache destination
env:
CAN_WRITE: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) && github.actor != 'dependabot[bot]' }}
run: |
if [ "$CAN_WRITE" = "true" ]; then
echo "CACHE_TO=type=registry,ref=ghcr.io/${{ github.repository_owner }}/wasm-clang-builder:buildcache,mode=max" >> $GITHUB_ENV
echo "DO_PUSH=true" >> $GITHUB_ENV
else
echo "CACHE_TO=type=local,dest=/tmp/wasm-clang-builder-cache/" >> $GITHUB_ENV
echo "DO_PUSH=false" >> $GITHUB_ENV
fi
- name: Build and push wasm-clang-builder
# Only push if not from a fork, not from pull request, and not from dependabot
uses: docker/build-push-action@v6
with:
context: src/wasmsamples
file: src/wasmsamples/dockerfile
load: true
push: ${{ env.DO_PUSH }}
build-args: |
WASI_SDK_VERSION_FULL=25.0
GCC_VERSION=12
tags: ghcr.io/${{ github.repository_owner }}/wasm-clang-builder:latest
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/wasm-clang-builder:buildcache
cache-to: ${{ env.CACHE_TO }}
- name: Build Modules
run: |
just ensure-tools
just build-wasm-examples release
shell: bash
working-directory: src/wasmsamples
- name: Upload Wasm Modules
uses: actions/upload-artifact@v4
with:
name: guest-modules
path: |
x64/release/*.aot