Skip to content

Commit 75f63bb

Browse files
authored
fix(release): use workflow package token (#186)
1 parent 215ce4f commit 75f63bb

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,28 @@ jobs:
5050
)
5151
echo "$version" >> "$GITHUB_OUTPUT"
5252
53+
registry-auth-preflight:
54+
name: Verify GitHub Packages authentication
55+
needs: plan-release
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Setup Node for GitHub Packages
59+
uses: actions/setup-node@v6
60+
with:
61+
node-version: 24.10.0
62+
registry-url: https://npm.pkg.github.com
63+
scope: "@lzehrung"
64+
65+
- name: Authenticate with the workflow token
66+
env:
67+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
run: npm whoami --registry=https://npm.pkg.github.com
69+
5370
build-native-artifacts:
5471
name: Build ${{ matrix.suffix }}
55-
needs: plan-release
72+
needs:
73+
- plan-release
74+
- registry-auth-preflight
5675
runs-on: ${{ matrix.os }}
5776
strategy:
5877
fail-fast: false
@@ -727,7 +746,7 @@ jobs:
727746
728747
- name: Publish only certified tarballs
729748
env:
730-
NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_PUBLISH_TOKEN || secrets.GITHUB_TOKEN }}
749+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
731750
shell: bash
732751
run: |
733752
node ./scripts/certification/publish-release-candidates.mjs \

PUBLISHING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ A structural result proves archive checksum, package identity, target naming, an
9999

100100
Publishing waits for every required package row plus security, semantics, and hermeticity. Missing, failed, stale-revision, wrong-version, expired-exception, size, or checksum evidence stops the job before `npm publish` is invoked.
101101

102-
The workflow uses `PACKAGE_PUBLISH_TOKEN` when configured and otherwise uses the workflow-scoped `GITHUB_TOKEN`. The job has `packages: write`; a custom token is only needed when the repository's workflow token cannot write an existing package.
102+
The workflow uses its repository-scoped `GITHUB_TOKEN` with `packages: write`; it does not prefer long-lived package secrets. A registry authentication preflight runs before native builds so invalid workflow access fails before the certification matrix starts.
103103

104104
## Package Roles
105105

tests/certification-release-workflow.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ function jobBlock(workflow: string, jobName: string): string {
1616
describe("certified release workflows", () => {
1717
it("finishes package certification and publication before standalone previews", () => {
1818
const assemble = jobBlock(releaseWorkflow, "assemble-release-candidates");
19+
const authPreflight = jobBlock(releaseWorkflow, "registry-auth-preflight");
20+
const buildNative = jobBlock(releaseWorkflow, "build-native-artifacts");
1921
const security = jobBlock(releaseWorkflow, "security-production");
2022
const smoke = jobBlock(releaseWorkflow, "package-smoke");
2123
const packageFunnel = jobBlock(releaseWorkflow, "package-funnel");
2224
const report = jobBlock(releaseWorkflow, "certification-report");
2325
const publish = jobBlock(releaseWorkflow, "publish-certified");
2426

27+
expect(authPreflight).toContain("npm whoami --registry=https://npm.pkg.github.com");
28+
expect(authPreflight).toContain("NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}");
29+
expect(buildNative).toContain("- registry-auth-preflight");
2530
expect(assemble).toContain("- build-native-artifacts");
2631
expect(security).toContain("- assemble-release-candidates");
2732
expect(smoke).toContain("- security-production");
@@ -56,7 +61,8 @@ describe("certified release workflows", () => {
5661
expect(releaseWorkflow.split("assemble-release-candidates.mjs")).toHaveLength(2);
5762
expect(releaseWorkflow).not.toContain("npm pack");
5863
expect(publish).toContain("publish-release-candidates.mjs");
59-
expect(publish).toContain("NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_PUBLISH_TOKEN || secrets.GITHUB_TOKEN }}");
64+
expect(publish).toContain("NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}");
65+
expect(publish).not.toContain("PACKAGE_PUBLISH_TOKEN");
6066
expect(publish).not.toContain("CODEGRAPH_PACKAGES_TOKEN_B64");
6167
expect(publish).not.toContain("base64 --decode");
6268
expect(publish).toContain("temp/release-candidates/packages/*.tgz");

0 commit comments

Comments
 (0)