Skip to content

Commit 0982295

Browse files
chore(internal): switch npm publishing from token authentication to OIDC
1 parent 05bdf41 commit 0982295

5 files changed

Lines changed: 13 additions & 11 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
permissions:
2020
contents: write
21+
id-token: write
2122

2223
steps:
2324
- uses: actions/checkout@v6
@@ -39,8 +40,6 @@ jobs:
3940
PATHS_RELEASED='[\".\", \"packages/mcp-server\"]'
4041
fi
4142
yarn tsn scripts/publish-packages.ts "{ \"paths_released\": \"$PATHS_RELEASED\" }"
42-
env:
43-
NPM_TOKEN: ${{ secrets.LITHIC_NPM_TOKEN || secrets.NPM_TOKEN }}
4443
4544
- name: Upload MCP Server DXT GitHub release asset
4645
run: |

.github/workflows/release-doctor.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,3 @@ jobs:
1717
- name: Check release environment
1818
run: |
1919
bash ./bin/check-release-environment
20-
env:
21-
NPM_TOKEN: ${{ secrets.LITHIC_NPM_TOKEN || secrets.NPM_TOKEN }}

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 190
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-e88a4837037207e9591d48d534bd61acca57ca6e7c59ec0d4fdcf6e05288cc6d.yml
33
openapi_spec_hash: fd8bbc173d1b6dafd117fb1a3a3d446c
4-
config_hash: 3005e2502301e77754e5e1455584525b
4+
config_hash: 64f05ed5c69d8a76596979dc2c17f0f9

bin/check-release-environment

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
errors=()
44

5-
if [ -z "${NPM_TOKEN}" ]; then
6-
errors+=("The NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets")
7-
fi
8-
95
lenErrors=${#errors[@]}
106

117
if [[ lenErrors -gt 0 ]]; then

bin/publish-npm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
set -eux
44

5-
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
5+
if [[ ${NPM_TOKEN:-} ]]; then
6+
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
7+
elif [[ ! ${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-} ]]; then
8+
echo "ERROR: NPM_TOKEN must be set if not running in a Github Action with id-token permission"
9+
exit 1
10+
fi
611

712
yarn build
813
cd dist
@@ -57,5 +62,9 @@ else
5762
TAG="latest"
5863
fi
5964

65+
# Install OIDC compatible npm version
66+
npm install --prefix ../oidc/ npm@11.6.2
67+
6068
# Publish with the appropriate tag
61-
yarn publish --tag "$TAG"
69+
export npm_config_registry='https://registry.npmjs.org'
70+
../oidc/node_modules/.bin/npm publish --tag "$TAG"

0 commit comments

Comments
 (0)