Skip to content

Commit 61f2e7e

Browse files
author
gitlayzer
committed
ci: add npm trusted publishing to release workflow
1 parent 491311b commit 61f2e7e

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
permissions:
99
contents: write
1010
packages: write
11+
id-token: write
1112

1213
jobs:
1314
goreleaser:
@@ -44,7 +45,7 @@ jobs:
4445
uses: goreleaser/goreleaser-action@v6
4546
with:
4647
distribution: goreleaser
47-
version: latest
48+
version: '~> v2'
4849
args: release --clean
4950
env:
5051
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -93,3 +94,37 @@ jobs:
9394
VERSION=${{ steps.vars.outputs.version }}
9495
cache-from: type=gha
9596
cache-to: type=gha,mode=max
97+
98+
npm-publish:
99+
runs-on: ubuntu-latest
100+
needs:
101+
- goreleaser
102+
- docker
103+
permissions:
104+
contents: read
105+
id-token: write
106+
steps:
107+
- name: Checkout
108+
uses: actions/checkout@v4
109+
with:
110+
fetch-depth: 0
111+
112+
- name: Set up Node.js
113+
uses: actions/setup-node@v4
114+
with:
115+
node-version: '24'
116+
registry-url: 'https://registry.npmjs.org'
117+
118+
- name: Verify npm trusted publishing prerequisites
119+
run: |
120+
node --version
121+
npm --version
122+
node --check scripts/build-npm-packages.mjs
123+
124+
- name: Publish npm packages
125+
env:
126+
NPM_VERSION: ${{ github.ref_name }}
127+
NPM_RELEASE_TAG: ${{ github.ref_name }}
128+
run: |
129+
export NPM_VERSION="${NPM_VERSION#v}"
130+
make npm-publish

0 commit comments

Comments
 (0)