pcbjam/.github/workflows/release.yml
Istvan Matejcsok a0df92bfd1 deploy: backed editor at editor.pcbjam.com (remote mode, same CDN WASM)
New release.yml job `deploy-editor` (parallel to deploy-demo, same per-tag
WASM manifest): builds the standalone in REMOTE mode via the new
scripts/deploy/build-editor.mjs — projects/libs/auth from the closed API
(VITE_API_BASE_URL=https://api.pcbjam.com, VITE_LIBS_SOURCE=synced), Yjs
board rooms through the API host's path route (VITE_YJS_ENDPOINT=api origin,
doc source ydoc) — and ships it to the pcbjam-editor Pages project. The
demo deploy is unchanged. The closed stack itself (api./app.pcbjam.com)
deploys from pcbjam-private; when both sides change, that repo tags first.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014dasZuqo6FStgT3rkC85im
2026-07-08 11:42:38 +02:00

184 lines
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, at the SAME -O1 asyncify tail
# + run the e2e gate. Because the opt level now matches main, this
# FINAL-cache-hits main's build and skips the asyncify tail rebuild.
# Uploads output/.
# 2) publish-wasm — push the 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
# Backed editor deployment (remote mode against the closed API). The closed
# stack (api./app.pcbjam.com) deploys from the pcbjam-private repo; release
# order when both change: pcbjam-private first, then this repo.
EDITOR_PAGES_PROJECT: pcbjam-editor
EDITOR_API_BASE: https://api.pcbjam.com
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 (-O1, identical to main) + e2e gate. Reuses main's FINAL cache (same
# opt level) so the asyncify tail isn't rebuilt. Uploads the publishable
# output/ as the 'wasm-output' artifact for the publish job.
build:
uses: ./.github/workflows/wasm-build.yml
with:
opt_level: "-O1"
build_3d_viewer: "ON"
run_tests: true
upload_output: true
# 2) Publish the 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 br --quality 11
# 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
# Plausible: set the repo Actions VARIABLE `PLAUSIBLE_DOMAIN` (e.g.
# demo.pcbjam.com) to enable analytics; unset ⇒ "" ⇒ build-demo leaves it off.
run: >
node scripts/deploy/build-demo.mjs --tag "${{ needs.meta.outputs.tag }}"
--cdn "$CDN" --lib-tag "$LIB_TAG"
--plausible "${{ vars.PLAUSIBLE_DOMAIN }}"
- 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
# 4) Backed editor (editor.pcbjam.com): the SAME standalone, built in remote
# mode against the closed API (pcbjam-private's api.pcbjam.com) instead of
# the static gallery. Reuses this tag's CDN WASM manifest — no extra WASM
# work. Runs in parallel with deploy-demo (separate runner, own dist/).
deploy-editor:
needs: [meta, publish-wasm]
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ needs.meta.outputs.tag }}
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
- name: Build editor (remote mode)
run: >
node scripts/deploy/build-editor.mjs --tag "$RELEASE_TAG"
--cdn "$CDN" --api-base "$EDITOR_API_BASE"
- name: Ensure Pages project exists
run: >
npx --yes wrangler@4 pages project create "$EDITOR_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 "$EDITOR_PAGES_PROJECT"
--branch "$PAGES_PROD_BRANCH"
--commit-dirty=true