Skip to content

Commit bd207e3

Browse files
committed
feat: publish pipeline
1 parent 34a4670 commit bd207e3

File tree

3 files changed

+113
-1
lines changed

3 files changed

+113
-1
lines changed

.github/workflows/publish.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
validate-version:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Verify tag matches package version
15+
run: |
16+
TAG=${GITHUB_REF#refs/tags/v}
17+
PKG_VERSION=$(node -p "require('./package.json').version")
18+
if [ "$TAG" != "$PKG_VERSION" ]; then
19+
echo "Tag $TAG doesn't match package version $PKG_VERSION"
20+
exit 1
21+
fi
22+
echo "Version validation successful: $TAG"
23+
24+
build-and-publish:
25+
needs: validate-version
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Setup Node
33+
uses: actions/setup-node@v3
34+
with:
35+
node-version: 18
36+
registry-url: 'https://registry.npmjs.org'
37+
38+
- name: Setup pnpm
39+
uses: pnpm/action-setup@v2
40+
with:
41+
version: 8.15.5
42+
run_install: false
43+
44+
- name: Get pnpm store directory
45+
shell: bash
46+
run: |
47+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
48+
49+
- name: Cache pnpm dependencies
50+
uses: actions/cache@v3
51+
with:
52+
path: ${{ env.STORE_PATH }}
53+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
54+
restore-keys: |
55+
${{ runner.os }}-pnpm-store-
56+
57+
- name: Install dependencies
58+
run: pnpm install --frozen-lockfile
59+
60+
- name: Typecheck
61+
run: pnpm typecheck
62+
63+
- name: Lint
64+
run: pnpm lint
65+
66+
- name: Build
67+
run: pnpm build
68+
69+
- name: Test
70+
run: pnpm test
71+
72+
- name: Publish package
73+
run: |
74+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
75+
pnpm publish --no-git-checks --access public
76+
env:
77+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
78+
79+
- name: Create GitHub Release
80+
run: gh release create ${GITHUB_REF#refs/tags/} --generate-notes
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,33 @@ pnpm test
169169
pnpm test:watch
170170
```
171171

172+
### Releasing
173+
174+
This package follows semantic versioning. To release a new version:
175+
176+
1. Choose the appropriate release type based on your changes:
177+
```bash
178+
# For bug fixes and minor changes (0.0.x)
179+
pnpm release:patch
180+
181+
# For new features - backward compatible (0.x.0)
182+
pnpm release:minor
183+
184+
# For breaking changes (x.0.0)
185+
pnpm release:major
186+
```
187+
188+
2. Push the new tag to GitHub:
189+
```bash
190+
git push --follow-tags
191+
```
192+
193+
3. The GitHub Actions workflow will automatically:
194+
- Validate that the tag version matches the package.json version
195+
- Run tests and build the package
196+
- Publish to npm (requires npm authentication)
197+
- Create a GitHub Release for the tag
198+
172199
## License
173200

174201
MIT

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
"clean": "rm -rf dist",
1818
"prepare": "npm run build",
1919
"test": "vitest run",
20-
"test:watch": "vitest"
20+
"test:watch": "vitest",
21+
"release:patch": "npm version patch -m \"chore(release): %s\"",
22+
"release:minor": "npm version minor -m \"chore(release): %s\"",
23+
"release:major": "npm version major -m \"chore(release): %s\""
2124
},
2225
"repository": {
2326
"type": "git",

0 commit comments

Comments
 (0)