Skip to content

Commit c2a2a5e

Browse files
Vrtak-CZclaude
andcommitted
feat(ci): automate releases with git-tag-based versioning
Replace manual version bumping with automated release workflow. Version is now derived from git tags instead of being committed in package.json — the release workflow calculates semver bumps, creates tags (no v prefix), and triggers npm publish. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 989d28e commit c2a2a5e

4 files changed

Lines changed: 61 additions & 2 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
2525
restore-keys: ${{ runner.os }}-bun-
2626
- run: bun install --frozen-lockfile
27+
- name: Set version from release tag
28+
run: npm version "${{ github.event.release.tag_name }}" --no-git-tag-version --allow-same-version
2729
- run: bun run check
2830
- run: bun run typecheck
2931
- run: bun test

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: "Version bump type"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- uses: actions/checkout@v6
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Get latest tag
26+
id: latest
27+
run: |
28+
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
29+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
30+
31+
- name: Calculate new version
32+
id: version
33+
run: |
34+
IFS='.' read -r major minor patch <<< "${{ steps.latest.outputs.tag }}"
35+
case "${{ inputs.bump }}" in
36+
major) major=$((major + 1)); minor=0; patch=0 ;;
37+
minor) minor=$((minor + 1)); patch=0 ;;
38+
patch) patch=$((patch + 1)) ;;
39+
esac
40+
echo "new=${major}.${minor}.${patch}" >> "$GITHUB_OUTPUT"
41+
42+
- name: Create tag and release
43+
env:
44+
GH_TOKEN: ${{ github.token }}
45+
run: |
46+
git tag "${{ steps.version.outputs.new }}"
47+
git push origin "${{ steps.version.outputs.new }}"
48+
gh release create "${{ steps.version.outputs.new }}" --generate-notes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cookielab.io/klovi",
3-
"version": "0.9.8",
3+
"version": "0.0.0",
44
"description": "A local web app for browsing and presenting Claude Code session history",
55
"module": "index.ts",
66
"type": "module",

scripts/build-server.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import { join } from "node:path";
22
import pkg from "../package.json";
33

4+
let version = pkg.version;
5+
if (version === "0.0.0") {
6+
try {
7+
version = (await Bun.$`git describe --tags`.text()).trim();
8+
} catch {
9+
version = "dev";
10+
}
11+
}
12+
413
let commitHash = "";
514
try {
615
commitHash = (await Bun.$`git rev-parse --short HEAD`.text()).trim();
716
} catch {
817
// git not available
918
}
1019

11-
await Bun.$`bun build index.ts --target node --outfile dist/server.js --define process.env.KLOVI_VERSION=${JSON.stringify(pkg.version)} --define process.env.KLOVI_COMMIT=${JSON.stringify(commitHash)}`;
20+
await Bun.$`bun build index.ts --target node --outfile dist/server.js --define process.env.KLOVI_VERSION=${JSON.stringify(version)} --define process.env.KLOVI_COMMIT=${JSON.stringify(commitHash)}`;
1221

1322
// Prepend shebang for direct CLI execution (package.json "bin" points here)
1423
const serverPath = join(import.meta.dir, "..", "dist", "server.js");

0 commit comments

Comments
 (0)