Skip to content

Commit 5fef9e2

Browse files
authored
Merge pull request #97 from sourcefuse/GH-96
chore(ci-cd): trusted publishing using oidc
2 parents fe1b816 + c1988a1 commit 5fef9e2

File tree

3 files changed

+4644
-3662
lines changed

3 files changed

+4644
-3662
lines changed

.github/workflows/release.yaml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
# This Manually Executable Workflow is for NPM Releases
2-
32
name: Release [Manual]
43
on: workflow_dispatch
4+
55
permissions:
66
contents: write
7+
id-token: write # REQUIRED for trusted publishing
8+
79
jobs:
810
Release:
911
runs-on: ubuntu-latest
12+
# Specify environment if you configured one in npm
13+
# environment: production # Uncomment if you set an environment name in npm trusted publisher settings
14+
1015
steps:
1116
- uses: actions/checkout@v3
1217
with:
1318
# fetch-depth is necessary to get all tags
1419
# otherwise lerna can't detect the changes and will end up bumping the versions for all packages
1520
fetch-depth: 0
1621
token: ${{ secrets.RELEASE_COMMIT_GH_PAT }}
22+
1723
- name: Setup Node
18-
uses: actions/setup-node@v3
24+
uses: actions/setup-node@v4 # UPDATED to v4
1925
with:
20-
node-version: '20.x'
26+
node-version: '22'
27+
registry-url: 'https://registry.npmjs.org'
28+
always-auth: false # important for trusted publishing
29+
2130
- name: Configure CI Git User
2231
run: |
2332
git config --global user.name $CONFIG_USERNAME
@@ -27,26 +36,22 @@ jobs:
2736
GITHUB_PAT: ${{ secrets.RELEASE_COMMIT_GH_PAT }}
2837
CONFIG_USERNAME: ${{ vars.RELEASE_COMMIT_USERNAME }}
2938
CONFIG_EMAIL: ${{ vars.RELEASE_COMMIT_EMAIL }}
30-
- name: Authenticate with Registry
31-
run: |
32-
echo "@${NPM_USERNAME}:registry=https://registry.npmjs.org/" > .npmrc
33-
echo "registry=https://registry.npmjs.org/" >> .npmrc
34-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
35-
npm whoami
36-
env:
37-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
38-
NPM_USERNAME: ${{ vars.NPM_USERNAME }}
3939

4040
- name: Install 📌
41-
run: |
42-
npm install
41+
run: npm install
42+
4343
- name: Test 🔧
4444
run: npm run test
45+
46+
# ✅ CHANGED THIS SECTION
4547
- name: Semantic Publish to NPM 🚀
46-
# "HUSKY=0" disables pre-commit-msg check (Needed in order to allow semantic-release perform the release commit)
47-
run: HUSKY=0 npx semantic-release
48+
run: |
49+
npm config set provenance true
50+
HUSKY=0 npx semantic-release
4851
env:
4952
GH_TOKEN: ${{ secrets.RELEASE_COMMIT_GH_PAT }}
50-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
53+
# REMOVED: NPM_TOKEN is not needed with trusted publishing
54+
# The id-token: write permission above handles authentication
55+
5156
- name: Changelog 📝
5257
run: cd src/release_notes && HUSKY=0 node release-notes.js

0 commit comments

Comments
 (0)