Skip to content

fix: pnpm publish auth — write .npmrc explicitly#45

Merged
27Bslash6 merged 2 commits into
mainfrom
fix/pnpm-publish-auth
Apr 28, 2026
Merged

fix: pnpm publish auth — write .npmrc explicitly#45
27Bslash6 merged 2 commits into
mainfrom
fix/pnpm-publish-auth

Conversation

@27Bslash6
Copy link
Copy Markdown
Contributor

@27Bslash6 27Bslash6 commented Apr 26, 2026

Problem

Release workflow failed with ENEEDAUTHpnpm publish doesn't reliably pick up the ${NODE_AUTH_TOKEN} template that setup-node writes to .npmrc.

Fix

Write //registry.npmjs.org/:_authToken directly to ~/.npmrc before pnpm publish. This ensures pnpm has explicit auth regardless of .npmrc resolution order.

Context

This blocked the v0.1.1 release (run 24957354685). After merge, re-trigger by running the Release workflow manually or pushing a new fix: commit.

Summary by CodeRabbit

  • Chores
    • Added an explicit npm authentication step in the automated release workflow to write the registry auth token, strengthening package publish authentication and reliability.

setup-node's .npmrc template uses ${NODE_AUTH_TOKEN} which npm
expands but pnpm doesn't pick up reliably. Write the auth token
to ~/.npmrc directly before pnpm publish.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 26ab5cf2-cdbf-49c6-85d8-5e62ee32a2a5

📥 Commits

Reviewing files that changed from the base of the PR and between 11b299a and 4e98703.

📒 Files selected for processing (1)
  • .github/workflows/release-please.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/release-please.yml

📝 Walkthrough

Walkthrough

The release workflow now writes the npm registry auth token into ~/.npmrc (explicit npm authentication) prior to the existing publish step.

Changes

Cohort / File(s) Summary
Workflow: npm auth step
.github/workflows/release-please.yml
Added a step that writes secrets.NPM_TOKEN into ~/.npmrc after tests and before the existing pnpm publish step (publish still provides NODE_AUTH_TOKEN via environment).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 I wrote a tiny token in a cozy ~/.npmrc,
So packages hop out safe and sound,
A soft provenance trail beneath the stars,
Releases bound and nicely crowned. 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: pnpm publish auth — write .npmrc explicitly' accurately describes the main change: fixing pnpm publish authentication by explicitly writing the .npmrc file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
.github/workflows/release-please.yml (2)

92-92: Avoid duplicate provenance configuration.

Line 92 duplicates the --provenance flag already present in the publish command (Line 89). Keep one source of truth to reduce drift.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/release-please.yml at line 92, The workflow currently sets
NPM_CONFIG_PROVENANCE: true which duplicates the --provenance flag already
passed to the npm publish command; remove the redundant environment variable
(NPM_CONFIG_PROVENANCE) so provenance is controlled only via the publish command
flag, leaving the existing --provenance usage intact to avoid configuration
drift.

83-83: Harden .npmrc file permissions when writing token.

On Line 83, consider creating the file with restrictive permissions (0600) before writing the token.

Suggested change
-      - name: Configure npm auth
-        run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
+      - name: Configure npm auth
+        run: |
+          umask 077
+          printf '%s\n' "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
         env:
           NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/release-please.yml at line 83, The step that writes the
NPM token currently uses the command string 'echo
"//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc' which leaves default
file perms; change it to create the file with restrictive 0600 permissions
before/when writing the token (for example, set umask 077 for the write or
create then chmod 600 the file). Update the workflow run command that contains
the echo/redirect so it either prefixes with 'umask 077 &&' or writes then runs
'chmod 600 ~/.npmrc' to ensure ~/.npmrc is only readable/writable by the owner.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/release-please.yml:
- Line 92: The workflow currently sets NPM_CONFIG_PROVENANCE: true which
duplicates the --provenance flag already passed to the npm publish command;
remove the redundant environment variable (NPM_CONFIG_PROVENANCE) so provenance
is controlled only via the publish command flag, leaving the existing
--provenance usage intact to avoid configuration drift.
- Line 83: The step that writes the NPM token currently uses the command string
'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc' which leaves
default file perms; change it to create the file with restrictive 0600
permissions before/when writing the token (for example, set umask 077 for the
write or create then chmod 600 the file). Update the workflow run command that
contains the echo/redirect so it either prefixes with 'umask 077 &&' or writes
then runs 'chmod 600 ~/.npmrc' to ensure ~/.npmrc is only readable/writable by
the owner.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3027ecac-ee41-4e37-a629-0878903218a1

📥 Commits

Reviewing files that changed from the base of the PR and between ba96af5 and 11b299a.

📒 Files selected for processing (1)
  • .github/workflows/release-please.yml

--provenance flag on pnpm publish already controls this.
@27Bslash6 27Bslash6 merged commit e2c7105 into main Apr 28, 2026
17 checks passed
@27Bslash6 27Bslash6 deleted the fix/pnpm-publish-auth branch April 28, 2026 21:28
27Bslash6 added a commit that referenced this pull request May 17, 2026
…2 release (#52)

## Summary

Two real documentation fixes that double as the trigger commit for the
0.1.2 recovery release.

### `packages/cachekit/README.md`

- `Requirements: Node.js 18+` was stale. PR #47 bumped `engines.node` to
`>=22.0.0` across all packages. README now matches: `Node.js 22+`.
- Added a short version-history note explaining the `0.1.0 → 0.1.2` jump
on npm so consumers don't think 0.1.1 is missing or yanked.

### `packages/cachekit-core-ts/README.md` (new)

Every npm-published package should have a README. This one didn't. Added
a minimal one covering:

- What the package is and that consumers shouldn't install it directly
- The 5 prebuilt platform packages and how `optionalDependencies`
selects one
- A summary of the public N-API surface
- The same 0.1.0 → 0.1.2 version note

## Why this is the bootstrap commit for 0.1.2

The commit touches both `packages/cachekit/` and
`packages/cachekit-core-ts/` paths so release-please picks both packages
up for a coordinated release. The `Release-As: 0.1.2` trailer skips
0.1.1 (which exists as a git tag but never reached npm) and forces
release-please to propose 0.1.2 directly.

Type is `docs:` because that's what the changes honestly are — no code
behavior changes. The `Release-As:` trailer is what triggers the
release, not the type.

## What happens after this merges

1. release-please.yml fires on push to main
2. release-please scans commits since the last published manifest, sees
the `Release-As: 0.1.2` trailer and the path touches → opens a release
PR titled `chore: release main` proposing 0.1.2 for both packages
3. Merging that release PR cuts tags `cachekit-v0.1.2` and
`cachekit-core-ts-v0.1.2`
4. `release-please.yml publish-cachekit` runs (auth fix from PR #45 is
in place) → publishes `@cachekit-io/cachekit@0.1.2`
5. The core-ts tag triggers `build-native.yml` → publishes
`@cachekit-io/cachekit-core-ts@0.1.2` + creates all 5 platform packages
on npm (napi flag fix from PR #51 is in place)

After step 5, all 7 packages exist on npm — at which point you can:
6. Configure trusted publishers on npmjs.com for each
7. Take PR #50 out of draft and merge it
8. Delete the `NPM_TOKEN` repo secret after the next OIDC-based release
confirms the loop

## Fallback if release-please ignores `Release-As:` on a `docs:` commit

If release-please's defaults don't pick up `Release-As:` from a
non-releasing commit type, the fallback is to:

- Bump both `package.json` files to 0.1.2 directly
- Update `.release-please-manifest.json` to 0.1.2 for both packages
- Manually create and push the tags

I'd open that as a follow-up PR if needed — keeping the doc-fix and the
release-trigger separate.

## Test plan

- [x] Local validation via prek (no hooks affected by markdown-only
changes)
- [ ] CI green on this PR
- [ ] After merge: confirm release-please opens a 0.1.2 PR within a few
minutes
- [ ] Merge the release PR and watch both publish workflows go green

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Added comprehensive documentation for the native binding package,
including installation guidance and platform support details
  * Updated minimum Node.js version requirement to 22+
  * Clarified version and release information

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/cachekit-io/cachekit-ts/pull/52?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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