Merge pull request #69 from gpu-cli/release/0.15.0 #18
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Playground WASM | |
| # Builds the website playground's WASM bundle for each release tag, publishes it | |
| # as a public release asset, and bumps website/playground-wasm.lock on main. | |
| # The lock-bump commit triggers Vercel's git auto-deploy, whose build fetches | |
| # the asset via website/scripts/fetch-playground-wasm.mjs. No Vercel secrets. | |
| on: | |
| push: | |
| tags: ["v*"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: playground-wasm | |
| cancel-in-progress: false | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - uses: Swatinem/rust-cache@v2 | |
| - uses: taiki-e/install-action@v2 | |
| with: | |
| tool: wasm-pack | |
| - name: Build playground bundle | |
| run: ./scripts/build-playground-wasm.sh | |
| - name: Package and publish release asset | |
| id: publish | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| version=$(cargo metadata --no-deps --format-version 1 \ | |
| | jq -r '.packages[] | select(.name == "openapi-to-rust") | .version') | |
| tag="playground-wasm-${version}-${GITHUB_SHA::7}" | |
| tar czf playground-pkg.tar.gz -C website/public/playground pkg | |
| gh release create "$tag" playground-pkg.tar.gz \ | |
| --prerelease \ | |
| --title "Playground WASM $version (${GITHUB_SHA::7})" \ | |
| --notes "WASM bundle for openapi-to-rust.dev/playground, built from ${GITHUB_SHA}." | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| - name: Commit lock bump | |
| # Tag-triggered runs update main. Manual pre-merge runs update the | |
| # branch they were dispatched from. | |
| env: | |
| WASM_RELEASE_TAG: ${{ steps.publish.outputs.tag }} | |
| run: | | |
| set -euo pipefail | |
| target_branch="$GITHUB_REF_NAME" | |
| if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then | |
| target_branch="main" | |
| fi | |
| git fetch origin "$target_branch" | |
| git checkout -B "$target_branch" "origin/$target_branch" | |
| echo "$WASM_RELEASE_TAG" > website/playground-wasm.lock | |
| if git diff --quiet -- website/playground-wasm.lock; then | |
| echo "lock unchanged; nothing to deploy" | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add website/playground-wasm.lock | |
| git commit -m "chore: bump playground wasm to $(cat website/playground-wasm.lock) [skip ci]" | |
| git push origin "HEAD:$target_branch" |