Skip to content

Commit 20a59ee

Browse files
authored
Update release workflows to support npm trusted publshing (#2669)
1 parent 10442ab commit 20a59ee

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

.github/util/initialize/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ inputs:
55
node-version: {required: false, default: 'lts/*'}
66
dart-sdk: {required: false, default: stable}
77
architecture: {required: false}
8+
for-npm-deploy: {required: false, default: false}
89
runs:
910
using: composite
1011
steps:
@@ -14,9 +15,22 @@ runs:
1415
architecture: "${{ inputs.architecture }}"
1516

1617
- uses: actions/setup-node@v6
18+
if: "inputs.for-npm-deploy != true"
1719
with:
1820
node-version: "${{ inputs.node-version }}"
1921

22+
- uses: actions/setup-node@v6
23+
if: inputs.for-npm-deploy == true
24+
with:
25+
node-version: "${{ inputs.node-version }}"
26+
check-latest: true
27+
registry-url: 'https://registry.npmjs.org'
28+
29+
# npm trusted publisher infrastructure requires npm >=11.5.1
30+
- run: npm install -g npm@latest
31+
if: inputs.for-npm-deploy == true
32+
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
33+
2034
# See: https://github.com/dart-lang/sdk/issues/52266
2135
- run: Invoke-WebRequest https://pub.dev
2236
if: runner.os == 'Windows'

.github/workflows/release.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ jobs:
6565
steps:
6666
- uses: actions/checkout@v5
6767
- uses: ./.github/util/initialize
68-
with: {github-token: "${{ github.token }}"}
68+
with:
69+
github-token: ${{ github.token }}
70+
for-npm-deploy: true
6971

7072
- name: Deploy
7173
run: dart run grinder pkg-npm-deploy
7274
env:
7375
UPDATE_SASS_SASS_REPO: false
74-
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
7576

7677
deploy_pub:
7778
name: Deploy Pub
@@ -113,6 +114,10 @@ jobs:
113114
node-version: 'lts/*'
114115
check-latest: true
115116
registry-url: 'https://registry.npmjs.org'
117+
118+
# npm trusted publisher infrastructure requires npm >=11.5.1
119+
- run: npm install -g npm@latest
120+
116121
- name: Get Dart Sass version
117122
id: dart-sass-version
118123
run: echo "version=${{ github.ref_name }}" | tee --append "$GITHUB_OUTPUT"
@@ -127,8 +132,6 @@ jobs:
127132
run: npm pkg set version='${{ steps.dart-sass-version.outputs.version }}'
128133
working-directory: pkg/sass-types/
129134
- run: npm publish
130-
env:
131-
NODE_AUTH_TOKEN: '${{ secrets.NPM_TOKEN }}'
132135
working-directory: pkg/sass-types/
133136

134137
deploy_sass_parser:
@@ -147,8 +150,8 @@ jobs:
147150
check-latest: true
148151
registry-url: 'https://registry.npmjs.org'
149152

150-
# The repo package has a file dependency, but the released version needs
151-
# a real dependency on the released version of Sass.
153+
# The repo package has a file dependency, but the released version needs a
154+
# real dependency on the released version of Sass.
152155
- name: Get Dart Sass version
153156
id: dart-sass-version
154157
run: echo "version=${{ github.ref_name }}" | tee --append "$GITHUB_OUTPUT"
@@ -158,8 +161,6 @@ jobs:
158161
- run: npm run compile
159162
working-directory: pkg/sass-parser/
160163
- run: npm publish
161-
env:
162-
NODE_AUTH_TOKEN: '${{ secrets.NPM_TOKEN }}'
163164
working-directory: pkg/sass-parser/
164165

165166
- name: Get Sass parser version

0 commit comments

Comments
 (0)