Skip to content

Commit 4b7c20a

Browse files
committed
Update to use Node OIDC Token
This uses the OIDC GitHub token for publishing to the NPM Registry See https://docs.npmjs.com/trusted-publishers#step-2-configure-your-cicd-workflow
1 parent 4512fb3 commit 4b7c20a

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
release-version:
77
description: Enter version to release (e.g., 1.0.1).
88
required: false
9+
permissions:
10+
# Required for OIDC. See https://docs.npmjs.com/trusted-publishers#step-2-configure-your-cicd-workflow
11+
id-token: write
12+
contents: write
913
jobs:
1014
perform:
1115
if: github.event_name == 'workflow_dispatch' && github.repository_owner == 'spring-io'
@@ -14,13 +18,13 @@ jobs:
1418
- name: Checkout
1519
uses: actions/checkout@v4
1620
- name: Install Node.js
17-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
1822
with:
1923
node-version: '16'
24+
registry-url: 'https://registry.npmjs.org'
2025
cache: 'npm'
2126
- name: Set up release environment
2227
run: |
2328
echo RELEASE_VERSION=${{ github.event.inputs.release-version }} >> $GITHUB_ENV
24-
echo RELEASE_NPM_TOKEN=${{ secrets.NPM_TOKEN }} >> $GITHUB_ENV
2529
- name: Build, tag, and publish npm package
2630
run: ./npm/release.sh

npm/release.sh

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
if [ ! -v RELEASE_USER ]; then
66
export RELEASE_USER=$GITHUB_ACTOR
77
fi
8-
#if [ ! -v RELEASE_NPM_TOKEN ]; then
9-
# declare -n RELEASE_NPM_TOKEN="RELEASE_NPM_TOKEN_$RELEASE_USER"
10-
#fi
11-
if [ -z "$RELEASE_NPM_TOKEN" ]; then
12-
echo No npm token specified for publishing to npmjs.com. Stopping release.
13-
exit 1
14-
fi
158
export RELEASE_BRANCH=${GITHUB_REF_NAME:-main}
169
RELEASE_GIT_NAME=$(curl -s https://api.github.com/users/$RELEASE_USER | jq -r .name)
1710
RELEASE_GIT_EMAIL=$RELEASE_USER@users.noreply.github.com
@@ -34,9 +27,6 @@ fi
3427
git config --local user.name "$RELEASE_GIT_NAME"
3528
git config --local user.email "$RELEASE_GIT_EMAIL"
3629

37-
# configure npm client for publishing
38-
echo -e "//registry.npmjs.org/:_authToken=$RELEASE_NPM_TOKEN" > $HOME/.npmrc
39-
4030
# release!
4131
(
4232
set -e
@@ -54,9 +44,6 @@ echo -e "//registry.npmjs.org/:_authToken=$RELEASE_NPM_TOKEN" > $HOME/.npmrc
5444

5545
exit_code=$?
5646

57-
# nuke npm settings
58-
rm -f $HOME/.npmrc
59-
6047
# check for any uncommitted files
6148
git status -s -b
6249

0 commit comments

Comments
 (0)