Skip to content

Commit d6c8cee

Browse files
authored
ci: setup npm trusted publisher (#89)
1 parent d4b354a commit d6c8cee

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

.github/workflows/npm.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Publish NPM Package
22

3+
permissions:
4+
id-token: write
5+
6+
37
on:
48
workflow_dispatch: # Trigger manually through GitHub Actions interface
59

@@ -8,7 +12,7 @@ on:
812
- "v*" # Trigger on version tags (e.g., v1.0.0)
913

1014
env:
11-
NODE_VERSION: lts/hydrogen
15+
NODE_VERSION: lts/jod
1216

1317
jobs:
1418
publish:
@@ -26,10 +30,11 @@ jobs:
2630
node-version: ${{ env.NODE_VERSION }}
2731
registry-url: "https://registry.npmjs.org"
2832

33+
# Upgrade npm for trusted publishing (requires npm >= 11.5.1)
34+
- run: npm install -g npm@latest
35+
2936
- name: Install dependencies
3037
run: yarn install --frozen-lockfile
3138

3239
- name: Publish to npm
3340
run: scripts/publish-lib.sh
34-
env:
35-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

lib/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"name": "@cowprotocol/cms",
33
"version": "*** THE VERSION IS OVERRIDDEN AT PUBLISHING TIME ***",
44
"description": "Cow Protocol CMS",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/cowprotocol/cms.git",
8+
"directory": "lib"
9+
},
510
"main": "dist/lib.js",
611
"types": "dist/lib.d.ts",
712
"source": "src/lib.ts",

scripts/publish-lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ yarn build:lib
2929

3030
# Publish the library
3131
echo -e "\n🚀 Publish the library"
32-
(cd lib && npm publish --access public)
32+
(cd lib && npm publish --access public --provenance)

0 commit comments

Comments
 (0)