|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | # |
3 | | -# Prepare a release branch with version bumps. |
| 3 | +# Prepare a release branch using VERSION file as source of truth. |
4 | 4 | # |
5 | | -# Usage: ./scripts/prepare-release.sh <patch|minor|major> |
6 | | -# DRY_RUN=1 ./scripts/prepare-release.sh patch # test without commit/push |
| 5 | +# Usage: ./scripts/prepare-release.sh |
| 6 | +# DRY_RUN=1 ./scripts/prepare-release.sh # test without commit/push |
7 | 7 | # |
8 | 8 | # This script: |
9 | | -# 1. Reads current version from VERSION file |
10 | | -# 2. Calculates new version using semver bump |
| 9 | +# 1. Reads version from VERSION file (must be bumped manually beforehand) |
| 10 | +# 2. Validates VERSION looks like valid semver |
11 | 11 | # 3. Creates a release branch |
12 | | -# 4. Updates VERSION, sqlite-vec.h, and package.json |
| 12 | +# 4. Syncs VERSION to sqlite-vec.h and package.json |
13 | 13 | # 5. Commits and pushes the release branch |
14 | 14 | # |
15 | 15 | # Outputs (for GitHub Actions): |
16 | 16 | # - Writes branch=<name> and version=<version> to $GITHUB_OUTPUT if set |
17 | 17 | # |
18 | | -# Why this exists (replacing scripts/publish-release.sh): |
| 18 | +# Developer workflow: |
| 19 | +# 1. Manually bump VERSION file (e.g., 0.4.0 → 0.4.1) |
| 20 | +# 2. Update CHANGELOG-mceachen.md with changes |
| 21 | +# 3. Commit: git commit -am "release: prepare v0.4.1" |
| 22 | +# 4. Trigger npm-release.yaml workflow |
| 23 | +# 5. Workflow runs this script, builds, publishes, merges to main |
19 | 24 | # |
20 | | -# The original publish-release.sh pushed version bumps to main BEFORE CI |
21 | | -# builds completed. If builds failed, main was left in an inconsistent state |
22 | | -# with a version tag pointing to broken artifacts. |
| 25 | +# Why VERSION is source of truth: |
23 | 26 | # |
24 | | -# This script is part of a safer release flow: |
| 27 | +# - Clear and transparent: "The version is whatever VERSION says" |
| 28 | +# - Prepare releases: Update CHANGELOG for new version before workflow runs |
| 29 | +# - Git history: Version bumps are explicit, visible commits |
| 30 | +# - Standard practice: Similar to Go modules, Rust crates, etc. |
25 | 31 | # |
26 | | -# 1. RELEASE BRANCH ISOLATION: Version bumps happen on a release/vX.Y.Z |
| 32 | +# Why this release flow exists: |
| 33 | +# |
| 34 | +# 1. RELEASE BRANCH ISOLATION: VERSION sync happens on a release/vX.Y.Z |
27 | 35 | # branch. Main is untouched until everything succeeds. |
28 | 36 | # |
29 | 37 | # 2. CORRECT VERSION IN BINARIES: All platform builds check out the release |
|
45 | 53 | # |
46 | 54 | set -euo pipefail |
47 | 55 |
|
48 | | -BUMP_TYPE="${1:-patch}" |
| 56 | +# Get version from VERSION file (source of truth) |
| 57 | +VERSION=$(cat VERSION | tr -d '[:space:]') |
| 58 | +echo "Releasing version: $VERSION" |
49 | 59 |
|
50 | | -if [[ ! "$BUMP_TYPE" =~ ^(patch|minor|major)$ ]]; then |
51 | | - echo "Usage: $0 <patch|minor|major>" >&2 |
| 60 | +# Validate VERSION looks like semver (basic check) |
| 61 | +if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then |
| 62 | + echo "ERROR: VERSION file contains invalid semver: '$VERSION'" >&2 |
| 63 | + echo "Expected format: X.Y.Z or X.Y.Z-prerelease" >&2 |
52 | 64 | exit 1 |
53 | 65 | fi |
54 | 66 |
|
55 | | -# Get current version from VERSION file (source of truth) |
56 | | -CURRENT=$(cat VERSION | tr -d '[:space:]') |
57 | | -echo "Current version: $CURRENT" |
58 | | - |
59 | | -# Calculate new version (strip prerelease suffix, then bump) |
60 | | -BASE_VERSION=$(echo "$CURRENT" | sed 's/-.*//') |
61 | | -NEW_VERSION=$(npx -y semver -i "$BUMP_TYPE" "$BASE_VERSION") |
62 | | -echo "New version: $NEW_VERSION" |
63 | | - |
64 | 67 | # Create release branch |
65 | 68 | BRANCH="release/v${NEW_VERSION}" |
66 | 69 | git checkout -b "$BRANCH" |
|
0 commit comments