Merge pull request #44 from Southclaws/req-body-ref #11
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 whenever the generator changes, | |
| # publishes it as a public release asset, and bumps website/playground-wasm.lock. | |
| # 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. | |
| # | |
| # Self-retrigger is impossible by construction: the lock file lives under | |
| # website/, outside this workflow's path filter. | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "src/**" | |
| - "wasm/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| - "scripts/build-playground-wasm.sh" | |
| 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 | |
| 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" > website/playground-wasm.lock | |
| - name: Commit lock bump | |
| # Pushes back to the ref the workflow ran on: main for the normal | |
| # push-triggered flow, the dispatched branch for pre-merge test runs. | |
| run: | | |
| set -euo pipefail | |
| 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 pull --rebase origin "$GITHUB_REF_NAME" | |
| git push origin "HEAD:$GITHUB_REF_NAME" |