Skip to content

Commit d18e4e7

Browse files
committed
Prepare npm publishing pipeline
- package.json: add repository / bugs / homepage / keywords / author for npm listing metadata, add NOTICE to the tarball's files field, and add `prepublishOnly` = gen-proto + build so the dist artifacts are always fresh at publish time. - New .github/workflows/release.yml triggers on `v*` tag pushes (plus manual workflow_dispatch for replays). It verifies the tag matches package.json version, regenerates proto, lints, typechecks, runs the full test suite, then publishes to npm with SLSA provenance via --provenance (requires id-token: write). Requires a repository secret `NPM_TOKEN` (granular automation token scoped to the oxia package) for the publish step. Signed-off-by: Matteo Merli <mmerli@apache.org>
1 parent 374b7af commit d18e4e7

2 files changed

Lines changed: 102 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
# Lets a maintainer republish a specific tag manually if the automated
7+
# run failed after an issue was fixed out-of-band.
8+
workflow_dispatch:
9+
inputs:
10+
tag:
11+
description: 'Tag to publish (e.g. v0.1.0)'
12+
required: true
13+
14+
concurrency:
15+
group: release-${{ github.ref }}
16+
cancel-in-progress: false
17+
18+
permissions:
19+
contents: read
20+
id-token: write # required for npm provenance
21+
22+
jobs:
23+
publish:
24+
name: Publish to npm
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
ref: ${{ github.event.inputs.tag || github.ref }}
30+
31+
- uses: arduino/setup-protoc@v3
32+
with:
33+
version: '27.x'
34+
repo-token: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- uses: actions/setup-node@v4
37+
with:
38+
node-version: 20
39+
cache: 'npm'
40+
registry-url: 'https://registry.npmjs.org'
41+
42+
- run: npm ci
43+
44+
- name: Verify package.json version matches tag
45+
run: |
46+
TAG="${{ github.event.inputs.tag || github.ref_name }}"
47+
TAG_VERSION="${TAG#v}"
48+
PKG_VERSION="$(node -p "require('./package.json').version")"
49+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
50+
echo "::error::Tag $TAG declares version $TAG_VERSION but package.json has $PKG_VERSION"
51+
exit 1
52+
fi
53+
echo "Publishing version $PKG_VERSION"
54+
55+
- name: Generate proto code
56+
run: npm run gen-proto
57+
58+
- name: Lint
59+
run: npm run lint
60+
61+
- name: Typecheck
62+
run: npx tsc --noEmit -p tsconfig.json
63+
64+
- name: Test
65+
run: npm test
66+
67+
- name: Build
68+
run: npm run build
69+
70+
# `prepublishOnly` in package.json runs gen-proto + build again; the
71+
# earlier steps are so we get a clean lint/typecheck/test signal before
72+
# we touch npm.
73+
- name: Publish with provenance
74+
run: npm publish --access public --provenance
75+
env:
76+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
"version": "0.1.0",
44
"description": "Oxia client SDK for Node.js",
55
"license": "Apache-2.0",
6+
"author": "The Oxia Authors",
7+
"homepage": "https://oxia-db.github.io",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/oxia-db/oxia-client-node.git"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/oxia-db/oxia-client-node/issues"
14+
},
15+
"keywords": [
16+
"oxia",
17+
"oxia-db",
18+
"kv",
19+
"key-value",
20+
"metadata",
21+
"coordination",
22+
"distributed",
23+
"grpc",
24+
"notifications"
25+
],
626
"type": "module",
727
"main": "dist/index.js",
828
"types": "dist/index.d.ts",
@@ -15,7 +35,8 @@
1535
"files": [
1636
"dist",
1737
"src",
18-
"proto"
38+
"proto",
39+
"NOTICE"
1940
],
2041
"engines": {
2142
"node": ">=18"
@@ -27,13 +48,14 @@
2748
"test:watch": "vitest",
2849
"lint": "biome check src test",
2950
"format": "biome format --write src test",
30-
"docs": "typedoc"
51+
"docs": "typedoc",
52+
"prepublishOnly": "npm run gen-proto && npm run build"
3153
},
3254
"dependencies": {
3355
"@bufbuild/protobuf": "^2.2.0",
3456
"@grpc/grpc-js": "^1.12.0",
35-
"long": "^5.2.3",
36-
"@node-rs/xxhash": "^1.7.6"
57+
"@node-rs/xxhash": "^1.7.6",
58+
"long": "^5.2.3"
3759
},
3860
"devDependencies": {
3961
"@biomejs/biome": "^1.9.0",

0 commit comments

Comments
 (0)