Skip to content

Commit a9ffc2f

Browse files
committed
Update release workflow to support npm trusted publshing
1 parent 5cb75b2 commit a9ffc2f

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -126,29 +126,10 @@ jobs:
126126
deploy_npm:
127127
name: Deploy npm
128128
runs-on: ubuntu-latest
129-
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/embedded-host-node'"
129+
if: "github.ref_type == 'tag' && github.event.repository.fork == false"
130130
needs: [static_analysis, tests, sass_spec]
131-
132-
steps:
133-
- uses: actions/checkout@v5
134-
- uses: actions/setup-node@v6
135-
with:
136-
node-version: 'lts/*'
137-
check-latest: true
138-
registry-url: 'https://registry.npmjs.org'
139-
- run: npm install
140-
141-
- name: "Check we're not using a -dev version of the embedded protocol"
142-
run: jq -r '.["protocol-version"]' package.json | grep -qv -- '-dev$'
143-
- name: "Check we're not using a -dev version of the embedded compiler"
144-
run: jq -r '.["compiler-version"]' package.json | grep -qv -- '-dev$'
145-
146-
- name: Publish optional dependencies
147-
env:
148-
NODE_AUTH_TOKEN: '${{ secrets.NPM_TOKEN }}'
149-
run: |
150-
find ./npm -mindepth 1 -maxdepth 1 -print0 | xargs -0 -n 1 -- sh -xc 'npx ts-node ./tool/prepare-optional-release.ts --package=$(basename $1) && npm publish $1' --
151-
152-
- run: npm publish
153-
env:
154-
NODE_AUTH_TOKEN: '${{ secrets.NPM_TOKEN }}'
131+
permissions:
132+
attestations: write
133+
contents: write
134+
id-token: write
135+
uses: ./.github/workflows/release.yml

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
deploy_npm:
8+
name: Deploy npm
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v5
13+
- uses: actions/setup-node@v6
14+
with:
15+
node-version: 'lts/*'
16+
check-latest: true
17+
registry-url: 'https://registry.npmjs.org'
18+
19+
# npm trusted publisher infrastructure requires npm >=11.5.1
20+
- run: npm install -g npm@latest
21+
22+
- run: npm install
23+
24+
- name: "Check we're not using a -dev version of the embedded protocol"
25+
run: jq -r '.["protocol-version"]' package.json | grep -qv -- '-dev$'
26+
- name: "Check we're not using a -dev version of the embedded compiler"
27+
run: jq -r '.["compiler-version"]' package.json | grep -qv -- '-dev$'
28+
29+
- name: Publish optional dependencies
30+
run: |
31+
find ./npm -mindepth 1 -maxdepth 1 -print0 | xargs -0 -n 1 -- sh -xc 'npx ts-node ./tool/prepare-optional-release.ts --package=$(basename $1) && npm publish $1' --
32+
33+
- run: npm publish

0 commit comments

Comments
 (0)