name: Publish runtime Wasm
on:
push:
tags:
- v*
workflow_dispatch:
inputs:
release_tag:
description: Release tag to build from
required: false
type: string
workflow_call:
inputs:
release_tag:
description: Release tag to build from
required: true
type: string
env:
CARGO_TERM_COLOR: always
RELEASE_TAG: ${{ inputs.release_tag || github.ref_name }}
IMAGE_NAME: ${{ github.repository }}
COMPONENT_NAME: componentize-qjs-runtime
COMPONENT_NAME_OPT_SIZE: componentize-qjs-runtime-opt-size
COMPONENT_DESCRIPTION: QuickJS runtime for componentize-qjs
COMPONENT_DESCRIPTION_OPT_SIZE: QuickJS runtime for componentize-qjs optimized for size
COMPONENT_SOURCE: https://github.com/${{ github.repository }}
COMPONENT_HOMEPAGE: https://github.com/${{ github.repository }}
COMPONENT_LICENSES: Apache-2.0
WASM_FILE: dist/componentize_qjs_runtime.wasm
WASM_FILE_OPT_SIZE: dist/componentize_qjs_runtime_opt_size.wasm
SBOM_FILE: dist/componentize_qjs_runtime.wasm.cdx.json
SBOM_FILE_OPT_SIZE: dist/componentize_qjs_runtime_opt_size.wasm.cdx.json
jobs:
build:
name: Build runtime Wasm
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
ref: ${{ env.RELEASE_TAG }}
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 with:
targets: wasm32-wasip2
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@4852a15cf01e4f33958ce547326406fe78f27c38
- name: Cache cargo
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4
- name: Compute runtime version
id: version
shell: bash
run: |
version="${RELEASE_TAG#v}"
test -n "$version" || { echo "ERROR: release tag is empty"; exit 1; }
echo "version=${version}" >> "$GITHUB_OUTPUT"
- name: Install build tools
run: |
cargo binstall cargo-auditable --force
cargo binstall auditable2cdx --force
- name: Build auditable runtime
shell: bash
run: |
bash .github/scripts/prepare-runtime-artifacts.sh \
target/runtime-publish \
dist \
runtime.wasm=componentize_qjs_runtime.wasm \
runtime-opt-size.wasm=componentize_qjs_runtime_opt_size.wasm
- name: Upload runtime artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: componentize-qjs-runtime
path: |
${{ env.WASM_FILE }}
${{ env.WASM_FILE }}.sha256
${{ env.SBOM_FILE }}
${{ env.WASM_FILE_OPT_SIZE }}
${{ env.WASM_FILE_OPT_SIZE }}.sha256
${{ env.SBOM_FILE_OPT_SIZE }}
if-no-files-found: error
publish:
name: Publish ${{ matrix.runtime }} runtime (${{ matrix.channel }})
if: github.event_name != 'workflow_dispatch'
needs: build
runs-on: ubuntu-latest
permissions:
actions: read
id-token: write
packages: write
contents: read
strategy:
fail-fast: false
matrix:
runtime: [default, opt-size]
channel: [versioned, latest]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
ref: ${{ env.RELEASE_TAG }}
- name: Download runtime artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with:
name: componentize-qjs-runtime
path: dist
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@4852a15cf01e4f33958ce547326406fe78f27c38
- name: Install wkg
run: cargo binstall wkg --force
- name: Login to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Install cosign
uses: sigstore/cosign-installer@cad07c2e89fa2edd6e2d7bab4c1aa38e53f76003
- name: Publish runtime
uses: ./.github/actions/publish-runtime
with:
file: ${{ matrix.runtime == 'default' && env.WASM_FILE || env.WASM_FILE_OPT_SIZE }}
sbom-file: ${{ matrix.runtime == 'default' && env.SBOM_FILE || env.SBOM_FILE_OPT_SIZE }}
oci-reference-without-tag: ghcr.io/${{ env.IMAGE_NAME }}/${{ matrix.runtime == 'default' && env.COMPONENT_NAME || env.COMPONENT_NAME_OPT_SIZE }}
version: ${{ matrix.channel == 'versioned' && needs.build.outputs.version || 'latest' }}
description: ${{ matrix.runtime == 'default' && env.COMPONENT_DESCRIPTION || env.COMPONENT_DESCRIPTION_OPT_SIZE }}
source: ${{ env.COMPONENT_SOURCE }}
homepage: ${{ env.COMPONENT_HOMEPAGE }}
licenses: ${{ env.COMPONENT_LICENSES }}