Skip to content

Commit 41c4e76

Browse files
committed
fix(ci-cd): trusted publisher
changed the provenance GH-269
1 parent 7b642e8 commit 41c4e76

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

.github/workflows/release.yaml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +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
7+
id-token: write # REQUIRED for trusted publishing
8+
89
jobs:
910
Release:
1011
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+
1115
steps:
1216
- uses: actions/checkout@v3
1317
with:
1418
# fetch-depth is necessary to get all tags
1519
# otherwise lerna can't detect the changes and will end up bumping the versions for all packages
1620
fetch-depth: 0
1721
token: ${{ secrets.RELEASE_COMMIT_GH_PAT }}
22+
1823
- name: Setup Node
19-
uses: actions/setup-node@v3
24+
uses: actions/setup-node@v4 # ✅ UPDATED to v4
2025
with:
2126
node-version: '22'
27+
registry-url: 'https://registry.npmjs.org'
28+
always-auth: false # ✅ ADD THIS - important for trusted publishing
29+
2230
- name: Configure CI Git User
2331
run: |
2432
git config --global user.name $CONFIG_USERNAME
@@ -28,29 +36,27 @@ jobs:
2836
GITHUB_PAT: ${{ secrets.RELEASE_COMMIT_GH_PAT }}
2937
CONFIG_USERNAME: ${{ vars.RELEASE_COMMIT_USERNAME }}
3038
CONFIG_EMAIL: ${{ vars.RELEASE_COMMIT_EMAIL }}
31-
# - name: Authenticate with Registry
32-
# run: |
33-
# echo "@${NPM_USERNAME}:registry=https://registry.npmjs.org/" > .npmrc
34-
# echo "registry=https://registry.npmjs.org/" >> .npmrc
35-
# echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
36-
# npm whoami
37-
# env:
38-
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
39-
# NPM_USERNAME: ${{ vars.NPM_USERNAME }}
4039

4140
- name: Install 📌
42-
run: |
43-
npm install
41+
run: npm install
42+
4443
- name: Test 🔧
4544
run: npm run test
45+
46+
- name: Debug npm config
47+
run: |
48+
npm config list
49+
echo "Registry link ---: $(npm config get registry)" # remove this later
50+
51+
# ✅ CHANGED THIS SECTION
4652
- name: Semantic Publish to NPM 🚀
47-
# "HUSKY=0" disables pre-commit-msg check (Needed in order to allow semantic-release perform the release commit)
4853
run: |
4954
npm config set provenance true
5055
HUSKY=0 npx semantic-release --debug
5156
env:
5257
GH_TOKEN: ${{ secrets.RELEASE_COMMIT_GH_PAT }}
53-
# npm token not needed got trusted publishing
54-
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
58+
# ✅ REMOVED: NPM_TOKEN is not needed with trusted publishing
59+
# The id-token: write permission above handles authentication
60+
5561
- name: Changelog 📝
5662
run: cd src/release_notes && HUSKY=0 node release-notes.js

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,14 @@
261261
}
262262
],
263263
"@semantic-release/release-notes-generator",
264+
[
264265
"@semantic-release/npm",
266+
{
267+
"npmPublish": true,
268+
"pkgRoot": ".",
269+
"tarballDir": "dist"
270+
}
271+
],
265272
[
266273
"@semantic-release/git",
267274
{
@@ -274,6 +281,6 @@
274281
],
275282
"@semantic-release/github"
276283
],
277-
"repositoryUrl": "git@github.com:sourcefuse/loopback4-authentication.git"
284+
"repositoryUrl": "https://github.com/sourcefuse/loopback4-authentication.git"
278285
}
279286
}

0 commit comments

Comments
 (0)