Skip to content

Commit c8255f7

Browse files
committed
refactor(release): use VERSION file as source of truth instead of automatic bumping
Changed release workflow from automated version bumping to manual VERSION control. **Changes to prepare-release.sh:** - Remove version bump type argument (patch/minor/major) - Read VERSION file as-is instead of calculating new version - Add semver validation for VERSION format - Sync VERSION to package.json instead of bumping both - Updated documentation to explain manual workflow - Simplified: no longer writes to VERSION file, just reads it **Changes to npm-release.yaml:** - Remove workflow_dispatch inputs (version bump type selector) - Update documentation to explain manual VERSION bumping - Remove ${{ github.event.inputs.version }} parameter **Developer workflow (new):** 1. Manually bump VERSION file (e.g., 0.4.0 → 0.4.1) 2. Update CHANGELOG-mceachen.md with changes 3. Commit: git commit -am "release: prepare v0.4.1" 4. Trigger npm-release.yaml workflow 5. Workflow syncs VERSION to package.json and publishes **Rationale:** - Single source of truth: "The version is whatever VERSION says" - Prepare releases: Can update CHANGELOG for new version before triggering workflow - Transparent: Version bumps are explicit, visible git commits - Standard practice: Similar to Go modules, Rust crates, Python tools This is more intuitive for future maintainers than having the version magically calculated during workflow execution.
1 parent 91cea55 commit c8255f7

2 files changed

Lines changed: 28 additions & 28 deletions

File tree

.github/workflows/npm-release.yaml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,21 @@ name: "npm Release"
3838

3939
#
4040
# RELEASE FLOW:
41-
# 1. prepare-release: Creates a release branch, bumps VERSION/sqlite-vec.h/package.json
42-
# 2. build-*: All builds run from the release branch (with correct version baked in)
43-
# 3. publish-npm: Publishes to npm, then merges release branch to main on success
41+
# 1. Manually bump VERSION file and update CHANGELOG-mceachen.md on main
42+
# 2. prepare-release: Creates a release branch, syncs VERSION to sqlite-vec.h/package.json
43+
# 3. build-*: All builds run from the release branch (with correct version baked in)
44+
# 4. publish-npm: Publishes to npm, then merges release branch to main on success
4445
#
4546
# If any step fails, main is untouched and the release branch can be deleted.
4647
#
48+
# BEFORE TRIGGERING THIS WORKFLOW:
49+
# - Bump VERSION file (e.g., 0.4.0 → 0.4.1)
50+
# - Update CHANGELOG-mceachen.md with release notes
51+
# - Commit to main: git commit -am "release: prepare v0.4.1"
52+
#
4753

4854
on:
4955
workflow_dispatch:
50-
inputs:
51-
version:
52-
description: "Version bump type"
53-
required: false
54-
type: choice
55-
default: "patch"
56-
options:
57-
- patch
58-
- minor
59-
- major
6056

6157
permissions:
6258
contents: read
@@ -86,7 +82,7 @@ jobs:
8682

8783
- name: Prepare release branch
8884
id: prepare
89-
run: ./scripts/prepare-release.sh ${{ github.event.inputs.version }}
85+
run: ./scripts/prepare-release.sh
9086

9187
build-linux-x64:
9288
needs: [prepare-release]

scripts/prepare-release.sh

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,43 +65,47 @@ if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
6565
fi
6666

6767
# Create release branch
68-
BRANCH="release/v${NEW_VERSION}"
68+
BRANCH="release/v${VERSION}"
6969
git checkout -b "$BRANCH"
7070

71-
# Update VERSION file
72-
echo "$NEW_VERSION" > VERSION
73-
74-
# Regenerate sqlite-vec.h from template
71+
# Regenerate sqlite-vec.h from template (uses VERSION file)
7572
make sqlite-vec.h
7673

77-
# Update package.json and package-lock.json
78-
npm version "$NEW_VERSION" --no-git-tag-version
74+
# Sync VERSION to package.json and package-lock.json
75+
npm version "$VERSION" --no-git-tag-version --allow-same-version
7976
npm install --package-lock-only
8077

81-
# Commit all version changes
82-
git add VERSION sqlite-vec.h package.json package-lock.json
78+
# Commit version sync (VERSION should already be committed on main)
79+
git add sqlite-vec.h package.json package-lock.json
8380

8481
if [[ -n "${DRY_RUN:-}" ]]; then
8582
echo ""
8683
echo "=== DRY RUN MODE ==="
87-
echo "Would commit and push branch '$BRANCH' with version $NEW_VERSION"
84+
echo "Would commit and push branch '$BRANCH' with version $VERSION"
8885
echo ""
89-
echo "Files staged:"
86+
echo "Files to be committed:"
9087
git diff --cached --name-only
9188
echo ""
9289
echo "To clean up:"
9390
echo " git reset HEAD && git checkout -- . && git checkout main && git branch -D $BRANCH"
9491
exit 0
9592
fi
9693

97-
git commit -S -m "release: v${NEW_VERSION}"
94+
# Only commit if there are changes (VERSION might already be synced)
95+
if ! git diff --cached --quiet; then
96+
git commit -S -m "release: sync package.json to v${VERSION}"
97+
echo "Committed package.json sync for v${VERSION}"
98+
else
99+
echo "No changes to commit (package.json already synced)"
100+
fi
101+
98102
git push origin "$BRANCH"
99103

100104
# Output for GitHub Actions
101105
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
102106
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
103-
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
107+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
104108
fi
105109

106110
echo "Release branch '$BRANCH' created and pushed."
107-
echo "Version: $NEW_VERSION"
111+
echo "Version: $VERSION"

0 commit comments

Comments
 (0)