Skip to content

Commit 32eca27

Browse files
committed
npm publishing via ci and trusted publisher
1 parent c45aeb4 commit 32eca27

3 files changed

Lines changed: 102 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,33 @@ concurrency:
1313
group: ${{ github.head_ref || github.run_id }}
1414
cancel-in-progress: true
1515
jobs:
16+
verify-version:
17+
if: startsWith(github.ref, 'refs/tags/')
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v6
21+
- name: Verify tag version matches package.json
22+
run: |
23+
# Extract tag name from GITHUB_REF (e.g., refs/tags/v6.0.2 -> v6.0.2)
24+
TAG_NAME="${GITHUB_REF#refs/tags/}"
25+
# Remove 'v' prefix if present to get the version number
26+
TAG_VERSION="${TAG_NAME#v}"
27+
28+
# Get version from package.json
29+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
30+
31+
echo "Tag version: $TAG_VERSION"
32+
echo "Package version: $PACKAGE_VERSION"
33+
34+
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
35+
echo "ERROR: Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
36+
echo "Please update package.json or create a new tag with the correct version"
37+
echo "GitHub release will NOT be created."
38+
exit 1
39+
fi
40+
41+
echo "Version match verified!"
42+
1643
build:
1744
runs-on: ${{ matrix.os }}
1845
strategy:
@@ -163,3 +190,23 @@ jobs:
163190
- name: Upload binaries to GitHub Release
164191
run: yarn install --ignore-scripts && yarn upload --upload-all ${{ github.token }}
165192
if: startsWith(github.ref, 'refs/tags/')
193+
194+
publish-npm:
195+
needs: [build, build-musl]
196+
if: startsWith(github.ref, 'refs/tags/')
197+
runs-on: ubuntu-latest
198+
permissions:
199+
contents: read
200+
id-token: write
201+
steps:
202+
- uses: actions/checkout@v6
203+
- uses: actions/setup-node@v6
204+
with:
205+
node-version: 24
206+
registry-url: https://registry.npmjs.org
207+
208+
- name: Install dependencies
209+
run: yarn install --ignore-scripts
210+
211+
- name: Publish to npm
212+
run: npm publish

docs/DEVELOP.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Development and Release Guide
2+
3+
## Version Bumping
4+
5+
This project uses [npm version](https://docs.npmjs.com/cli/v10/commands/npm-version) to manage version releases.
6+
7+
### How to release a new version
8+
9+
1. **Bump the version** (this will create a Git tag automatically):
10+
```bash
11+
npm version <major|minor|patch>
12+
```
13+
14+
For example:
15+
```bash
16+
npm version patch
17+
```
18+
19+
2. **Push the changes and tags**:
20+
```bash
21+
git push origin main --tags
22+
```
23+
24+
The CI workflow will automatically:
25+
- Build binaries for all platforms
26+
- Upload them as release assets
27+
- Publish the package to npm
28+
29+
### Version format
30+
31+
- Versions follow [SemVer](https://semver.org/) format
32+
- Tags should be prefixed with `v`, e.g., `v6.0.2`
33+
- The version in `package.json` must match the Git tag version
34+
35+
## Release process
36+
37+
When you push a tag (e.g., `v6.0.2`), the CI workflow will:
38+
39+
1. Build prebuilt binaries for:
40+
- macOS (x64, arm64)
41+
- Linux (x64, arm64)
42+
- Windows (x64, ia32)
43+
44+
2. Upload binaries to GitHub Release
45+
46+
3. Publish to npm using trusted publishing (no NPM_TOKEN required)
47+
48+
## Checking the release
49+
50+
After releasing, you can verify:
51+
- GitHub Release with binaries: https://github.com/gms1/node-sqlite3/releases
52+
- npm package: https://www.npmjs.com/package/@homeofthings/sqlite3

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
"test": "node test/support/createdb.js && mocha -R spec --timeout 480000"
7777
},
7878
"license": "BSD-3-Clause",
79+
"publishConfig": {
80+
"access": "public"
81+
},
7982
"keywords": [
8083
"sql",
8184
"sqlite",

0 commit comments

Comments
 (0)