mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
fix(release): publish to npm with the job's OIDC token, not a stored token (#8070)
* test(release): npm publishes with the job's OIDC token, no stored token named * fix(release): publish to npm with the job's OIDC token, not a stored token * test(release): catch a secret named by index or inherited, not only secrets.X
This commit is contained in:
@@ -809,11 +809,12 @@ jobs:
|
||||
' "$RUNNER_TEMP/assets-pages.json" > /dev/null
|
||||
|
||||
# Runs outside the checkout so no project .npmrc applies, and with
|
||||
# --ignore-scripts so no lifecycle script runs next to the npm token.
|
||||
# --ignore-scripts so no lifecycle script runs next to the npm credentials.
|
||||
- name: Publish packages
|
||||
working-directory: ${{ runner.temp }}
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
# Empty, not setup-node's placeholder: npm authenticates with the job's OIDC token only.
|
||||
NODE_AUTH_TOKEN: ""
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
DIST_TAG: ${{ steps.version.outputs.dist_tag }}
|
||||
run: |
|
||||
|
||||
@@ -72,7 +72,7 @@ The publish workflow validates release channel boundaries before publishing:
|
||||
- Merged `release/vX.Y.Z` PRs publish stable releases only.
|
||||
- Every publish job verifies that its checkout matches the immutable event SHA.
|
||||
- Builds, lifecycle scripts and `npm pack` run in a job with a read-only token and no secrets.
|
||||
- The job that holds the npm token runs no code from the release commit. It checks that every packed tarball is a package this workflow publishes, at exactly the release version, then uploads it with lifecycle scripts off.
|
||||
- The job that publishes to npm runs no code from the release commit, and it holds no stored npm token: npm trusted publishing authenticates it with the job's OIDC token. It checks that every packed tarball is a package this workflow publishes, at exactly the release version, then uploads it with lifecycle scripts off.
|
||||
- A version already on npm is skipped only when its contents match the original run’s tarball, including on a retry. Different contents fail the publish.
|
||||
- The Lambda handler zip and arm64 video image are built by the run, and `@hyperframes/aws-lambda` pins those builds. Retries reuse the original immutable run bundle. If the version is already on npm, its verified package must pin those same bytes before any release mutation. A separate immutable run receipt binds the release ID and asset digests; foreign releases and mismatched assets fail instead of being adopted or overwritten. See [publish recovery](/contributing/changelog-process) for retention and recovery limits.
|
||||
|
||||
|
||||
@@ -471,6 +471,12 @@ test("release-commit code runs only in a job without secrets", () => {
|
||||
assert.deepEqual(publish.needs, ["release-source", "pack"]);
|
||||
});
|
||||
|
||||
test("npm publishes with the job's OIDC token only: no stored npm token is named", () => {
|
||||
assert.doesNotMatch(JSON.stringify(config), /\bsecrets\b(?!\.GITHUB_TOKEN\b)/);
|
||||
assert.equal(publish.permissions["id-token"], "write");
|
||||
assert.equal(stepOf(publish, "Publish packages").env.NODE_AUTH_TOKEN, "");
|
||||
});
|
||||
|
||||
test("the publish job runs no code from the release commit", () => {
|
||||
for (const step of publish.steps) {
|
||||
assert.doesNotMatch(step.uses ?? "", /setup-bun|^\.\//, `${step.uses} in the publish job`);
|
||||
@@ -482,10 +488,7 @@ test("the publish job runs no code from the release commit", () => {
|
||||
assert.match(line, /--ignore-scripts/, step.name);
|
||||
}
|
||||
}
|
||||
const job = JSON.stringify(publish);
|
||||
assert.equal(job.split("secrets.NPM_TOKEN").length - 1, 1);
|
||||
const publishPackages = stepOf(publish, "Publish packages");
|
||||
assert.equal(publishPackages.env.NODE_AUTH_TOKEN, "${{ secrets.NPM_TOKEN }}");
|
||||
assert.equal(publishPackages["working-directory"], "${{ runner.temp }}");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user