pcbjam/.github/workflows/release.yml
Gergő Törcsvári 913bc90fa0
ci: single build recipe (reusable) + ordered tag release pipeline; two-tier opt cache
Fixes two coupled bugs: (1) a tag deployed the demo by snapshotting the STALE registry with no build/publish, so v0.1.1 shipped v0.1.0-era wasm; (2) publish-wasm built -O1/3D-off while ci-ubicloud built -O1/3D-on — two diverging recipes.

wasm-build.yml (reusable workflow_call): THE single build+test recipe, parameterized by opt_level / build_3d_viewer / run_tests / no_cache / upload_output. Two-tier output cache around build.sh's new --compile-only/--postprocess-only split: a BASE cache keyed opt-INDEPENDENTLY (compile output + sysroot headers, shared across -O1/-O2) and a FINAL cache keyed opt-SPECIFICALLY. final-hit ⇒ skip all; final-miss+base-hit ⇒ restore base, run only the asyncify/-O tail; full-miss ⇒ compile then postprocess. Both keys now include the 3D flag, closing the cache-poisoning divergence.

ci-ubicloud.yml: thin caller (main/PR/dispatch) → wasm-build at -O1. release.yml (tag v*): meta → build (wasm-build at -O2 + e2e gate, uploads output, reuses main's base cache so only the -O2 tail rebuilds) → publish-wasm (content-addressed push + manifest-<tag>.json) → deploy-demo (build-demo pinned to that manifest + libs/kicad/$LIB_TAG → Pages). So the shipped build is exactly the tested build, and the demo can never point at stale wasm.

deploy-demo.yml: demoted to manual dispatch-only re-deploy (keeps the --from-registry snapshot for re-shipping an already-published tag). publish-wasm.yml: deleted (folded into release.yml + wasm-build.yml).

Validated: actionlint clean (bar the known ubicloud custom-label note), YAML + needs-graph + reusable-path checks pass. NOT runtime-tested — the build can't run locally; needs a CI smoke (a PR exercises ci-ubicloud→wasm-build; a throwaway tag exercises release.yml) before relying on it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 16:23:33 +02:00

130 lines
4.7 KiB
YAML

name: release
# Release pipeline on a vX.Y.Z tag, in order:
# 1) build — the SAME wasm-build.yml recipe as CI, but at -O2 (the shipped demo
# opt level) + run the e2e gate; reuses main's opt-independent base
# cache so only the asyncify/-O2 tail rebuilds. Uploads output/.
# 2) publish-wasm — push the -O2 build to the CDN (content-addressed, idempotent)
# and write manifest-<tag>.json. The registry now reflects THIS tag.
# 3) deploy-demo — build the standalone pinned to that manifest + deploy to
# demo.pcbjam.com. So the demo can never point at stale wasm.
#
# Libraries are NOT published here (they change only on a KiCad lib-version bump):
# run publish-libs.yml once per LIB_TAG; this deploy just points the demo at
# libs/kicad/$LIB_TAG. WASM publishing is folded in here (no separate manual
# workflow), so the build that ships is exactly the build that was tested.
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "Release tag to build + deploy, e.g. v1.2.3"
required: true
concurrency:
group: release
cancel-in-progress: false
env:
CDN: https://cdn.pcbjam.com
BUCKET: pcbjam-cdn
# KiCad library snapshot the demo points at (published by publish-libs.yml).
LIB_TAG: "10.0.3"
PAGES_PROJECT: pcbjam-demo
PAGES_PROD_BRANCH: production
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
WRANGLER_CMD: npx --yes wrangler@4
jobs:
meta:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
# On workflow_dispatch GITHUB_REF_NAME is the branch, so prefer the input;
# on a tag push the input is empty and ref_name is the tag.
- id: tag
run: echo "tag=${{ github.event.inputs.tag || github.ref_name }}" >> "$GITHUB_OUTPUT"
# 1) Build at -O2 (shipped) + e2e gate, reusing main's base cache. Uploads the
# publishable output/ as the 'wasm-output' artifact for the publish job.
build:
uses: ./.github/workflows/wasm-build.yml
with:
opt_level: "-O2"
build_3d_viewer: "ON"
run_tests: true
upload_output: true
# 2) Publish the -O2 build to the CDN (content-addressed; unchanged tools reuse)
# and write manifest-<tag>.json. Cheap runner — just downloads + uploads.
publish-wasm:
needs: [meta, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Init pcbjam-shared submodule
run: git submodule update --init --depth 1 web/pcbjam-shared
- uses: actions/setup-node@v4
with: { node-version: 20 }
- name: Download WASM output
uses: actions/download-artifact@v4
with:
name: wasm-output
path: output
- name: Publish WASM to CDN
run: >
node scripts/deploy/publish-wasm.mjs --tag "${{ needs.meta.outputs.tag }}"
--src output --driver r2 --bucket "$BUCKET" --remote --compress gzip
# 3) Build the standalone pinned to this tag's manifest + libs, deploy to Pages.
deploy-demo:
needs: [meta, publish-wasm]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Init pcbjam-shared submodule
run: git submodule update --init --depth 1 web/pcbjam-shared
- uses: pnpm/action-setup@v4
with:
version: 10.33.0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
cache-dependency-path: web/pnpm-lock.yaml
- name: Install standalone workspace
run: pnpm --dir web install --frozen-lockfile
# Read-only example gallery (tiny; content/<tag>/).
- name: Publish content gallery
run: >
node scripts/deploy/publish-content.mjs --tag "${{ needs.meta.outputs.tag }}"
--gallery deploy/demo/gallery.json --driver r2 --bucket "$BUCKET" --remote
# Standalone pinned to the CDN + this tag's manifest-<tag>.json (written by
# publish-wasm above) + the full library set at libs/kicad/$LIB_TAG.
- name: Build demo
run: >
node scripts/deploy/build-demo.mjs --tag "${{ needs.meta.outputs.tag }}"
--cdn "$CDN" --lib-tag "$LIB_TAG"
- name: Ensure Pages project exists
run: >
npx --yes wrangler@4 pages project create "$PAGES_PROJECT"
--production-branch "$PAGES_PROD_BRANCH"
|| echo "pages project create skipped (already exists)"
- name: Deploy to Cloudflare Pages
run: >
npx --yes wrangler@4 pages deploy web/standalone/dist
--project-name "$PAGES_PROJECT"
--branch "$PAGES_PROD_BRANCH"
--commit-dirty=true