Skip to content

Commit f5158a8

Browse files
Merge pull request #1072 from NordicSemiconductor/push-vpnyyqtmqvws
Switch to trusted publishing for npm
2 parents 85183dd + dff4f7e commit f5158a8

File tree

4 files changed

+43
-33
lines changed

4 files changed

+43
-33
lines changed

.github/workflows/auto-publish-shared.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Auto-publish shared
22

3-
on:
4-
push:
5-
branches: [main]
3+
on: workflow_call
64

75
jobs:
86
check:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release shared
2+
3+
# With the trusted publisher model, npm now allows only a single workflow to
4+
# be registered as the trusted publisher. But this workflow can then invoke
5+
# other workflows, which may do the actual publishing.
6+
7+
# So this workflow will act as a switch which:
8+
# - If run on main branch as a result of a push, will check try to
9+
# automatically release a new version
10+
# - Can be run directly to explicitly publish a new version to npm (which only
11+
# makes sense when running it on a branch apart from main, because there the
12+
# auto-publish workflow will take care of it)
13+
#
14+
# The idea of this setup is also shown in
15+
# https://github.com/orgs/community/discussions/174507#discussioncomment-14723818
16+
17+
on:
18+
push:
19+
branches: [main]
20+
workflow_dispatch:
21+
inputs:
22+
ref:
23+
description:
24+
Ref (Tag, branch, commit SHA) to release. Defaults to from
25+
where the workflow is triggered, usually the main branch.
26+
required: false
27+
type: string
28+
29+
jobs:
30+
auto-publish:
31+
if: ${{ github.event_name == 'push' }}
32+
uses: ./.github/workflows/auto-publish-shared.yml
33+
secrets: inherit
34+
35+
explicit-publish:
36+
if: ${{ github.event_name == 'workflow_dispatch' }}
37+
uses: ./.github/workflows/release-shared.yml
38+
with:
39+
ref: ${{ inputs.ref }}

.github/workflows/release-shared.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
name: Release shared
22

33
on:
4-
workflow_dispatch:
4+
workflow_call:
55
inputs:
66
ref:
77
description:
88
Ref (Tag, branch, commit SHA) to release. Defaults to from
99
where the workflow is triggered, usually the main branch.
1010
required: false
1111
type: string
12-
workflow_call:
1312

1413
jobs:
1514
release:
@@ -36,6 +35,7 @@ jobs:
3635
exit 1
3736
fi
3837
38+
- run: npm install --global npm@latest
3939
- run: npm ci
4040
- run: npm run check
4141
- run: npm test
@@ -60,6 +60,4 @@ jobs:
6060
--notes-file release_notes.md
6161
6262
- name: Publish to npm
63-
env:
64-
NODE_AUTH_TOKEN: ${{ secrets.WAYLAND_NPM_TOKEN }}
65-
run: npm publish --provenance
63+
run: npm publish

.github/workflows/unpublish-npm-version.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)