Skip to content

Commit 5a1ad86

Browse files
committed
ci: add tag-triggered npm publish and GitHub release
- Add v* tag trigger and publish job to CI workflow (runs after all checks pass: lint, typecheck, test, build, e2e) - Add publishConfig.access=public to package.json - Add .npmrc for commit message format (chore: release v%s) - Add Releasing section to README
1 parent ebfc30f commit 5a1ad86

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ name: CI
33
on:
44
push:
55
branches: [main]
6+
tags: ["v*"]
67
pull_request:
78
branches: [main]
89

10+
permissions:
11+
contents: write
12+
id-token: write
13+
914
jobs:
1015
commitlint:
1116
if: github.event_name == 'pull_request'
@@ -84,3 +89,24 @@ jobs:
8489
- run: pnpm install --frozen-lockfile
8590
- run: pnpm build
8691
- run: pnpm test:e2e
92+
93+
publish:
94+
if: startsWith(github.ref, 'refs/tags/v')
95+
needs: [lint, typecheck, test, build, e2e]
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/checkout@v4
99+
- uses: pnpm/action-setup@v4
100+
- uses: actions/setup-node@v4
101+
with:
102+
node-version: 20
103+
cache: pnpm
104+
registry-url: https://registry.npmjs.org
105+
- run: pnpm install --frozen-lockfile
106+
- run: pnpm build
107+
- run: pnpm publish --provenance --no-git-checks --access public
108+
env:
109+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
110+
- run: gh release create ${{ github.ref_name }} --generate-notes
111+
env:
112+
GH_TOKEN: ${{ github.token }}

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
message="chore: release v%s"

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,20 @@ test/
20182018
- Tabs for indentation, double quotes
20192019
- ESM-only (`"type": "module"`)
20202020
2021+
### Releasing
2022+
2023+
Releases are tag-triggered. Pushing a semver tag runs all CI checks, publishes to npm with [provenance](https://docs.npmjs.com/generating-provenance-statements), and creates a GitHub release with auto-generated notes.
2024+
2025+
```bash
2026+
# 1. Bump version
2027+
pnpm version patch # or minor / major
2028+
2029+
# 2. Push commit and tag
2030+
git push && git push --tags
2031+
```
2032+
2033+
CI handles the rest. Requires an `NPM_TOKEN` repository secret.
2034+
20212035
## Contributing
20222036
20232037
Contributions are welcome! Please:

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
},
3232
"packageManager": "pnpm@10.30.3",
3333
"license": "MIT",
34+
"publishConfig": {
35+
"access": "public"
36+
},
3437
"files": [
3538
"dist"
3639
],

0 commit comments

Comments
 (0)