Skip to content

fix: write npmrc for npm pub#17

Merged
shavonn merged 1 commit into
mainfrom
fix/add-npmrc-npm-pub
Apr 1, 2026
Merged

fix: write npmrc for npm pub#17
shavonn merged 1 commit into
mainfrom
fix/add-npmrc-npm-pub

Conversation

@shavonn
Copy link
Copy Markdown
Contributor

@shavonn shavonn commented Apr 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 1, 2026 18:09
@shavonn shavonn merged commit bdf21c0 into main Apr 1, 2026
@shavonn shavonn deleted the fix/add-npmrc-npm-pub branch April 1, 2026 18:10
@github-actions github-actions Bot mentioned this pull request Apr 1, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates npm publish credential handling by correcting the .npmrc auth line format when using npm-registry values with trailing slashes.

Changes:

  • Strip a trailing / from INPUT_NPM_REGISTRY when deriving the registry host.
  • Write the auth token entry using the expected //host/:_authToken=... format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

local registry="${INPUT_NPM_REGISTRY:-https://registry.npmjs.org}"
local registry_host
registry_host=$(echo "$registry" | sed 's|https:||')
registry_host=$(echo "$registry" | sed 's|https:||' | sed 's|/$||')
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

registry_host normalization only strips the https: scheme. If a user supplies an http:// registry URL (or another scheme), the generated auth line in .npmrc will be malformed. Consider stripping both http: and https: (e.g., by matching ^https?://), or using a more robust URL normalization approach so npm-registry accepts any valid http(s) URL.

Suggested change
registry_host=$(echo "$registry" | sed 's|https:||' | sed 's|/$||')
registry_host=$(echo "$registry" | sed -E 's|^https?://|//|' | sed 's|/$||')

Copilot uses AI. Check for mistakes.
Comment on lines +79 to 82
echo "${registry_host}/:_authToken=${INPUT_NPM_TOKEN}" > .npmrc
echo "registry=${registry}" >> .npmrc

npm publish
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

This writes the auth token to a .npmrc in the workspace. With set -e, if npm publish fails the script will exit before cleanup, potentially leaving the token on disk for later steps/artifacts. Consider writing to a temp userconfig (e.g., via NPM_CONFIG_USERCONFIG) and/or installing a trap to remove the file on EXIT/ERR so the token is always cleaned up.

Copilot uses AI. Check for mistakes.
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.

2 participants