Skip to content

Commit 9d9afa3

Browse files
authored
ci: add publish action for releases (#2181)
Defines a GitHub action to publish releases from GitHub CI using the npm trusted publishers method. I've tested this on a smaller project I maintain github.com/jsonresume/jsonresume-theme-class and everything went great, so I'm adopting this in svg/svgo as well. This makes the process of releasing a little less stressful, and significantly reduces the likelihood for human error, like releasing versions under the wrong dist-tag. 😓 The only difference between this workflow and other ones I've defined is that for SVGO, I use `jq` to check if the version name includes `-rc.` which indicates it's a release candidate. If so, we use the `rc` dist-tag.
1 parent 14010d0 commit 9d9afa3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/publish.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Node.js Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
workflow_dispatch:
7+
8+
permissions:
9+
id-token: write
10+
contents: read
11+
12+
jobs:
13+
publish-npm:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v5
17+
- run: corepack enable
18+
- uses: actions/setup-node@v6
19+
with:
20+
node-version: 22
21+
registry-url: https://registry.npmjs.org
22+
- run: yarn install
23+
- run: |
24+
if jq -r .version <package.json | grep -q \\-rc.; then
25+
yarn npm publish --access public --tag rc
26+
else
27+
yarn npm publish --access public
28+
fi

0 commit comments

Comments
 (0)