From ca0b51f6bc3bfdde55df724787a972ab9d10ee53 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:14:59 +0000 Subject: [PATCH 01/12] test(release): require the frozen caller to forward every secret the release entry declares --- scripts/release-train/caller.test.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/release-train/caller.test.ts b/scripts/release-train/caller.test.ts index cd8c010..983b0bd 100644 --- a/scripts/release-train/caller.test.ts +++ b/scripts/release-train/caller.test.ts @@ -78,7 +78,13 @@ describe("the frozen caller", () => { for (const registry of ["public", "private"]) { const file = `release-npm-${registry}.yml`; const entry = read(`../../.github/workflows/${file}`); - const job = registry === "public" ? caller : caller.replace("release-npm-public.yml", file).replace(" id-token: write\n", ""); + const job = + registry === "public" + ? caller + : caller + .replace("release-npm-public.yml", file) + .replace(" id-token: write\n", "") + .replace(/(\n {6}RELEASE_APP_PRIVATE_KEY: .*\n)/, "$1 NPM_ANTELOPE_TOKEN: ${{ secrets.NPM_ANTELOPE_TOKEN }}\n"); test(`calls ${file} with inputs, secrets and permissions it accepts`, () => { assert.match(job, new RegExp(`uses: AntelopeJS/\\.github/\\.github/workflows/${file.replace(".", "\\.")}@v2\\n`)); @@ -87,8 +93,11 @@ describe("the frozen caller", () => { assert.deepEqual(passed.filter((name) => !accepted.has(name)), []); const required = [...accepted].filter(([, lines]) => lines.includes("required: true")).map(([name]) => name); assert.deepEqual(required.filter((name) => !passed.includes(name)), []); - const secrets = [...entries(entry, ["workflow_call", "secrets"])].filter(([, lines]) => lines.includes("required: true")); - assert.deepEqual(secrets, []); + const declaredSecrets = entries(entry, ["workflow_call", "secrets"]); + assert.deepEqual([...declaredSecrets].filter(([, lines]) => lines.includes("required: true")), []); + const passedSecrets = entries(job, ["jobs", "release", "secrets"]); + assert.deepEqual([...passedSecrets.keys()].sort(), [...declaredSecrets.keys()].sort(), `the caller forwards every secret ${file} declares`); + for (const [name, value] of passedSecrets) assert.deepEqual(value, [`\${{ secrets.${name} }}`]); const granted = entries(job, ["permissions"]); for (const [scope, [level = ""]] of entries(entry, ["jobs", "release", "permissions"])) { const grant = granted.get(scope)?.[0]; From 3b090a8b19c304083edb947d892aff16e3ba7e80 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:15:39 +0000 Subject: [PATCH 02/12] fix(release): forward the release app secrets in the frozen caller, as antelopejs-sync writes it --- AGENTS.md | 2 +- README.md | 32 +++++++++++++++---------- scripts/release-train/frozen-caller.yml | 4 ++++ workflow-templates/npm-release.yml | 4 ++++ 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d57fc37..8f130aa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ This repository holds the AntelopeJS organization defaults: the community health ## Callers -Every repository calls the shared workflows at the `v2` tag, as in `AntelopeJS/.github/.github/workflows/ci-node.yml@v2`. A change on `main` reaches no caller until the tag moves, and `v2` moves only when Antony says so. The callers are frozen: a change keeps every existing input, default, secret and permission as they are, so each caller keeps working without an edit. `scripts/release-train/frozen-caller.yml` is the release caller that `antelopejs-sync` writes, and `caller.test.ts` checks the release workflows against it. +Every repository calls the shared workflows at the `v2` tag, as in `AntelopeJS/.github/.github/workflows/ci-node.yml@v2`. A change on `main` reaches no caller until the tag moves, and `v2` moves only when Antony says so. The callers are frozen: a change keeps every existing input, default, secret and permission as they are, so each caller keeps working without an edit. One exception predates the rule: a stable or repin release mints its token from `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY`, so every release caller forwards those two secrets, as `antelopejs-sync` writes them, before `v2` moves. `scripts/release-train/frozen-caller.yml` is the release caller that `antelopejs-sync` writes, and `caller.test.ts` checks the release workflows against it. ## Checks diff --git a/README.md b/README.md index 1d5e2ec..86fc5ca 100644 --- a/README.md +++ b/README.md @@ -428,16 +428,17 @@ stable release. ### What a caller declares -`antelopejs-sync` of `@antelopejs/tooling-configs` 0.8.5 writes this caller, -and the shared workflows at `@v2` work with it unchanged. +`antelopejs-sync` of the first `@antelopejs/tooling-configs` release after +0.9.2 writes this caller. A caller written by an older `antelopejs-sync` +forwards only `RELEASE_GITHUB_TOKEN`, and its stable and repin runs fail once +`v2` moves, so every caller forwards the two app secrets before it does. - **File.** `.github/workflows/release.yml`. npm trusted publishing names this file, and the release train dispatches it. -- **Triggers.** `push` to the default branch for previews, and - `workflow_dispatch` for stable releases. A caller that adds `pull_request` - with the types `opened`, `synchronize`, `reopened` and `labeled` publishes a - [pull request preview](#pull-request-previews) for each pull request that - carries the `preview` label. +- **Triggers.** `push` to the default branch for previews, `pull_request` + with the types `labeled`, `synchronize` and `reopened` for a + [pull request preview](#pull-request-previews) of each pull request that + carries the `preview` label, and `workflow_dispatch` for stable releases. - **Dispatch inputs.** `release-version`, `release-commit` and `dependency-ranges` (default `"{}"`), all optional strings that the release train sets. A repository whose package is not at its root adds @@ -449,10 +450,11 @@ and the shared workflows at `@v2` work with it unchanged. the release app token. - **Optional inputs.** Every other input of the shared workflows has a default that fits this caller. A caller may set `install-core`. -- **Secrets.** `RELEASE_GITHUB_TOKEN` for the public workflow, plus - `NPM_ANTELOPE_TOKEN` for the private one, each passed by name. The shared - workflows no longer read `RELEASE_GITHUB_TOKEN`: a stable or repin run needs - `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY` passed the same way. +- **Secrets.** `RELEASE_GITHUB_TOKEN`, `RELEASE_APP_ID` and + `RELEASE_APP_PRIVATE_KEY`, plus `NPM_ANTELOPE_TOKEN` for the private + workflow, each passed by name. A stable or repin run mints its token from the + two app secrets and fails without them. No step reads + `RELEASE_GITHUB_TOKEN`. - **Call.** `release-npm-public.yml@v2` or `release-npm-private.yml@v2`, with each dispatch input passed through under the same name. `release-npm.yml@v2` takes the same call with `registry: public` or `registry: private`. @@ -461,8 +463,8 @@ and the shared workflows at `@v2` work with it unchanged. ### Caller workflow -The caller is the `release.yml` of the repository. It needs both triggers and -passes the inputs the release train sets: +The caller is the `release.yml` of the repository. It declares the three +triggers, passes the inputs the release train sets and forwards the secrets: ```yaml name: Release @@ -470,6 +472,8 @@ name: Release on: push: branches: [main] + pull_request: + types: [labeled, synchronize, reopened] workflow_dispatch: inputs: release-version: @@ -499,6 +503,8 @@ jobs: dependency-ranges: ${{ inputs.dependency-ranges }} secrets: RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }} + RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} ``` A private package calls `release-npm-private.yml` and also passes diff --git a/scripts/release-train/frozen-caller.yml b/scripts/release-train/frozen-caller.yml index 484739a..a7a6625 100644 --- a/scripts/release-train/frozen-caller.yml +++ b/scripts/release-train/frozen-caller.yml @@ -3,6 +3,8 @@ name: Release on: push: branches: [main] + pull_request: + types: [labeled, synchronize, reopened] workflow_dispatch: inputs: release-version: @@ -32,3 +34,5 @@ jobs: dependency-ranges: ${{ inputs.dependency-ranges }} secrets: RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }} + RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} diff --git a/workflow-templates/npm-release.yml b/workflow-templates/npm-release.yml index 484739a..a7a6625 100644 --- a/workflow-templates/npm-release.yml +++ b/workflow-templates/npm-release.yml @@ -3,6 +3,8 @@ name: Release on: push: branches: [main] + pull_request: + types: [labeled, synchronize, reopened] workflow_dispatch: inputs: release-version: @@ -32,3 +34,5 @@ jobs: dependency-ranges: ${{ inputs.dependency-ranges }} secrets: RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }} + RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} From e414f846d5d39663c934ee325cf3b15fd10980f3 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:16:31 +0000 Subject: [PATCH 03/12] test(ci-node): decide Windows legs on a schedule payload that carries no repository --- scripts/release-train/workflows.test.ts | 49 ++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/scripts/release-train/workflows.test.ts b/scripts/release-train/workflows.test.ts index b961a2a..eb6c040 100644 --- a/scripts/release-train/workflows.test.ts +++ b/scripts/release-train/workflows.test.ts @@ -53,6 +53,7 @@ interface Scope { inputs?: object; github?: object; vars?: object; + needs?: object; } function evaluate(expression: string, scope: Scope): unknown { @@ -64,7 +65,7 @@ function evaluate(expression: string, scope: Scope): unknown { .replace(/!=/g, "!=="); assert.doesNotMatch(source, /\*/, `the test cannot evaluate ${expression}`); const contains = (list: string[], item: string): boolean => list.includes(item); - return new Function("steps", "inputs", "github", "vars", "contains", "fromJSON", `return (${source})`)(scope.steps, scope.inputs, scope.github, scope.vars, contains, JSON.parse); + return new Function("steps", "inputs", "github", "vars", "needs", "contains", "fromJSON", `return (${source})`)(scope.steps, scope.inputs, scope.github, scope.vars, scope.needs, contains, JSON.parse); } function interpolate(template: string, scope: Scope): string { @@ -1359,10 +1360,24 @@ describe("release-npm.yml", () => { }); describe("ci-node.yml", () => { - test("Windows legs join the matrix only for a public repository, and only in the tiers that ran them before", () => { - const matrix = /^ {8}os: (.*)$/m.exec(workflowText("ci-node.yml"))?.[1] ?? ""; - const os = (visibility: string, event: string, inputs: object): unknown => - evaluate(matrix, { github: { event_name: event, event: { repository: { visibility } } }, inputs }); + const ciNode = workflowText("ci-node.yml"); + const jobText = (name: string): string => { + const start = ciNode.indexOf(`\n ${name}:\n`); + assert.notEqual(start, -1, `no job ${name}`); + const next = /\n {2}[\w-]+:\n/g; + next.lastIndex = start + 1; + return ciNode.slice(start, next.exec(ciNode)?.index); + }; + + test("Windows legs join the matrix only for a repository the API reports public, and only in the tiers that ran them before", () => { + const gate = /^ {4}if: (.*)$/m.exec(jobText("windows"))?.[1] ?? ""; + const matrix = /^ {8}os: (.*)$/m.exec(jobText("node"))?.[1] ?? ""; + assert.doesNotMatch(matrix, /github\.event\.repository/, "a schedule payload carries no repository"); + const os = (visibility: string, event: string, inputs: object): unknown => { + const github = { event_name: event, event: {} }; + const ran = evaluate(gate, { github, inputs }) === true; + return evaluate(matrix, { github, inputs, needs: { windows: { outputs: { visibility: ran ? visibility : "" } } } }); + }; const events = ["schedule", "merge_group", "workflow_dispatch", "pull_request", "push"]; for (const visibility of ["public", "private", "internal"]) { for (const event of events) { @@ -1376,6 +1391,30 @@ describe("ci-node.yml", () => { } } }); + + test("the Windows gate reads the visibility with one API call and fails when the call fails", () => { + const bin = join(root, "windows-gate-bin"); + mkdirSync(bin, { recursive: true }); + const log = join(root, "windows-gate-gh.log"); + writeFileSync(join(bin, "gh"), '#!/usr/bin/env bash\nprintf \'%s\\n\' "$*" >> "$GH_LOG"\n[ -n "$FAKE_VISIBILITY" ] || exit 1\necho "$FAKE_VISIBILITY"\n'); + chmodSync(join(bin, "gh"), 0o755); + const env = { PATH: `${bin}:${process.env.PATH ?? ""}`, GH_LOG: log, GITHUB_REPOSITORY: "AntelopeJS/x" }; + for (const visibility of ["public", "private"]) { + writeFileSync(log, ""); + const result = runStep(ciNode, "Read the repository visibility", root, { ...env, FAKE_VISIBILITY: visibility }); + assert.equal(result.status, 0, result.stderr); + assert.equal(result.outputs, `visibility=${visibility}\n`); + assert.equal(readFileSync(log, "utf8"), "api repos/AntelopeJS/x --jq .visibility\n"); + } + const failed = runStep(ciNode, "Read the repository visibility", root, { ...env, FAKE_VISIBILITY: "" }); + assert.notEqual(failed.status, 0); + assert.equal(failed.outputs, ""); + }); + + test("a failed Windows gate fails the run instead of dropping the Windows legs", () => { + assert.match(jobText("node"), /^ {4}needs: windows\n {4}if: \$\{\{ !cancelled\(\) && needs\.windows\.result != 'failure' \}\}$/m); + assert.match(jobText("checks"), /^ {4}needs: \[windows, node, stress\]$/m); + }); }); test("the starter workflow is the frozen caller that antelopejs-sync writes", () => { From e0c02aab315939aea69ee925de5b610599c70c74 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:17:09 +0000 Subject: [PATCH 04/12] test(release): pin the permissions each release app token asks --- .github/workflows/ci-node.yml | 29 ++++++++++++++++++++++++---- scripts/release-train/caller.test.ts | 13 +++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-node.yml b/.github/workflows/ci-node.yml index f37c63d..0b292b0 100644 --- a/.github/workflows/ci-node.yml +++ b/.github/workflows/ci-node.yml @@ -77,12 +77,33 @@ on: required: false jobs: + windows: + name: Windows eligibility + if: inputs.windows && (github.event_name == 'schedule' || ((github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') && (inputs.windows-merge-queue || inputs.windows-pull-requests))) + runs-on: ${{ vars.RUNNER_CI || 'ubuntu-latest' }} + timeout-minutes: 5 + permissions: + contents: read + outputs: + visibility: ${{ steps.visibility.outputs.visibility }} + steps: + - name: Read the repository visibility + id: visibility + env: + GH_TOKEN: ${{ github.token }} + run: | + visibility=$(gh api "repos/$GITHUB_REPOSITORY" --jq .visibility) + echo "visibility=$visibility" >> "$GITHUB_OUTPUT" + node: + needs: windows + if: ${{ !cancelled() && needs.windows.result != 'failure' }} name: ${{ matrix.part == 'test' && 'Test' || matrix.part == 'extra' && 'Extra' || 'Node' }} ${{ matrix.node-version || '.nvmrc' }}${{ matrix.os == 'windows-latest' && ' on Windows' || '' }} # Linux legs on our runners when the CALLING repository's variable RUNNER_CI names a scale set (the # private repositories: antelope-ci), and on GitHub's runners when RUNNER_CI is empty or unset (every - # public repository). Windows legs run only for a public calling repository, on GitHub's runners: no - # private or internal repository gets one. Set RUNNER_CI per repository, never at organisation + # public repository). Windows legs run only for a calling repository the API reports public, on + # GitHub's runners: no private or internal repository gets one, and a schedule payload carries no + # repository to read it from. Set RUNNER_CI per repository, never at organisation # level: the runner group refuses public repositories, and their jobs would wait forever. runs-on: ${{ matrix.os == 'ubuntu-latest' && vars.RUNNER_CI || matrix.os }} permissions: @@ -90,7 +111,7 @@ jobs: strategy: fail-fast: false matrix: - os: ${{ fromJSON(inputs.windows && github.event.repository.visibility == 'public' && (github.event_name == 'schedule' || ((github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') && (inputs.windows-merge-queue || inputs.windows-pull-requests))) && '["ubuntu-latest","windows-latest"]' || '["ubuntu-latest"]') }} + os: ${{ fromJSON(needs.windows.outputs.visibility == 'public' && '["ubuntu-latest","windows-latest"]' || '["ubuntu-latest"]') }} node-version: ${{ fromJSON(inputs.node-versions || '[""]') }} part: ${{ fromJSON(format('[{0}{1}]', inputs.single-job && inputs.services-compose-file == '' && '"all"' || '"checks","test"', inputs.extra-commands-job && inputs.extra-commands != '' && ',"extra"' || '')) }} defaults: @@ -586,7 +607,7 @@ jobs: checks: if: always() - needs: [node, stress] + needs: [windows, node, stress] runs-on: ${{ vars.RUNNER_CI || 'ubuntu-latest' }} timeout-minutes: 5 permissions: {} diff --git a/scripts/release-train/caller.test.ts b/scripts/release-train/caller.test.ts index 983b0bd..e2a9d4b 100644 --- a/scripts/release-train/caller.test.ts +++ b/scripts/release-train/caller.test.ts @@ -186,3 +186,16 @@ test("no shared workflow reads RELEASE_GITHUB_TOKEN, and each one that writes to const minting = workflows.filter((name) => /uses: actions\/create-github-app-token@[0-9a-f]{40} /.test(read(`../../.github/workflows/${name}`))); assert.deepEqual(minting, ["module-locks-refresh.yml", "module-locks-renovate.yml", "next-sync.yml", "release-npm.yml"]); }); + +test("each release app token asks only the permissions its job uses", () => { + const asked = (name: string): string[] => { + const text = read(`../../.github/workflows/${name}`); + const steps = text.split(/\n {6}- /).filter((step) => /uses: actions\/create-github-app-token@/.test(step)); + assert.equal(steps.length, 1, name); + return [...(steps[0] ?? "").matchAll(/^ {10}(permission-[\w-]+: \w+)$/gm)].map(([, line]) => line ?? ""); + }; + assert.deepEqual(asked("release-npm.yml"), ["permission-contents: write", "permission-pull-requests: read"]); + assert.deepEqual(asked("next-sync.yml"), ["permission-contents: write"]); + assert.deepEqual(asked("module-locks-renovate.yml"), ["permission-contents: write"]); + assert.deepEqual(asked("module-locks-refresh.yml"), ["permission-contents: write", "permission-pull-requests: write"]); +}); From 1e984ae8ed2e6190f1760b86f75a1862af6b90ae Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:18:31 +0000 Subject: [PATCH 05/12] fix(ci-node): read the repository visibility from the API, which every event reaches --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 86fc5ca..18730e3 100644 --- a/README.md +++ b/README.md @@ -673,7 +673,7 @@ It accepts these optional inputs: | `single-job` | `true` | Run the checks and the tests in one job per runner. Pass `false` to run the tests in a job of their own, in parallel with the checks, when they take minutes. A caller with `services-compose-file` always gets separate jobs. | | `test-job` | `false` | Accepted and ignored. The tests run as a step of the single job, or in a job of their own with `single-job: false`. | | `extra-commands-job` | `false` | Run `extra-commands` in their own job, in parallel with the other checks. Use it only when the commands do not read files that `pnpm run checks` writes, such as a build. | -| `windows` | `true` | Also run the jobs on `windows-latest`, in parallel with `ubuntu-latest`, in the `nightly` tier, and with `windows-merge-queue` in the `queue` tier and on manual runs. Windows runs only when the calling repository is public. Private and internal repositories skip it: we have no Windows runner of our own, and GitHub bills their hosted minutes. Steps and package scripts run in Git Bash, and git checks out with `core.autocrlf false` and `core.symlinks true`. The Windows jobs skip services and the skill evals, so tests that need the services must not run there. A caller that cannot run on Windows passes `false` and states the reason in its workflow. | +| `windows` | `true` | Also run the jobs on `windows-latest`, in parallel with `ubuntu-latest`, in the `nightly` tier, and with `windows-merge-queue` in the `queue` tier and on manual runs. Windows runs only when the calling repository is public, which a `Windows eligibility` job reads from the API once per run, because a `schedule` payload names no repository. Private and internal repositories skip it: we have no Windows runner of our own, and GitHub bills their hosted minutes. Steps and package scripts run in Git Bash, and git checks out with `core.autocrlf false` and `core.symlinks true`. The Windows jobs skip services and the skill evals, so tests that need the services must not run there. A caller that cannot run on Windows passes `false` and states the reason in its workflow. | | `windows-merge-queue` | `false` | With `windows`, also run the Windows jobs in the `queue` tier and on manual runs. | | `windows-pull-requests` | `false` | Accepted. The former name of `windows-merge-queue`, with the same effect. | | `module-locks` | `false` | After the install, tests and `extra-commands` of each job, run the [module locks committed](#module-locks-committed) action: the job fails when it wrote an `antelope-lock/` file that is not committed, and on a Renovate pull request it uploads what it wrote. Pass `true` in a repository that commits an `antelope-lock/` folder. | From 7f3a1b97efded2132eb8384bac32d335e69f66a7 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:18:31 +0000 Subject: [PATCH 06/12] fix(release): scope each release app token to the permissions its job uses, and end dirname options --- .github/workflows/module-locks-refresh.yml | 2 ++ .github/workflows/module-locks-renovate.yml | 3 ++- .github/workflows/next-sync.yml | 1 + .github/workflows/release-npm.yml | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/module-locks-refresh.yml b/.github/workflows/module-locks-refresh.yml index 544b9e7..ddeeb43 100644 --- a/.github/workflows/module-locks-refresh.yml +++ b/.github/workflows/module-locks-refresh.yml @@ -209,6 +209,8 @@ jobs: with: app-id: ${{ secrets.RELEASE_APP_ID }} private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + permission-contents: write + permission-pull-requests: write - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 if: env.STATE == 'changed' diff --git a/.github/workflows/module-locks-renovate.yml b/.github/workflows/module-locks-renovate.yml index 23af3ef..d56d6b8 100644 --- a/.github/workflows/module-locks-renovate.yml +++ b/.github/workflows/module-locks-renovate.yml @@ -95,7 +95,7 @@ jobs: } END { exit !found }' "$1" } - git ls-files -z --others --exclude-standard -- ':(glob)**/antelope-lock/**' | xargs -0 -r -n1 dirname | sort -u > "$work/recorded" + git ls-files -z --others --exclude-standard -- ':(glob)**/antelope-lock/**' | xargs -0 -r -n1 dirname -- | sort -u > "$work/recorded" while IFS= read -r lock; do name="${lock%@*}" while IFS= read -r committed; do @@ -135,6 +135,7 @@ jobs: with: app-id: ${{ secrets.RELEASE_APP_ID }} private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + permission-contents: write - name: Push the locks to the Renovate branch if: steps.commit.outputs.committed == 'true' diff --git a/.github/workflows/next-sync.yml b/.github/workflows/next-sync.yml index 87b9218..5837988 100644 --- a/.github/workflows/next-sync.yml +++ b/.github/workflows/next-sync.yml @@ -52,6 +52,7 @@ jobs: with: app-id: ${{ secrets.RELEASE_APP_ID }} private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + permission-contents: write - name: Merge id: merge diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index d8f563c..186b9ae 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -117,6 +117,8 @@ jobs: with: app-id: ${{ secrets.RELEASE_APP_ID }} private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + permission-contents: write + permission-pull-requests: read - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: From bd57506b852633a4ea1801a0ad9a9f1391d39676 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:21:39 +0000 Subject: [PATCH 07/12] test(module-locks): refuse a refresh patch that touches .github, adds a symlink or submodule, or escapes the checkout --- scripts/module-locks/module-locks.test.ts | 66 ++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/scripts/module-locks/module-locks.test.ts b/scripts/module-locks/module-locks.test.ts index f760d99..3d890ec 100644 --- a/scripts/module-locks/module-locks.test.ts +++ b/scripts/module-locks/module-locks.test.ts @@ -1,6 +1,6 @@ import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; -import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { after, describe, test } from "node:test"; @@ -20,6 +20,7 @@ const COPY = "Copy the recorded locks into the checkout"; const COMMIT = "Commit the locks"; const LOCK_COMMIT = "build(deps): record the module locks of the bumped modules"; const BRANCH = "antelopejs/module-locks"; +const CHECK = "Check the refresh patch"; const root = mkdtempSync(join(tmpdir(), "module-locks-")); after(() => rmSync(root, { recursive: true, force: true })); @@ -219,6 +220,69 @@ describe("module-locks-refresh.yml", () => { assert.equal(readFileSync(log, "utf8"), "project modules update --fix -p a\nproject modules update --fix -p b\n"); }); + describe("checks the refresh patch before it pushes", () => { + const checkPatch = (dir: string, patch: string): StepResult => { + runs += 1; + const temp = join(root, `patch-${runs}`); + mkdirSync(join(temp, "module-locks"), { recursive: true }); + writeFileSync(join(temp, "module-locks", "refresh.patch"), patch); + return runStep(refresh, CHECK, dir, { RUNNER_TEMP: temp }); + }; + const staged = (dir: string, change: () => void): string => { + change(); + git(dir, "add", "-A"); + const patch = spawnSync("git", ["diff", "--cached", "--binary"], { cwd: dir, encoding: "utf8" }).stdout; + git(dir, "reset", "-q", "--hard"); + return patch; + }; + const base = (): string => repository({ ...lock("antelope-lock", "@antelopejs/api@1.0.0"), "package.json": '{"name":"app"}\n', "antelope.config.ts": "export default {};\n" }); + + test("passes a refresh that moves locks, ranges and other files, and leaves the checkout alone", () => { + const dir = base(); + const patch = staged(dir, () => { + rmSync(join(dir, "antelope-lock"), { recursive: true }); + write(dir, { ...lock("antelope-lock", "@antelopejs/api@1.1.0"), "package.json": '{"name":"app","version":"1"}\n', "antelope.config.ts": "export default { a: 1 };\n", "pnpm-lock.yaml": "x\n" }); + }); + const check = checkPatch(dir, patch); + assert.equal(check.status, 0, check.stdout + check.stderr); + assert.equal(git(dir, "status", "--porcelain"), ""); + }); + + const refused: [string, (dir: string) => void, RegExp][] = [ + ["a workflow", (dir) => write(dir, { ".github/workflows/x.yml": "on: push\n" }), /\.github\/workflows\/x\.yml, which is under \.github/], + ["a symlink", (dir) => symlinkSync("/etc/passwd", join(dir, "antelope-lock", "link")), /antelope-lock\/link, which is a symlink/], + [ + "a submodule", + (dir) => { + mkdirSync(join(dir, "vendor", "x"), { recursive: true }); + git(join(dir, "vendor", "x"), "init", "-q"); + git(join(dir, "vendor", "x"), "commit", "-q", "--allow-empty", "-m", "x"); + }, + /vendor\/x, which is a submodule/, + ], + ["a .gitmodules", (dir) => write(dir, { ".gitmodules": "[submodule \"x\"]\n" }), /\.gitmodules, which is under \.github or declares submodules/], + ]; + for (const [name, change, message] of refused) { + test(`refuses ${name}`, () => { + const dir = base(); + const check = checkPatch(dir, staged(dir, () => change(dir))); + assert.notEqual(check.status, 0); + assert.match(check.stdout, message); + assert.match(check.stdout, /Nothing was pushed/); + }); + } + + for (const [name, path] of [["a path outside the checkout", "../outside"], ["a path under .git", ".git/hooks/post-checkout"]]) { + test(`refuses ${name}`, () => { + const dir = base(); + const check = checkPatch(dir, `diff --git a/${path} b/${path}\nnew file mode 100644\n--- /dev/null\n+++ b/${path}\n@@ -0,0 +1 @@\n+x\n`); + assert.notEqual(check.status, 0); + assert.match(check.stdout, /::error::The refresh patch does not apply/); + assert.equal(existsSync(join(dir, path)), false); + }); + } + }); + test("fails with the fix when no folder holds node_modules/.bin/ajs", () => { const dir = repository({ "playground/antelope.config.ts": "export default {};\n" }); From 86d2833b798a171e002a90f463fd80555f749114 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:21:39 +0000 Subject: [PATCH 08/12] fix(module-locks): check the refresh patch before the release app token pushes it --- .github/workflows/module-locks-refresh.yml | 27 ++++++++++++++++++++++ README.md | 6 +++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/module-locks-refresh.yml b/.github/workflows/module-locks-refresh.yml index ddeeb43..d131c6b 100644 --- a/.github/workflows/module-locks-refresh.yml +++ b/.github/workflows/module-locks-refresh.yml @@ -223,6 +223,33 @@ jobs: name: module-locks path: ${{ runner.temp }}/module-locks + - name: Check the refresh patch + if: env.STATE == 'changed' + run: | + out="$RUNNER_TEMP/module-locks" + export GIT_INDEX_FILE="$out/check.index" + git read-tree HEAD + git apply --cached "$out/refresh.patch" || { + echo "::error::The refresh patch does not apply to $(git rev-parse HEAD). Nothing was pushed." + exit 1 + } + git diff --cached --no-renames --raw -z HEAD > "$out/check.raw" + refused=0 + while IFS= read -r -d '' meta && IFS= read -r -d '' path; do + read -r _ mode _ <<< "$meta" + case "$path" in + .github/* | .gitmodules) reason="is under .github or declares submodules" ;; + *) case "$mode" in + 120000) reason="is a symlink" ;; + 160000) reason="is a submodule" ;; + *) continue ;; + esac ;; + esac + printf '::error::The refresh patch changes %q, which %s. Nothing was pushed.\n' "$path" "$reason" + refused=1 + done < "$out/check.raw" + exit "$refused" + - name: Push the refreshed locks if: env.STATE == 'changed' env: diff --git a/README.md b/README.md index 18730e3..4ed10ab 100644 --- a/README.md +++ b/README.md @@ -797,8 +797,10 @@ command records the newest release each range accepts, resolves the dependencies of every locked module again and deletes the locks no environment uses. It runs a second time when the first run fails, until a core release carries AntelopeJS/antelopejs#535. The workflow then runs -`pnpm install --no-frozen-lockfile` and the caller's `commands`. When a file -changed, it pushes the result to `antelopejs/module-locks` with an installation +`pnpm install --no-frozen-lockfile` and the caller's `commands`. It fails +without pushing when the change touches `.github/` or `.gitmodules`, adds a +symlink or a submodule, or holds a path `git apply` refuses, such as one under +`.git` or outside the checkout. When a file changed, it pushes the result to `antelopejs/module-locks` with an installation token of the `antelopejs-release` GitHub App and opens a pull request into the default branch, or updates the one already open. The pull request body lists the module versions From c52fc9264b33a3718f9afb5333f2974814197ef4 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:27:57 +0000 Subject: [PATCH 09/12] test(release): cover the app secrets, the RELEASE_GITHUB_TOKEN fallback and neither, in releases and next-sync --- scripts/release-train/caller.test.ts | 14 +++++-- scripts/release-train/workflows.test.ts | 52 +++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/scripts/release-train/caller.test.ts b/scripts/release-train/caller.test.ts index e2a9d4b..d678909 100644 --- a/scripts/release-train/caller.test.ts +++ b/scripts/release-train/caller.test.ts @@ -105,7 +105,7 @@ describe("the frozen caller", () => { } }); - test(`${file} forwards every input but integration-branch and every secret but RELEASE_GITHUB_TOKEN to release-npm.yml, and names its registry`, () => { + test(`${file} forwards every input but integration-branch and every secret to release-npm.yml, and names its registry`, () => { const forwarded = entries(entry, ["jobs", "release", "with"]); assert.deepEqual([...forwarded.keys()].sort(), [...entries(release, ["workflow_call", "inputs"]).keys()].sort()); assert.deepEqual(forwarded.get("registry"), [registry]); @@ -117,7 +117,7 @@ describe("the frozen caller", () => { assert.equal(declaredInputs.get("integration-branch")?.some((line) => line.startsWith("default:")), false); for (const name of declaredInputs.keys()) if (forwarded.has(name)) assert.deepEqual(forwarded.get(name), [`\${{ inputs.${name} }}`]); const secrets = entries(entry, ["jobs", "release", "secrets"]); - assert.deepEqual([...secrets.keys()], [...entries(entry, ["workflow_call", "secrets"]).keys()].filter((name) => name !== "RELEASE_GITHUB_TOKEN")); + assert.deepEqual([...secrets.keys()], [...entries(entry, ["workflow_call", "secrets"]).keys()]); for (const [name, value] of secrets) assert.deepEqual(value, [`\${{ secrets.${name} }}`]); }); @@ -179,10 +179,16 @@ describe("the frozen caller", () => { } }); -test("no shared workflow reads RELEASE_GITHUB_TOKEN, and each one that writes to the repository mints a release app token", () => { +test("RELEASE_GITHUB_TOKEN only stands in for the release app token, and each workflow that writes to the repository mints one", () => { const directory = new URL("../../.github/workflows/", import.meta.url); const workflows = readdirSync(directory).filter((name) => name.endsWith(".yml")); - assert.deepEqual(workflows.filter((name) => read(`../../.github/workflows/${name}`).includes("secrets.RELEASE_GITHUB_TOKEN")), []); + const reading = workflows.filter((name) => read(`../../.github/workflows/${name}`).includes("secrets.RELEASE_GITHUB_TOKEN")); + assert.deepEqual(reading, ["next-sync.yml", "release-npm-private.yml", "release-npm-public.yml", "release-npm.yml"]); + for (const name of reading) { + const text = read(`../../.github/workflows/${name}`); + const uses = text.split("\n").filter((line) => line.includes("RELEASE_GITHUB_TOKEN }}") || line.includes("steps.token.outputs.token")); + for (const line of uses) assert.match(line.trim(), /^(RELEASE_GITHUB_TOKEN: \$\{\{ secrets\.RELEASE_GITHUB_TOKEN \}\}|\w+: \$\{\{ steps\.token\.outputs\.token \|\| secrets\.RELEASE_GITHUB_TOKEN \}\})$/, `${name}: ${line}`); + } const minting = workflows.filter((name) => /uses: actions\/create-github-app-token@[0-9a-f]{40} /.test(read(`../../.github/workflows/${name}`))); assert.deepEqual(minting, ["module-locks-refresh.yml", "module-locks-renovate.yml", "next-sync.yml", "release-npm.yml"]); }); diff --git a/scripts/release-train/workflows.test.ts b/scripts/release-train/workflows.test.ts index eb6c040..44ada4c 100644 --- a/scripts/release-train/workflows.test.ts +++ b/scripts/release-train/workflows.test.ts @@ -8,6 +8,7 @@ import { nonRegistrySpecs, registrySpecs } from "./registry-specs.ts"; const workflowText = (file: string): string => readFileSync(new URL(`../../.github/workflows/${file}`, import.meta.url), "utf8"); const text = workflowText("release-npm.yml"); +const NO_CREDENTIALS = "RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not configured, and no RELEASE_GITHUB_TOKEN stands in for them."; const root = mkdtempSync(join(tmpdir(), "release-workflows-")); after(() => rmSync(root, { recursive: true, force: true })); @@ -54,6 +55,7 @@ interface Scope { github?: object; vars?: object; needs?: object; + secrets?: object; } function evaluate(expression: string, scope: Scope): unknown { @@ -65,7 +67,7 @@ function evaluate(expression: string, scope: Scope): unknown { .replace(/!=/g, "!=="); assert.doesNotMatch(source, /\*/, `the test cannot evaluate ${expression}`); const contains = (list: string[], item: string): boolean => list.includes(item); - return new Function("steps", "inputs", "github", "vars", "needs", "contains", "fromJSON", `return (${source})`)(scope.steps, scope.inputs, scope.github, scope.vars, scope.needs, contains, JSON.parse); + return new Function("steps", "inputs", "github", "vars", "needs", "secrets", "contains", "fromJSON", `return (${source})`)(scope.steps, scope.inputs, scope.github, scope.vars, scope.needs, scope.secrets, contains, JSON.parse); } function interpolate(template: string, scope: Scope): string { @@ -1166,15 +1168,38 @@ describe("release-npm.yml", () => { assert.deepEqual(check({ REGISTRY: "public" }), [0, ""]); assert.deepEqual(check({ REGISTRY: "private" }), [1, "NPM_ANTELOPE_TOKEN is not configured.\n"]); assert.deepEqual(check({ REGISTRY: "private", NPM_ANTELOPE_TOKEN: "token" }), [0, ""]); - assert.deepEqual(check({ REGISTRY: "public", MODE: "stable" }), [1, "RELEASE_APP_ID is not configured.\n"]); - assert.deepEqual(check({ REGISTRY: "public", MODE: "stable", RELEASE_APP_ID: "1" }), [1, "RELEASE_APP_PRIVATE_KEY is not configured.\n"]); + assert.deepEqual(check({ REGISTRY: "public", MODE: "stable" }), [1, `${NO_CREDENTIALS}\n`]); + assert.deepEqual(check({ REGISTRY: "public", MODE: "stable", RELEASE_APP_ID: "1" }), [1, `${NO_CREDENTIALS}\n`]); assert.deepEqual(check({ REGISTRY: "public", MODE: "pull-request" }), [0, ""]); assert.deepEqual(check({ REGISTRY: "private", MODE: "pull-request" }), [1, "NPM_ANTELOPE_TOKEN is not configured.\n"]); - assert.deepEqual(check({ REGISTRY: "public", MODE: "repin" }), [1, "RELEASE_APP_ID is not configured.\n"]); + assert.deepEqual(check({ REGISTRY: "public", MODE: "repin" }), [1, `${NO_CREDENTIALS}\n`]); assert.deepEqual(check({ REGISTRY: "public", MODE: "repin", RELEASE_APP_ID: "1", RELEASE_APP_PRIVATE_KEY: "key" }), [0, ""]); assert.deepEqual(check({ REGISTRY: "npmjs" }), [1, "registry must be public or private, got 'npmjs'.\n"]); }); + for (const mode of ["stable", "repin"]) { + test(`a ${mode} run writes with the app token when both app secrets are set, else with RELEASE_GITHUB_TOKEN, and fails with neither`, () => { + const mint = /^ {8}if: (.*)$/m.exec(stepOf(text, "Create the release token"))?.[1] ?? ""; + const writers = ["Push the stable ranges", "Write release notes", "Publish stable release"].map((name) => /^ {10}\w+: (\$\{\{ steps\.token\.outputs\.token.*\}\})$/m.exec(stepOf(text, name))?.[1] ?? ""); + const run = (secrets: Record) => { + const result = runStep(text, "Validate release credentials", root, { MODE: mode, REGISTRY: "public", RELEASE_APP_ID: "", RELEASE_APP_PRIVATE_KEY: "", RELEASE_GITHUB_TOKEN: "", NPM_ANTELOPE_TOKEN: "", ...secrets }); + const app = /^app=(.*)$/m.exec(result.outputs)?.[1] ?? ""; + const minted = evaluate(mint, { steps: { credentials: { outputs: { app } } } }) === true; + const steps = { token: { outputs: { token: minted ? "app-token" : "" } } }; + return { status: result.status, stdout: result.stdout, stderr: result.stderr, tokens: [...new Set(writers.map((expression) => interpolate(expression, { steps, secrets: { RELEASE_GITHUB_TOKEN: secrets.RELEASE_GITHUB_TOKEN ?? "" } })))] }; + }; + const app = run({ RELEASE_APP_ID: "1", RELEASE_APP_PRIVATE_KEY: "key", RELEASE_GITHUB_TOKEN: "pat" }); + assert.deepEqual([app.status, app.tokens, app.stdout], [0, ["app-token"], ""]); + const appOnly = run({ RELEASE_APP_ID: "1", RELEASE_APP_PRIVATE_KEY: "key" }); + assert.deepEqual([appOnly.status, appOnly.tokens], [0, ["app-token"]]); + const token = run({ RELEASE_APP_ID: "1", RELEASE_GITHUB_TOKEN: "pat" }); + assert.deepEqual([token.status, token.tokens], [0, ["pat"]]); + assert.match(token.stdout, /^::warning::RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not forwarded/); + const neither = run({}); + assert.deepEqual([neither.status, neither.stderr], [1, `${NO_CREDENTIALS}\n`]); + }); + } + test("a repin run commits the devDependency ranges to the default branch, and refuses a runtime pin or no range", () => { const preview = "0.4.3-next.117.g3645dff"; const manifest = (spec: string) => `${JSON.stringify({ name: "@antelopejs/m", version: "1.8.6", devDependencies: { "@antelopejs/interface-database": spec } }, null, 2)}\n`; @@ -1359,6 +1384,25 @@ describe("release-npm.yml", () => { }); }); +describe("next-sync.yml", () => { + const sync = workflowText("next-sync.yml"); + + test("pushes with the app token when both app secrets are set, else with RELEASE_GITHUB_TOKEN, and fails with neither", () => { + const mint = /^ {8}if: (.*)$/m.exec(stepOf(sync, "Create the push token"))?.[1] ?? ""; + const pusher = /^ {10}TOKEN: (.*)$/m.exec(stepOf(sync, "Merge"))?.[1] ?? ""; + const run = (secrets: Record) => { + const result = runStep(sync, "Pick the push credentials", root, { RELEASE_APP_ID: "", RELEASE_APP_PRIVATE_KEY: "", RELEASE_GITHUB_TOKEN: "", ...secrets }); + const app = /^app=(.*)$/m.exec(result.outputs)?.[1] ?? ""; + const minted = evaluate(mint, { steps: { credentials: { outputs: { app } } } }) === true; + return [result.status, interpolate(pusher, { steps: { token: { outputs: { token: minted ? "app-token" : "" } } }, secrets: { RELEASE_GITHUB_TOKEN: secrets.RELEASE_GITHUB_TOKEN ?? "" } }), result.stdout.split(" ")[0]]; + }; + assert.deepEqual(run({ RELEASE_APP_ID: "1", RELEASE_APP_PRIVATE_KEY: "key", RELEASE_GITHUB_TOKEN: "pat" }), [0, "app-token", ""]); + assert.deepEqual(run({ RELEASE_APP_ID: "1", RELEASE_APP_PRIVATE_KEY: "key" }), [0, "app-token", ""]); + assert.deepEqual(run({ RELEASE_APP_PRIVATE_KEY: "key", RELEASE_GITHUB_TOKEN: "pat" }), [0, "pat", "::warning::RELEASE_APP_ID"]); + assert.deepEqual(run({}), [1, "", "::error::RELEASE_APP_ID"]); + }); +}); + describe("ci-node.yml", () => { const ciNode = workflowText("ci-node.yml"); const jobText = (name: string): string => { From 3707c41a1f315b60968e1af25f0bb35d7052aa10 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:27:57 +0000 Subject: [PATCH 10/12] fix(release): fall back to RELEASE_GITHUB_TOKEN while a caller does not forward the app secrets --- .github/workflows/next-sync.yml | 21 ++++++++++++++++-- .github/workflows/release-npm-private.yml | 3 ++- .github/workflows/release-npm-public.yml | 3 ++- .github/workflows/release-npm.yml | 27 ++++++++++++++--------- AGENTS.md | 2 +- README.md | 26 ++++++++++++---------- 6 files changed, 55 insertions(+), 27 deletions(-) diff --git a/.github/workflows/next-sync.yml b/.github/workflows/next-sync.yml index 5837988..7abebcf 100644 --- a/.github/workflows/next-sync.yml +++ b/.github/workflows/next-sync.yml @@ -9,7 +9,7 @@ on: type: string secrets: RELEASE_GITHUB_TOKEN: - description: Unused, kept so that callers which still pass it are accepted + description: Token the release falls back to while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets required: false RELEASE_APP_ID: description: ID of the GitHub App whose installation token pushes the merge, which the branch's ruleset lets push @@ -46,8 +46,25 @@ jobs: DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} steps: + - name: Pick the push credentials + id: credentials + env: + RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }} + RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + run: | + if [ -n "$RELEASE_APP_ID" ] && [ -n "$RELEASE_APP_PRIVATE_KEY" ]; then + echo "app=true" >> "$GITHUB_OUTPUT" + elif [ -n "$RELEASE_GITHUB_TOKEN" ]; then + echo "::warning::RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not forwarded, so this sync pushes with RELEASE_GITHUB_TOKEN. Run antelopejs-sync to forward them before the token is revoked." + else + echo "::error::RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not configured, and no RELEASE_GITHUB_TOKEN stands in for them." + exit 1 + fi + - name: Create the push token id: token + if: steps.credentials.outputs.app == 'true' uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 with: app-id: ${{ secrets.RELEASE_APP_ID }} @@ -57,7 +74,7 @@ jobs: - name: Merge id: merge env: - TOKEN: ${{ steps.token.outputs.token }} + TOKEN: ${{ steps.token.outputs.token || secrets.RELEASE_GITHUB_TOKEN }} run: | git init -q git remote add origin "https://github.com/${GH_REPO}.git" diff --git a/.github/workflows/release-npm-private.yml b/.github/workflows/release-npm-private.yml index f38a119..2c2155f 100644 --- a/.github/workflows/release-npm-private.yml +++ b/.github/workflows/release-npm-private.yml @@ -28,7 +28,7 @@ on: type: string secrets: RELEASE_GITHUB_TOKEN: - description: Unused. Kept so that a caller that passes it keeps working + description: Token the release falls back to while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets required: false RELEASE_APP_ID: description: ID of the GitHub App whose installation token creates the release commit, tag, and GitHub release @@ -56,6 +56,7 @@ jobs: install-core: ${{ inputs.install-core }} package-directory: ${{ inputs.package-directory }} secrets: + RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }} RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} NPM_ANTELOPE_TOKEN: ${{ secrets.NPM_ANTELOPE_TOKEN }} diff --git a/.github/workflows/release-npm-public.yml b/.github/workflows/release-npm-public.yml index 3aee67b..ab0708f 100644 --- a/.github/workflows/release-npm-public.yml +++ b/.github/workflows/release-npm-public.yml @@ -28,7 +28,7 @@ on: type: string secrets: RELEASE_GITHUB_TOKEN: - description: Unused. Kept so that a caller that passes it keeps working + description: Token the release falls back to while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets required: false RELEASE_APP_ID: description: ID of the GitHub App whose installation token creates the release commit, tag, and GitHub release @@ -54,5 +54,6 @@ jobs: install-core: ${{ inputs.install-core }} package-directory: ${{ inputs.package-directory }} secrets: + RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }} RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 186b9ae..f12872d 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -28,6 +28,9 @@ on: default: . type: string secrets: + RELEASE_GITHUB_TOKEN: + description: Token the release falls back to while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets + required: false RELEASE_APP_ID: description: ID of the GitHub App whose installation token creates the release commit, tag, and GitHub release required: false @@ -81,11 +84,13 @@ jobs: fi - name: Validate release credentials + id: credentials env: MODE: ${{ steps.mode.outputs.mode }} REGISTRY: ${{ inputs.registry }} RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }} RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} NPM_ANTELOPE_TOKEN: ${{ secrets.NPM_ANTELOPE_TOKEN }} run: | case "$REGISTRY" in @@ -102,17 +107,19 @@ jobs: ;; esac if [ "$MODE" = stable ] || [ "$MODE" = repin ]; then - for name in RELEASE_APP_ID RELEASE_APP_PRIVATE_KEY; do - test -n "${!name}" || { - echo "$name is not configured." >&2 - exit 1 - } - done + if [ -n "$RELEASE_APP_ID" ] && [ -n "$RELEASE_APP_PRIVATE_KEY" ]; then + echo "app=true" >> "$GITHUB_OUTPUT" + elif [ -n "$RELEASE_GITHUB_TOKEN" ]; then + echo "::warning::RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not forwarded, so this release writes with RELEASE_GITHUB_TOKEN. Run antelopejs-sync to forward them before the token is revoked." + else + echo "RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not configured, and no RELEASE_GITHUB_TOKEN stands in for them." >&2 + exit 1 + fi fi - name: Create the release token id: token - if: steps.mode.outputs.mode == 'stable' || steps.mode.outputs.mode == 'repin' + if: steps.credentials.outputs.app == 'true' uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 with: app-id: ${{ secrets.RELEASE_APP_ID }} @@ -563,7 +570,7 @@ jobs: if: steps.mode.outputs.mode == 'repin' env: MESSAGE: ${{ steps.ranges.outputs.message }} - GITHUB_TOKEN: ${{ steps.token.outputs.token }} + GITHUB_TOKEN: ${{ steps.token.outputs.token || secrets.RELEASE_GITHUB_TOKEN }} run: | set -euo pipefail git commit --quiet -m "$MESSAGE" @@ -578,7 +585,7 @@ jobs: env: DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} DEPENDENCY_RANGES: ${{ inputs.dependency-ranges }} - GH_TOKEN: ${{ steps.token.outputs.token }} + GH_TOKEN: ${{ steps.token.outputs.token || secrets.RELEASE_GITHUB_TOKEN }} RELEASE_VERSION: ${{ steps.version.outputs.version }} RESUME: ${{ steps.version.outputs.resume }} run: | @@ -820,7 +827,7 @@ jobs: working-directory: ${{ inputs.package-directory }} env: RELEASE_VERSION: ${{ steps.version.outputs.version }} - GITHUB_TOKEN: ${{ steps.token.outputs.token }} + GITHUB_TOKEN: ${{ steps.token.outputs.token || secrets.RELEASE_GITHUB_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_ANTELOPE_TOKEN }} run: | auth=$(printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64 -w0) diff --git a/AGENTS.md b/AGENTS.md index 8f130aa..7a2f260 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ This repository holds the AntelopeJS organization defaults: the community health ## Callers -Every repository calls the shared workflows at the `v2` tag, as in `AntelopeJS/.github/.github/workflows/ci-node.yml@v2`. A change on `main` reaches no caller until the tag moves, and `v2` moves only when Antony says so. The callers are frozen: a change keeps every existing input, default, secret and permission as they are, so each caller keeps working without an edit. One exception predates the rule: a stable or repin release mints its token from `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY`, so every release caller forwards those two secrets, as `antelopejs-sync` writes them, before `v2` moves. `scripts/release-train/frozen-caller.yml` is the release caller that `antelopejs-sync` writes, and `caller.test.ts` checks the release workflows against it. +Every repository calls the shared workflows at the `v2` tag, as in `AntelopeJS/.github/.github/workflows/ci-node.yml@v2`. A change on `main` reaches no caller until the tag moves, and `v2` moves only when Antony says so. The callers are frozen: a change keeps every existing input, default, secret and permission as they are, so each caller keeps working without an edit. Release and next-sync callers forward `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY`, as `antelopejs-sync` writes them. Until every caller is re-synced, a run without them falls back to `RELEASE_GITHUB_TOKEN`, so an older caller keeps working when `v2` moves. The fallback goes away once every caller is re-synced and the token is revoked. `scripts/release-train/frozen-caller.yml` is the release caller that `antelopejs-sync` writes, and `caller.test.ts` checks the release workflows against it. ## Checks diff --git a/README.md b/README.md index 4ed10ab..42f6a9f 100644 --- a/README.md +++ b/README.md @@ -398,13 +398,14 @@ keeps working unchanged. | `package-directory` | `.` | Directory of the package, relative to the repository root. | | `integration-branch` | none | Unused. Only the two wrappers declare it, so that a caller that passes it keeps working. | -Both registries need the `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY` secrets -for a stable or repin run. From them `actions/create-github-app-token` mints a -token of the `antelopejs-release` GitHub App, scoped to the calling repository, -that pushes the release commit and tag and creates the GitHub release. The app -needs `contents: write`, and `pull_requests: read` for the release notes of a -private repository. `RELEASE_GITHUB_TOKEN` is still declared so that a caller -that passes it keeps working, and no step reads it. The `public` registry publishes to npmjs with public access and +A stable or repin run writes with a token of the `antelopejs-release` GitHub +App, which `actions/create-github-app-token` mints from the `RELEASE_APP_ID` +and `RELEASE_APP_PRIVATE_KEY` secrets, scoped to the calling repository and to +`contents: write` and `pull_requests: read` (the release notes read merged pull +requests). It pushes the release commit and tag and creates the GitHub release. +While a caller does not forward both app secrets, the run falls back to +`RELEASE_GITHUB_TOKEN` with a warning, and it fails when neither is set. The +fallback goes away once every caller is re-synced and the token is revoked. The `public` registry publishes to npmjs with public access and provenance. The `private` registry publishes to `https://npm.antelopejs.cloud/` and also needs `NPM_ANTELOPE_TOKEN` for every run. Each validates that the package directory resolves inside the repository and holds a `package.json`, @@ -430,8 +431,9 @@ stable release. `antelopejs-sync` of the first `@antelopejs/tooling-configs` release after 0.9.2 writes this caller. A caller written by an older `antelopejs-sync` -forwards only `RELEASE_GITHUB_TOKEN`, and its stable and repin runs fail once -`v2` moves, so every caller forwards the two app secrets before it does. +forwards only `RELEASE_GITHUB_TOKEN`, and keeps releasing with it through the +fallback. Every caller forwards the two app secrets before the token is +revoked, and the fallback is then removed. - **File.** `.github/workflows/release.yml`. npm trusted publishing names this file, and the release train dispatches it. @@ -453,8 +455,8 @@ forwards only `RELEASE_GITHUB_TOKEN`, and its stable and repin runs fail once - **Secrets.** `RELEASE_GITHUB_TOKEN`, `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY`, plus `NPM_ANTELOPE_TOKEN` for the private workflow, each passed by name. A stable or repin run mints its token from the - two app secrets and fails without them. No step reads - `RELEASE_GITHUB_TOKEN`. + two app secrets, and falls back to `RELEASE_GITHUB_TOKEN` until the token is + revoked. - **Call.** `release-npm-public.yml@v2` or `release-npm-private.yml@v2`, with each dispatch input passed through under the same name. `release-npm.yml@v2` takes the same call with `registry: public` or `registry: private`. @@ -970,7 +972,7 @@ the same conflict would come back. | `branch` | `next` | Branch that receives the default branch. | | `RELEASE_APP_ID` (secret) | | ID of the GitHub App whose token pushes the merge. The branch ruleset must list the app as a bypass actor. | | `RELEASE_APP_PRIVATE_KEY` (secret) | | Private key of that GitHub App. | -| `RELEASE_GITHUB_TOKEN` (secret) | | Optional and unused. Kept so that callers which still pass it are accepted. | +| `RELEASE_GITHUB_TOKEN` (secret) | | Pushes the merge, with a warning, while `RELEASE_APP_ID` or `RELEASE_APP_PRIVATE_KEY` is unset. The sync fails when neither is set. Removed once every caller forwards the app secrets and the token is revoked. | | `NOTION_TOKEN` (secret) | | Optional and unused: no workflow writes to Notion. Kept so that callers which still pass it are accepted. | The calling job must grant `issues: write`: a From 74b94e1f23692781b78692898344d59e7789e4c8 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:29:02 +0000 Subject: [PATCH 11/12] fix(module-locks): end the other dirname options, and forward the app secrets in the README's multi-package caller --- .github/workflows/module-locks-renovate.yml | 2 +- README.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/module-locks-renovate.yml b/.github/workflows/module-locks-renovate.yml index d56d6b8..0761822 100644 --- a/.github/workflows/module-locks-renovate.yml +++ b/.github/workflows/module-locks-renovate.yml @@ -104,7 +104,7 @@ jobs: git rm -rq -- "$committed" echo "Deleted ${committed}: the bump replaces ${version}." fi - done < <(git ls-tree -d --name-only HEAD -- "$(dirname "$lock")/") + done < <(git ls-tree -d --name-only HEAD -- "$(dirname -- "$lock")/") done < "$work/recorded" - name: Commit the locks diff --git a/README.md b/README.md index 42f6a9f..afe5539 100644 --- a/README.md +++ b/README.md @@ -1041,7 +1041,7 @@ releasing a package below `packages/` needs no extra input. This is the job ```yaml jobs: release-packages-dms-automation: - if: github.event_name == 'push' || inputs.package-directory == 'packages/dms-automation' + if: github.event_name != 'workflow_dispatch' || inputs.package-directory == 'packages/dms-automation' uses: AntelopeJS/.github/.github/workflows/release-npm-public.yml@v2 with: release-version: ${{ inputs.release-version }} @@ -1050,6 +1050,8 @@ jobs: package-directory: packages/dms-automation secrets: RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }} + RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} ``` Both workflows install from the nearest directory at or above the package From b82958bcfd44077b893560c3593203aa6b875d85 Mon Sep 17 00:00:00 2001 From: Antony Rizzitelli Date: Sat, 21 Nov 2026 00:31:01 +0000 Subject: [PATCH 12/12] fix(next-sync): name the fallback token in its description and in the push error --- .github/workflows/next-sync.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/next-sync.yml b/.github/workflows/next-sync.yml index 7abebcf..b16d0fb 100644 --- a/.github/workflows/next-sync.yml +++ b/.github/workflows/next-sync.yml @@ -9,7 +9,7 @@ on: type: string secrets: RELEASE_GITHUB_TOKEN: - description: Token the release falls back to while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets + description: Token the sync pushes with while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets required: false RELEASE_APP_ID: description: ID of the GitHub App whose installation token pushes the merge, which the branch's ruleset lets push @@ -104,7 +104,7 @@ jobs: fi [ "$attempt" = 3 ] || sleep 5 done - echo "::error::The merge was not pushed to ${BRANCH} after 3 attempts. Either ${BRANCH} moved each time, or the release GitHub App is not a bypass actor of its ruleset." + echo "::error::The merge was not pushed to ${BRANCH} after 3 attempts. Either ${BRANCH} moved each time, or the release GitHub App, or the owner of RELEASE_GITHUB_TOKEN when the app secrets are unset, is not a bypass actor of its ruleset." exit 1 - name: Open or update the conflict issue