From 4662dc7f96cd87b2428a40a1ba6d0ef45d3f6c73 Mon Sep 17 00:00:00 2001 From: Kiro Agent <244629292+kiro-agent@users.noreply.github.com> Date: Fri, 22 May 2026 22:08:09 +0000 Subject: [PATCH 1/2] ci: auto-publish built bundles to a dedicated dist branch on merge Adds .github/workflows/publish-dist.yml: triggered on push to main, runs `npm run build`, then force-pushes the dist/ tree (plus a SOURCE.txt stamp recording the source commit) to a dedicated orphan `dist` branch. The dist branch contains only built artifacts at its root, so jsDelivr URLs become: https://cdn.jsdelivr.net/gh/codeslash-dev/SLASHED@dist/slashed.essential.min.css This keeps main free of generated files (the original goal of #63) without sacrificing the @main-style CDN distribution path. Build runs once per merge instead of on every commit, and concurrency is set to cancel-in-progress on the publish-dist group so racing merges don't race force-pushes. docs/demo.html migrated to @dist for the built bundle (line 8). The optional/tokens.palette.css link stays on @main because it references a source file that lives only on main. Existing @main/dist/ URLs continue to work for now (dist/ is on main courtesy of #65). After the dist branch is verified populated, a follow-up PR can re-add dist/ to .gitignore and remove it from main, completing the original cleanup safely. --- .github/workflows/publish-dist.yml | 80 ++++++++++++++++++++++++++++++ docs/demo.html | 5 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-dist.yml diff --git a/.github/workflows/publish-dist.yml b/.github/workflows/publish-dist.yml new file mode 100644 index 00000000..c2e63190 --- /dev/null +++ b/.github/workflows/publish-dist.yml @@ -0,0 +1,80 @@ +name: Publish dist branch + +# Builds the CSS bundles after every merge to main and force-pushes the +# resulting dist/ tree to a dedicated `dist` branch. The `dist` branch is +# orphan (no shared history with main) and contains only the generated +# bundles at its root, so consumers can reference them via: +# +# https://cdn.jsdelivr.net/gh/codeslash-dev/SLASHED@dist/slashed.essential.min.css +# +# Source files (core/, optional/, etc.) live only on main; built files live +# only on dist. This keeps main free of generated artifacts while still +# giving the CDN something to serve. + +on: + push: + branches: [main] + workflow_dispatch: + +# If several merges land in quick succession, cancel any in-flight publish +# and rerun against the newest commit only. Prevents racing force-pushes. +concurrency: + group: publish-dist + cancel-in-progress: true + +permissions: + contents: write + +jobs: + publish-dist: + name: Build and force-push dist branch + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Build dist bundles + run: npm run build + + - name: Stage dist for orphan branch + run: | + set -euo pipefail + mkdir -p /tmp/sf-dist + cp -R dist/. /tmp/sf-dist/ + # Stamp file so consumers can verify exactly which source commit + # produced this dist tree. + { + echo "source-commit: ${GITHUB_SHA}" + echo "source-ref: ${GITHUB_REF}" + echo "built-at: $(date -u +%Y-%m-%dT%H:%M:%SZ)" + echo "built-by: .github/workflows/publish-dist.yml" + } > /tmp/sf-dist/SOURCE.txt + + - name: Force-push dist branch + env: + GIT_AUTHOR_NAME: github-actions[bot] + GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com + GIT_COMMITTER_NAME: github-actions[bot] + GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com + run: | + set -euo pipefail + git checkout --orphan dist + # The orphan checkout still stages main's tree; remove it all so + # only built artifacts end up on the dist branch. + git rm -rf . > /dev/null + shopt -s dotglob + cp -R /tmp/sf-dist/. . + git add -A + git commit -m "build: dist for ${GITHUB_SHA}" + git push --force origin dist diff --git a/docs/demo.html b/docs/demo.html index a5d48f8b..8d49d166 100644 --- a/docs/demo.html +++ b/docs/demo.html @@ -5,7 +5,10 @@ SLASHED — Demo - + +