Skip to content

ci(publish): NPM_TOKEN fallback for the first publish - #41

Merged
lex00 merged 1 commit into
mainfrom
chore/publish-token-fallback
Jun 19, 2026
Merged

ci(publish): NPM_TOKEN fallback for the first publish#41
lex00 merged 1 commit into
mainfrom
chore/publish-token-fallback

Conversation

@lex00

@lex00 lex00 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #40 — makes the publish CI work for the first release.

Problem

OIDC trusted publishing (what #40 set up) only works once the package already exists on npm and a trusted-publisher record is configured — a chicken-and-egg for the very first publish of github-warden.

Fix (entirely in publish.yml)

The publish job now:

  • Reads an optional NPM_TOKEN repo/org secret into the job env.
  • If present → writes ~/.npmrc itself and publishes with the token.
  • If absent → falls through to OIDC trusted publishing (no secret).

Either way it stays idempotent (skips if the version is already on npm) and uses --provenance. So the first publish needs only an NPM_TOKEN secret; once trusted publishing is configured on npm, drop the secret and subsequent releases authenticate via OIDC with nothing stored.

README gains a Releasing section documenting just release + both auth modes.

What still can't live in the workflow

The npm-side trust record / the NPM_TOKEN secret value are registry/secret config a maintainer sets once (I'm not authenticated to npm here). After that, just release minorv0.2.0 tag → publish.

Verification

  • publish.yml validates as YAML; the publish step passes bash -n.
  • No source changes — CI unaffected.

🤖 Generated with Claude Code

OIDC trusted publishing only works once the package exists + a trusted-
publisher record is configured on npm — a chicken-and-egg for the first
release. The publish job now uses an NPM_TOKEN secret when present
(writing .npmrc itself) and falls through to OIDC when it's absent, so
the first publish works with just a repo secret and later releases need
no secret at all. Documents both modes in a README "Releasing" section.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lex00
lex00 merged commit 195e4d6 into main Jun 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant