Skip to content

Commit d93ceac

Browse files
authored
ci: Update release workflow for npm OIDC authentication (#795)
1 parent de8c71c commit d93ceac

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,18 @@ jobs:
7070
- build-and-test
7171
- create-release-branch
7272
- confirm-public-repo-master-branch
73+
# OIDC permissions for npm trusted publishing
74+
permissions:
75+
contents: write
76+
issues: write
77+
pull-requests: write
78+
id-token: write # Required for OIDC authentication with npm
7379
env:
7480
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
7581
GIT_AUTHOR_NAME: mparticle-automation
7682
GIT_AUTHOR_EMAIL: [email protected]
7783
GIT_COMMITTER_NAME: mparticle-automation
7884
GIT_COMMITTER_EMAIL: [email protected]
79-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
8085

8186
steps:
8287
- name: Checkout public master branch
@@ -100,10 +105,14 @@ jobs:
100105
uses: actions/setup-node@v3
101106
with:
102107
node-version: 14.x
108+
registry-url: 'https://registry.npmjs.org'
103109

104110
- name: Install dependencies
105111
run: npm ci
106112

113+
- name: Ensure npm CLI supports OIDC
114+
run: npm install -g npm@latest
115+
107116
- name: Release --dry-run
108117
if: ${{ github.event.inputs.dryRun == 'true'}}
109118
run: |

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"description": "Media SDK for mParticle",
55
"main": "dist/mparticle-media.common.js",
66
"types": "dist/index.d.ts",
7+
"publishConfig": {
8+
"access": "public",
9+
"provenance": true,
10+
"registry": "https://registry.npmjs.org"
11+
},
712
"repository": "https://github.com/mParticle/mparticle-web-media-sdk",
813
"directories": {
914
"test": "test"

release.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ module.exports = {
3333
changelogFile: 'CHANGELOG.md',
3434
},
3535
],
36-
['@semantic-release/npm'],
36+
[
37+
'@semantic-release/npm',
38+
{
39+
npmPublish: false, // Disable npm publish here; we use exec with OIDC instead
40+
},
41+
],
3742
[
3843
'@semantic-release/exec',
3944
{
4045
prepareCmd: 'sh ./scripts/release.sh',
46+
publishCmd: 'npm publish',
4147
},
4248
],
4349
[

0 commit comments

Comments
 (0)