Skip to content

Commit da51f94

Browse files
Sakchai-RefinitivSakchai.Homhual
andauthored
ci: implement trusted publishing (#1291)
* chore: update npm to latest version in main branch check workflow * chore: update npm engine version to >=11.5.1 in package.json files * chore: add permissions for OIDC and npm.js Trusted Publishing in production and pre release workflow * chore: move npm update step to setup action for consistency * chore: remove NODE_AUTH_TOKEN from NPM publish steps in workflows * chore: update SonarCloud scan action to version 6 --------- Co-authored-by: Sakchai.Homhual <[email protected]>
1 parent 589c112 commit da51f94

File tree

10 files changed

+60
-249
lines changed

10 files changed

+60
-249
lines changed

.github/actions/setup/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ runs:
1010
node-version: 20.x
1111
cache: 'npm'
1212

13+
- name: Update npm to 11 # Trusted Publishing requires npm >= 11.5.1
14+
run: npm install -g npm@11
15+
shell: bash
16+
1317
- name: Setup caching dependencies
1418
uses: actions/cache@v4
1519
id: cache-node_modules

.github/workflows/dev_release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
jobs:
77
publish:
88
environment: development
9+
permissions:
10+
id-token: write # Required for OIDC and npm.js Trusted Publishing
11+
contents: write
912
runs-on: ubuntu-latest
1013
steps:
1114
- name: Check out repository code
@@ -21,5 +24,3 @@ jobs:
2124

2225
- name: Publish to NPM
2326
run: npx lerna publish 0.0.0-dev.${{ github.run_id }}.${{ github.run_attempt }} --dist-tag dev --force-publish --exact --include-merged-tags --no-private --no-changelog --no-git-tag-version --no-push --yes
24-
env:
25-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/pre_release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ jobs:
5757
name: Publish
5858
needs: test
5959
environment: development
60+
permissions:
61+
id-token: write # Required for OIDC and npm.js Trusted Publishing
62+
contents: write
6063
runs-on: ubuntu-latest
6164
steps:
6265
- name: Check out repository code
@@ -80,18 +83,14 @@ jobs:
8083
run: npx lerna publish ${{ inputs.version }} --preid next --dist-tag next --force-publish --include-merged-tags --no-private --no-changelog --yes
8184
env:
8285
GH_TOKEN: ${{ secrets.GH_TOKEN }}
83-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8486

8587
- name: Publish to NPM (modified packages)
8688
if: ${{ inputs.version != 'premajor' }}
8789
run: npx lerna publish ${{ inputs.version }} --preid next --dist-tag next --include-merged-tags --no-private --no-changelog --yes
8890
env:
8991
GH_TOKEN: ${{ secrets.GH_TOKEN }}
90-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
9192

9293
- name: Deprecate Solar Theme on npm
9394
run: |
9495
DEPRECATION_MESSAGE=$(npm info @refinitiv-ui/solar-theme deprecated)
9596
if [[ -z $DEPRECATION_MESSAGE ]]; then npm deprecate @refinitiv-ui/solar-theme "Solar theme is deprecated. Consider migrating to @refinitiv-ui/halo-theme instead."; fi
96-
env:
97-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/prod_release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ jobs:
5757
environment:
5858
name: production
5959
url: https://ui.refinitiv.com
60+
permissions:
61+
id-token: write # Required for OIDC and npm.js Trusted Publishing
62+
contents: write
6063
runs-on: ubuntu-latest
6164
steps:
6265
- name: Check out repository code
@@ -93,15 +96,11 @@ jobs:
9396

9497
- name: Publish to NPM
9598
run: npx lerna publish from-git --yes
96-
env:
97-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
9899

99100
- name: Deprecate Solar Theme on npm
100101
run: |
101102
DEPRECATION_MESSAGE=$(npm info @refinitiv-ui/solar-theme deprecated)
102103
if [[ -z $DEPRECATION_MESSAGE ]]; then npm deprecate @refinitiv-ui/solar-theme "Solar theme is deprecated. Consider migrating to @refinitiv-ui/halo-theme instead."; fi
103-
env:
104-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
105104
106105
- name: Publish Docs
107106
run: curl -X POST "https://api.cloudflare.com/client/v4/pages/webhooks/deploy_hooks/${{ secrets.CF_DEPLOY_HOOKS_ID_V7 }}"

.github/workflows/sonarcloud_scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
uses: ./.github/actions/setup
3535

3636
- name: SonarCloud Scan
37-
uses: SonarSource/sonarqube-scan-action@v5
37+
uses: SonarSource/sonarqube-scan-action@v6
3838
env:
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
4040
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

documents/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"description": "Element Framework Documentation",
77
"engines": {
88
"node": ">=20.0.0",
9-
"npm": ">=10.0.0"
9+
"npm": ">=11.5.1"
1010
},
1111
"scripts": {
1212
"lint": "eslint .",

0 commit comments

Comments
 (0)