publish-libs.ts: --clone <dir> shallow-clones kicad-symbols + kicad-footprints at --lib-tag (full, all libs) and uses them as sources, so CI publishes the whole set with one command. publish-libs.yml: decoupled workflow_dispatch (mirrors publish-wasm.yml) — lib_tag input (default 10.0.3) + force; clones + publishes to R2, skip-if-exists keyed by the tag. Dependency-free import chain ⇒ no workspace install (just node + npx tsx + git + wrangler). deploy-demo.yml: LIB_TAG=10.0.3 → build-demo --lib-tag, so the demo serves the full library set from libs/kicad/<LIB_TAG>. Validated locally over .cache: publish then skip-if-exists; both workflows valid YAML. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
112 lines
4.7 KiB
YAML
112 lines
4.7 KiB
YAML
name: deploy-demo
|
|
|
|
# Tag a release (vX.Y.Z) → reuse the already-published WASM (snapshot it into a
|
|
# per-release manifest), publish the example gallery, build the standalone pinned
|
|
# to the CDN, and deploy it to demo.pcbjam.com (Cloudflare Pages).
|
|
#
|
|
# The heavy WASM build+upload is DECOUPLED (workflow: publish-wasm.yml / a local
|
|
# seed) because the WASM changes rarely; this pipeline never rebuilds it. See
|
|
# docs/features/demo-deploy/.
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Release tag to deploy, e.g. v1.2.3"
|
|
required: true
|
|
|
|
# Serialize demo deploys so two tags don't race the live site (don't cancel a
|
|
# half-finished deploy — let it complete).
|
|
concurrency:
|
|
group: deploy-demo
|
|
cancel-in-progress: false
|
|
|
|
env:
|
|
CDN: https://cdn.pcbjam.com
|
|
BUCKET: pcbjam-cdn
|
|
# KiCad library snapshot the demo points at (published once by publish-libs.yml
|
|
# to libs/kicad/<LIB_TAG>/). Bump when moving to a newer KiCad library release.
|
|
LIB_TAG: "10.0.3"
|
|
PAGES_PROJECT: pcbjam-demo
|
|
# MUST be the Pages project's PRODUCTION branch — any other value makes
|
|
# `wrangler pages deploy` a PREVIEW deploy and demo.pcbjam.com won't update.
|
|
# Direct-Upload projects default to "production".
|
|
PAGES_PROD_BRANCH: production
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
# The publish scripts shell wrangler; no repo dep — fetch it on demand.
|
|
WRANGLER_CMD: npx --yes wrangler@4
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# The standalone needs the MIT pcbjam-shared submodule, but NOT the huge
|
|
# kicad/wxwidgets ones (WASM is prebuilt on the CDN, not built here).
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: false
|
|
- name: Init pcbjam-shared submodule
|
|
run: git submodule update --init --depth 1 web/pcbjam-shared
|
|
|
|
# Pin pnpm explicitly: the repo root has no package.json, so action-setup
|
|
# can't infer the version from a packageManager field (it lives in
|
|
# web/package.json). Keep in sync with web/package.json's packageManager.
|
|
- 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: Resolve tag
|
|
id: tag
|
|
# On workflow_dispatch GITHUB_REF_NAME is the branch (e.g. main), so prefer
|
|
# the explicit input; on a tag push the input is empty and ref_name is the tag.
|
|
run: echo "tag=${{ github.event.inputs.tag || github.ref_name }}" >> "$GITHUB_OUTPUT"
|
|
|
|
# 1) Reuse prebuilt WASM: snapshot the current registry into manifest-<tag>
|
|
# (no build, no upload). Fails if the WASM was never published — run
|
|
# publish-wasm.yml (or a local seed) first.
|
|
- name: Snapshot WASM manifest
|
|
run: >
|
|
node scripts/deploy/publish-wasm.mjs --tag "${{ steps.tag.outputs.tag }}"
|
|
--driver r2 --bucket "$BUCKET" --remote --from-registry
|
|
|
|
# 2) Publish the read-only example gallery (tiny; content/<tag>/).
|
|
- name: Publish content gallery
|
|
run: >
|
|
node scripts/deploy/publish-content.mjs --tag "${{ steps.tag.outputs.tag }}"
|
|
--gallery deploy/demo/gallery.json --driver r2 --bucket "$BUCKET" --remote
|
|
|
|
# 3) Build the standalone pinned to the CDN + this tag's manifests. The
|
|
# full KiCad library set is served read-only from libs/kicad/$LIB_TAG
|
|
# (published once by publish-libs.yml — run it first for a new lib tag).
|
|
- name: Build demo
|
|
run: >
|
|
node scripts/deploy/build-demo.mjs --tag "${{ steps.tag.outputs.tag }}"
|
|
--cdn "$CDN" --lib-tag "$LIB_TAG"
|
|
|
|
# 4) Ensure the Pages project exists (first deploy creates it; no-op after).
|
|
# Its production branch must equal PAGES_PROD_BRANCH or deploys land as
|
|
# previews and demo.pcbjam.com won't update.
|
|
- 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)"
|
|
|
|
# 5) Deploy to Cloudflare Pages. Attach demo.pcbjam.com to this project
|
|
# (Pages → $PAGES_PROJECT → Custom domains) for the custom domain to serve it.
|
|
- 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
|