Skip to content

Commit 55527ab

Browse files
committed
ci: add npm trusted publishing release workflow
1 parent e1b8378 commit 55527ab

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release (e.g. 1.0.1)'
11+
required: true
12+
type: string
13+
14+
permissions:
15+
id-token: write
16+
contents: write
17+
18+
jobs:
19+
publish:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v7
23+
- uses: actions/setup-node@v7
24+
with:
25+
node-version: '24'
26+
registry-url: 'https://registry.npmjs.org'
27+
- run: npm ci
28+
- run: npm run lint
29+
- run: npm run build
30+
- run: npm test
31+
- name: Set version from workflow input (patch release)
32+
if: github.event_name == 'workflow_dispatch'
33+
run: |
34+
current=$(node -p "require('./package.json').version")
35+
if [ "$current" != "${{ inputs.version }}" ]; then
36+
npm version ${{ inputs.version }} --no-git-tag-version
37+
fi
38+
- run: npm publish --access public --provenance
39+
40+
github-release:
41+
needs: publish
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v7
45+
- name: Determine version
46+
id: version
47+
run: |
48+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
49+
echo "tag=v${{ inputs.version }}" >> "$GITHUB_OUTPUT"
50+
else
51+
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
52+
fi
53+
- uses: softprops/action-gh-release@v3
54+
with:
55+
tag_name: ${{ steps.version.outputs.tag }}
56+
generate_release_notes: true

0 commit comments

Comments
 (0)