Skip to content

Commit 54f88a1

Browse files
committed
ci(release): clarify missing npm token blocker
1 parent a746bbd commit 54f88a1

4 files changed

Lines changed: 53 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,19 @@ jobs:
4040

4141
- name: Verify npm publish access
4242
run: |
43-
npm whoami
43+
if [ -z "${NODE_AUTH_TOKEN:-}" ]; then
44+
echo "NPM_TOKEN is not configured for this repository or environment."
45+
echo "Add a GitHub Actions secret named NPM_TOKEN with npm publish access before rerunning."
46+
exit 1
47+
fi
48+
49+
if ! NPM_USER=$(npm whoami 2>&1); then
50+
echo "NPM_TOKEN could not authenticate with npm."
51+
echo "${NPM_USER}"
52+
exit 1
53+
fi
54+
55+
echo "Authenticated to npm as ${NPM_USER}."
4456
4557
if ! npm access list packages @chart-kit --json >/dev/null; then
4658
echo "NPM_TOKEN cannot access the @chart-kit npm scope."

docs/release/beta-checklist.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This checklist tracks CKV2-017 readiness for the H5-approved Developer Preview.
1010
- Package strategy: `react-native-chart-kit` remains the compatibility path; `@chart-kit/react-native` is the modern v2 API for new adopters
1111
- Dist-tag target for Developer Preview: `next`
1212
- Publish manifest: [package-manifest.json](evidence/package-manifest.json) is the source of truth for Developer Preview-publishable packages. It publishes `@chart-kit/core`, `@chart-kit/svg-renderer`, `@chart-kit/react-native`, and then the root compatibility package `react-native-chart-kit`; it pack-checks but does not publish `@chart-kit/skia-renderer` or `@chart-kit/pro`.
13-
- npm access prerequisite: the `NPM_TOKEN` used by GitHub Actions must be able to create and publish public packages under the `@chart-kit` scope. The publish workflow runs `npm whoami` and `npm access list packages @chart-kit --json` before expensive build/test work so missing scope access fails early.
13+
- npm access prerequisite: the `NPM_TOKEN` used by GitHub Actions must exist, authenticate with npm, and be able to create and publish public packages under the `@chart-kit` scope. The publish workflow checks for the secret, runs `npm whoami`, and runs `npm access list packages @chart-kit --json` before expensive build/test work so missing auth or scope access fails early.
1414

1515
## Required Checks
1616

scripts/check-release-gates.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const requiredFiles = [
3939
"docs/release/evidence/package-manifest.json",
4040
"docs/release/evidence/skia-renderer-evidence.json",
4141
"docs/release/evidence/skia-renderer-matrix.json",
42+
".github/workflows/publish.yml",
4243
".github/workflows/native-release.yml",
4344
"scripts/generate-native-qa-checklists.mjs",
4445
"scripts/record-native-workflow-evidence.mjs",
@@ -507,6 +508,31 @@ addCheck({
507508
status: nativeWorkflowArtifactChecks.length === 0 ? "pass" : "fail"
508509
});
509510

511+
const publishWorkflowSource = await readRepoFile(".github/workflows/publish.yml");
512+
const publishWorkflowSafetyChecks = [
513+
"secrets.NPM_TOKEN",
514+
"NODE_AUTH_TOKEN",
515+
"NPM_TOKEN is not configured",
516+
"npm whoami",
517+
"npm access list packages @chart-kit --json",
518+
"scripts/list-release-packages.mjs --publishable",
519+
"npm publish \"${PUBLISH_TARGET}\" --ignore-scripts --access public --provenance --tag"
520+
].filter((needle) => !publishWorkflowSource.includes(needle));
521+
522+
addCheck({
523+
detail:
524+
publishWorkflowSafetyChecks.length > 0
525+
? `Missing publish workflow safety config: ${publishWorkflowSafetyChecks.join(
526+
", "
527+
)}`
528+
: "",
529+
evidence: ".github/workflows/publish.yml",
530+
id: "workflow:publish-safety",
531+
message:
532+
"Publish workflow validates npm auth and uses the release package manifest",
533+
status: publishWorkflowSafetyChecks.length === 0 ? "pass" : "fail"
534+
});
535+
510536
const candidateJavaHomes = [
511537
process.env.JAVA_HOME,
512538
"/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home",

scripts/check-release-gates.test.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,17 @@ describe("release gate checker", () => {
199199
status: "pass"
200200
});
201201
});
202+
203+
it("checks npm publish workflow auth and manifest safety", () => {
204+
const report = runGateReportJson();
205+
206+
expect(
207+
report.checks.find((check) => check.id === "workflow:publish-safety")
208+
).toMatchObject({
209+
evidence: ".github/workflows/publish.yml",
210+
message:
211+
"Publish workflow validates npm auth and uses the release package manifest",
212+
status: "pass"
213+
});
214+
});
202215
});

0 commit comments

Comments
 (0)