diff --git a/packages/design-tokens/.github/release-request.txt b/packages/design-tokens/.github/release-request.txt new file mode 100644 index 0000000..26aaba0 --- /dev/null +++ b/packages/design-tokens/.github/release-request.txt @@ -0,0 +1 @@ +1.2.0 diff --git a/packages/design-tokens/.github/workflows/publish.yml b/packages/design-tokens/.github/workflows/publish.yml index 16716c7..69e319f 100644 --- a/packages/design-tokens/.github/workflows/publish.yml +++ b/packages/design-tokens/.github/workflows/publish.yml @@ -17,6 +17,9 @@ name: Publish on: push: tags: ['v*'] + # Called explicitly by the verified tag workflow. GITHUB_TOKEN tag pushes + # intentionally do not retrigger workflows. + workflow_dispatch: {} # Publishing is idempotent: the job first asks the registry whether # package.json's version already exists and skips (green) if it does. A diff --git a/packages/design-tokens/.github/workflows/tag-approved-release.yml b/packages/design-tokens/.github/workflows/tag-approved-release.yml new file mode 100644 index 0000000..94f1527 --- /dev/null +++ b/packages/design-tokens/.github/workflows/tag-approved-release.yml @@ -0,0 +1,91 @@ +name: Tag approved design release + +# A release request is intentional and version-specific. A successful CI run +# is evidence, not permission to tag any arbitrary future manifest version. +on: + workflow_run: + workflows: [CI] + types: [completed] + +permissions: {} + +concurrency: + group: approved-design-release + cancel-in-progress: false + +jobs: + tag: + name: Tag after passing main CI + if: >- + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.head_branch == 'main' && + github.event.workflow_run.event == 'push' + runs-on: ubuntu-latest + permissions: + contents: write + actions: write + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ github.event.workflow_run.head_sha }} + fetch-depth: 0 + + - name: Verify approved version, verified SHA and tag absence + id: approval + env: + VERIFIED_SHA: ${{ github.event.workflow_run.head_sha }} + shell: bash + run: | + set -euo pipefail + version="$(node -p "require('./package.json').version")" + requested="$(tr -d '\r\n' < .github/release-request.txt)" + echo "version=$version" >> "$GITHUB_OUTPUT" + + if [ "$version" != "$requested" ]; then + echo "No release requested for $version (request is $requested)." + echo "release=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + # Only the exact latest green main SHA can be released. + git fetch origin main --depth=1 + head="$(git rev-parse origin/main)" + if [ "$head" != "$VERIFIED_SHA" ]; then + echo "Newer main exists; wait for CI on that SHA." + echo "release=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + if git ls-remote --exit-code --tags origin "refs/tags/v$version" >/dev/null 2>&1; then + echo "v$version is already tagged, never move an existing tag." + echo "release=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + echo "release=true" >> "$GITHUB_OUTPUT" + + - name: Create immutable release tag + if: steps.approval.outputs.release == 'true' + env: + VERIFIED_SHA: ${{ github.event.workflow_run.head_sha }} + VERSION: ${{ steps.approval.outputs.version }} + shell: bash + run: | + set -euo pipefail + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + git tag -a "v$VERSION" -m "Verified design-tokens v$VERSION" "$VERIFIED_SHA" + git push origin "refs/tags/v$VERSION" + + # GITHUB_TOKEN-created tag pushes do NOT trigger another workflow. An + # explicit workflow_dispatch does; publish.yml retains its own gated + # NPM_PUBLISHING variable and will never bypass npm trusted publishing. + - name: Dispatch publication workflow for the tag + if: steps.approval.outputs.release == 'true' + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ steps.approval.outputs.version }} + shell: bash + run: | + gh workflow run publish.yml --ref "v$VERSION" + echo "Created v$VERSION and dispatched guarded publication." >> "$GITHUB_STEP_SUMMARY" diff --git a/packages/design-tokens/README.md b/packages/design-tokens/README.md index 79fcce7..e8c812b 100644 --- a/packages/design-tokens/README.md +++ b/packages/design-tokens/README.md @@ -15,9 +15,13 @@ three different companies. Copies drift; imports cannot. ## Retheming the entire stack -1. Edit the block marked `▼▼▼ THE KNOBS ▼▼▼` in `tokens.css`. Nothing else. -2. Tag a release: `git tag v1.2.0 && git push --tags` -3. Bump `@bitbaum/design-tokens` in the three apps. Their CI auto-merges. +1. Edit the block marked `▼▼▼ THE KNOBS ▼▼▼` in `tokens.css` for a retheme, or update the optional `composition.css` contract for interface improvements. +2. Bump `package.json`'s version **and** set the matching explicit `.github/release-request.txt`; submit a PR and pass package CI. +3. A successful **main-branch push CI** triggers `tag-approved-release.yml`. It tags only the exact latest verified SHA and never rewrites an existing version tag. +4. The tag workflow explicitly dispatches `publish.yml`; npm publishing is still guarded by `NPM_PUBLISHING` and requires trusted-publishing bootstrap. If that variable is off, a Git tag exists but **no npm release** is claimed. +5. Upgrade consumers to the confirmed Git tag, published npm version, or an exact source-commit SHA; run their frozen-lockfile CI. + +The one-time release request does not automatically approve future version bumps: a request must match the manifest version. Changing the display typeface is **one line**: @@ -62,9 +66,11 @@ For spacing, control sizing, visual rhythm and interaction *decisions*, colours, body style or global reset. ```tsx -// App Router — any React app may opt into the grammar without its brand skin -import '@bitbaum/design-tokens/composition.css'; +// App Router — load AFTER the app's CSS reset and BEFORE product CSS modules. +// The shared classes intentionally use :where() specificity, so importing +// them before a later universal '*' padding reset would erase their padding. import './globals.css'; +import '@bitbaum/design-tokens/composition.css'; ``` ```tsx @@ -103,12 +109,13 @@ and reduced-motion support. Apps own typography, colours, spacing adjustments, components and their content. Do **not** render all information as cards: the grammar deliberately offers whitespace and hairline lists. -**Release note:** this source tree is prepared as `1.2.0`, but changing the -manifest does not publish it. The existing `v1.1.0` tag does not contain -`composition.css`. Until the `v1.2.0` Git tag and/or npm package are actually -published, consumers must pin an **exact commit SHA** that includes the -stylesheet. Never import this subpath from a consumer pinned to `v1.1.0`. -No existing importer of `tokens.css` changes behaviour because of this addition. +**Release contract:** the new composition subpath first appears in +source version `1.2.0`; `v1.1.0` does **not** include it. The verified +tagging pipeline only tags a version explicitly requested in +`.github/release-request.txt` after main CI is green. Verify the +`v1.2.0` Git ref and the registry separately before claiming either is +published. Until then, use a verified exact commit SHA. Existing +`tokens.css` consumers do not change appearance by opting out. ## The contract