Skip to content

Commit c4cf2a9

Browse files
committed
chore: migrate away from npm access tokens. Only permit oidc deploys from gated environment
1 parent 61ea23f commit c4cf2a9

2 files changed

Lines changed: 30 additions & 3541 deletions

File tree

.github/workflows/release.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ on:
66
jobs:
77
changesets:
88
runs-on: ubuntu-latest
9+
outputs:
10+
should_publish: ${{ steps.check_release.outputs.should_publish }}
911
steps:
1012
- name: Checkout code
11-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1214
- name: Get tags
1315
run: git fetch --tags origin
1416
- name: Setup Node.js environment
15-
uses: actions/setup-node@v3
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '24'
1620
- name: Install dependencies
17-
run: npm install
21+
run: npm ci
1822
- name: Create Release Pull Request
1923
id: changesets
2024
uses: changesets/action@v1
@@ -24,6 +28,7 @@ jobs:
2428
env:
2529
GITHUB_TOKEN: ${{ secrets.SDK_PUBLISH_TOKEN }}
2630
- name: Create new release
31+
id: check_release
2732
if: steps.changesets.outputs.hasChangesets == 'false'
2833
run: |
2934
npx changeset tag && git push origin --tags
@@ -43,11 +48,29 @@ jobs:
4348
}
4449
' CHANGELOG.md)
4550
gh release create $COMMIT_TAG -t "$COMMIT_TAG" -n "$CHANGELOG"
46-
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
47-
npm publish
51+
echo "should_publish=true" >> "$GITHUB_OUTPUT"
4852
else
4953
echo "No tag attached to HEAD. No new release needed."
54+
echo "should_publish=false" >> "$GITHUB_OUTPUT"
5055
fi
51-
env:
52-
NODE_AUTH_TOKEN: ${{ secrets.PUBLIC_REPO_NPM_PUBLISH }}
5356
57+
publish:
58+
needs: changesets
59+
if: needs.changesets.outputs.should_publish == 'true'
60+
runs-on: ubuntu-latest
61+
environment: production
62+
permissions:
63+
id-token: write
64+
contents: read
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
- name: Setup Node.js environment
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: '24'
72+
registry-url: 'https://registry.npmjs.org'
73+
- name: Install dependencies
74+
run: npm ci
75+
- name: Publish to npm
76+
run: npm publish

0 commit comments

Comments
 (0)