Skip to content

Commit 413a63e

Browse files
pratiksahuclaude
andcommitted
Add GitHub Actions CI and npm release workflows
CI builds and smoke-tests the CLI on Node 18/20/22 for pushes and PRs to main. Release publishes to npm with provenance and creates a GitHub Release when a vX.Y.Z tag is pushed; it verifies the tag matches package.json first. Requires an NPM_TOKEN automation-token secret. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0140ae8 commit 413a63e

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [18, 20, 22]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
cache: npm
22+
- run: npm ci
23+
- run: npm run build
24+
- name: Smoke test the built CLI
25+
run: |
26+
node dist/cli.js --version
27+
node dist/cli.js --list --no-color > /dev/null
28+
printf 'y\nn\n' | node dist/cli.js quick --no-detect --no-save --no-color > /dev/null

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release
2+
3+
# Publishes to npm when a version tag (e.g. v0.2.1) is pushed.
4+
#
5+
# Setup (one time):
6+
# 1. Create an npm "Automation" access token for the @geekyants org
7+
# (npmjs.com → Access Tokens → Generate → Automation). Automation tokens
8+
# bypass 2FA/OTP, which is what lets CI publish unattended.
9+
# 2. Add it as a repo secret named NPM_TOKEN
10+
# (Settings → Secrets and variables → Actions → New repository secret).
11+
#
12+
# Cut a release:
13+
# npm version patch # bumps package.json + creates a vX.Y.Z commit & tag
14+
# git push --follow-tags
15+
16+
on:
17+
push:
18+
tags:
19+
- "v*"
20+
21+
permissions:
22+
contents: write # create the GitHub Release
23+
id-token: write # npm provenance (public package + public repo)
24+
25+
jobs:
26+
publish:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: 20
34+
registry-url: "https://registry.npmjs.org"
35+
cache: npm
36+
37+
- name: Verify tag matches package.json version
38+
run: |
39+
PKG_VERSION="$(node -p "require('./package.json').version")"
40+
TAG_VERSION="${GITHUB_REF_NAME#v}"
41+
echo "package.json: $PKG_VERSION | tag: $TAG_VERSION"
42+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
43+
echo "::error::Tag $GITHUB_REF_NAME does not match package.json version $PKG_VERSION"
44+
exit 1
45+
fi
46+
47+
- run: npm ci
48+
49+
- run: npm run build
50+
51+
- name: Publish to npm
52+
run: npm publish --provenance --access public
53+
env:
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
56+
- name: Create GitHub Release
57+
run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes
58+
env:
59+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)