@@ -99,34 +99,33 @@ jobs:
9999
100100 - name : Configure npm authentication for semantic-release
101101 run : |
102- # actions/setup-node creates .npmrc in a temp location
102+ # actions/setup-node creates .npmrc in a temp location via NPM_CONFIG_USERCONFIG
103103 # We need to ensure semantic-release can find it
104104 if [ -f "$NPM_CONFIG_USERCONFIG" ]; then
105- echo "=== Found npmrc at $NPM_CONFIG_USERCONFIG ==="
106- cat "$NPM_CONFIG_USERCONFIG"
107- # Copy to home directory for semantic-release
105+ echo "Found npmrc at $NPM_CONFIG_USERCONFIG"
106+ # Copy to home directory for semantic-release to read
108107 mkdir -p ~/.npm
109108 cp "$NPM_CONFIG_USERCONFIG" ~/.npmrc
110109 echo "Copied .npmrc to ~/.npmrc"
111- else
112- echo "Warning: NPM_CONFIG_USERCONFIG not found at $NPM_CONFIG_USERCONFIG"
113- fi
114-
115- # Extract token from .npmrc and set as NPM_TOKEN for semantic-release
116- if [ -f ~/.npmrc ]; then
117- # Extract the token from the .npmrc file
118- TOKEN=$(grep -oP '(?<=//registry\.npmjs\.org/:_authToken=).*' ~/.npmrc || echo "")
110+
111+ # Also extract token for NPM_TOKEN env var (semantic-release npm plugin requires it)
112+ # We mask the token value in logs for security
113+ TOKEN=$(grep -oP '(?<=//registry\.npmjs\.org/:_authToken=).*' ~/.npmrc 2>/dev/null || echo "")
119114 if [ -n "$TOKEN" ]; then
115+ echo "NPM_TOKEN=***" >> $GITHUB_ENV
116+ echo "::add-mask::$TOKEN"
120117 echo "NPM_TOKEN=$TOKEN" >> $GITHUB_ENV
121- echo "NPM_TOKEN extracted from .npmrc and set "
118+ echo "NPM_TOKEN configured (masked in logs) "
122119 else
123120 echo "Warning: Could not extract token from .npmrc"
124121 fi
122+ else
123+ echo "Warning: NPM_CONFIG_USERCONFIG not found at $NPM_CONFIG_USERCONFIG"
125124 fi
126125
127- # Test npm auth
128- echo "=== Testing npm authentication === "
129- npm whoami --registry=https://registry.npmjs.org || echo "npm whoami failed"
126+ # Test npm auth (without exposing token)
127+ echo "Testing npm authentication... "
128+ npm whoami --registry=https://registry.npmjs.org >/dev/null 2>&1 && echo "✓ npm authentication successful" || echo "✗ npm authentication failed"
130129
131130 - name : Release
132131 env :
0 commit comments