Skip to content

Commit 16524bc

Browse files
committed
Merge pull request #3439 from cytoscape/copilot/refactor-github-actions-release-workflow
Refactor: extract npm publish into a dedicated reusable workflow with trusted publishing
1 parent dbb4b61 commit 16524bc

3 files changed

Lines changed: 40 additions & 9 deletions

File tree

.github/workflows/feature-release.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ jobs:
6161
with:
6262
name: npm-release--failure-report
6363
path: /home/runner/.npm/_logs/
64-
- name: Publish Package To npmjs
65-
run: npm publish
66-
env:
67-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6864
- name: Publish Package to GitHub Releases
6965
run: |
7066
curl -L \
@@ -92,4 +88,11 @@ jobs:
9288
-H "Accept: application/vnd.github.v3+json" \
9389
"https://api.github.com/repos/cytoscape/cytoscape.js-blog/issues" \
9490
-d "{\"title\":\"$TITLE\",\"body\":\"$BODY\"}"
95-
91+
92+
npm_publish:
93+
needs: feature-release
94+
permissions:
95+
contents: read
96+
id-token: write
97+
uses: ./.github/workflows/npm-publish.yml
98+

.github/workflows/npm-publish.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: npm publish
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
id-token: write
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
ref: master
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 22
20+
cache: 'npm'
21+
registry-url: 'https://registry.npmjs.org'
22+
- name: Install dependencies
23+
run: npm install
24+
- name: Publish Package To npmjs
25+
run: npm publish --provenance

.github/workflows/patch-release.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ jobs:
9595
with:
9696
name: npm-release--failure-report
9797
path: /home/runner/.npm/_logs/
98-
- name: Publish Package To npmjs
99-
run: npm publish
100-
env:
101-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10298
- name: Publish Package to GitHub Releases
10399
run: |
104100
curl -L \
@@ -113,3 +109,10 @@ jobs:
113109
uses: JamesIves/github-pages-deploy-action@v4
114110
with:
115111
folder: documentation
112+
113+
npm_publish:
114+
needs: patch-release
115+
permissions:
116+
contents: read
117+
id-token: write
118+
uses: ./.github/workflows/npm-publish.yml

0 commit comments

Comments
 (0)