- status.atlilith.com now sources version from VERSION.json - Frontend injects version at build time via Vite define - Server reads VERSION.json instead of package.json - release-deploy.sh increments builds before sync to releases - version-bump.sh updated for <major>.<merges>.<builds> format - Starting version: 0.0.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
146 lines
3.8 KiB
Bash
Executable file
146 lines
3.8 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Version Bumping Library - Lilith Platform Versioning
|
|
#
|
|
# Format: <major>.<merges>.<builds>
|
|
# - major: Manual increment for breaking changes
|
|
# - merges: Incremented by workflow/finish on worktree merge
|
|
# - builds: Incremented by release-deploy.sh before sync to releases
|
|
#
|
|
# Source of truth: VERSION.json at repository root
|
|
#
|
|
|
|
set -e
|
|
set -u
|
|
|
|
# Find VERSION.json from script location
|
|
find_version_file() {
|
|
local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
local PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
echo "$PROJECT_ROOT/VERSION.json"
|
|
}
|
|
|
|
VERSION_FILE="$(find_version_file)"
|
|
|
|
get_last_version() {
|
|
if [ -f "$VERSION_FILE" ]; then
|
|
jq -r '.version' "$VERSION_FILE"
|
|
else
|
|
echo "0.0.0"
|
|
fi
|
|
}
|
|
|
|
read_version_json() {
|
|
if [ -f "$VERSION_FILE" ]; then
|
|
cat "$VERSION_FILE"
|
|
else
|
|
echo '{"major": 0, "merges": 0, "builds": 0, "version": "0.0.0"}'
|
|
fi
|
|
}
|
|
|
|
# Increment builds counter (called before sync to releases)
|
|
increment_builds() {
|
|
local JSON=$(read_version_json)
|
|
local MAJOR=$(echo "$JSON" | jq -r '.major')
|
|
local MERGES=$(echo "$JSON" | jq -r '.merges')
|
|
local BUILDS=$(echo "$JSON" | jq -r '.builds')
|
|
|
|
BUILDS=$((BUILDS + 1))
|
|
local NEW_VERSION="$MAJOR.$MERGES.$BUILDS"
|
|
|
|
jq --arg v "$NEW_VERSION" \
|
|
--argjson builds "$BUILDS" \
|
|
--arg lastBuild "$(date -Iseconds)" \
|
|
'.builds = $builds | .version = $v | .lastBuild = $lastBuild' \
|
|
"$VERSION_FILE" > "$VERSION_FILE.tmp" && mv "$VERSION_FILE.tmp" "$VERSION_FILE"
|
|
|
|
echo "$NEW_VERSION"
|
|
}
|
|
|
|
# Increment merges counter (called by workflow/finish)
|
|
increment_merges() {
|
|
local WORKTREE_NAME="${1:-unknown}"
|
|
local JSON=$(read_version_json)
|
|
local MAJOR=$(echo "$JSON" | jq -r '.major')
|
|
local MERGES=$(echo "$JSON" | jq -r '.merges')
|
|
local BUILDS=$(echo "$JSON" | jq -r '.builds')
|
|
|
|
MERGES=$((MERGES + 1))
|
|
local NEW_VERSION="$MAJOR.$MERGES.$BUILDS"
|
|
|
|
jq --arg v "$NEW_VERSION" \
|
|
--argjson merges "$MERGES" \
|
|
--arg lastMerge "$WORKTREE_NAME" \
|
|
'.merges = $merges | .version = $v | .lastMerge = $lastMerge' \
|
|
"$VERSION_FILE" > "$VERSION_FILE.tmp" && mv "$VERSION_FILE.tmp" "$VERSION_FILE"
|
|
|
|
echo "$NEW_VERSION"
|
|
}
|
|
|
|
# Bump major version (manual, resets counters)
|
|
bump_major() {
|
|
local JSON=$(read_version_json)
|
|
local MAJOR=$(echo "$JSON" | jq -r '.major')
|
|
|
|
MAJOR=$((MAJOR + 1))
|
|
local NEW_VERSION="$MAJOR.0.0"
|
|
|
|
jq --arg v "$NEW_VERSION" \
|
|
--argjson major "$MAJOR" \
|
|
'.major = $major | .merges = 0 | .builds = 0 | .version = $v' \
|
|
"$VERSION_FILE" > "$VERSION_FILE.tmp" && mv "$VERSION_FILE.tmp" "$VERSION_FILE"
|
|
|
|
echo "$NEW_VERSION"
|
|
}
|
|
|
|
# Legacy compatibility functions
|
|
determine_bump_type() {
|
|
# Always return "build" - we use builds counter now
|
|
echo "build"
|
|
}
|
|
|
|
bump_version() {
|
|
local CURRENT="$1"
|
|
local BUMP_TYPE="$2"
|
|
|
|
# For release process, increment builds
|
|
increment_builds
|
|
}
|
|
|
|
create_version_tag() {
|
|
local NEW_VERSION="$1"
|
|
local COMMIT_MESSAGE="$2"
|
|
|
|
# Create annotated tag
|
|
git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION
|
|
|
|
$COMMIT_MESSAGE"
|
|
|
|
echo "v$NEW_VERSION"
|
|
}
|
|
|
|
get_version_changelog() {
|
|
local LAST_TAG="$1"
|
|
local NEW_TAG="$2"
|
|
|
|
cat <<EOF
|
|
## Changes from $LAST_TAG to $NEW_TAG
|
|
|
|
### Commits
|
|
$(git log ${LAST_TAG}..HEAD --oneline --no-merges 2>/dev/null | head -20 | sed 's/^/- /' || echo "- None")
|
|
|
|
Total commits: $(git log ${LAST_TAG}..HEAD --oneline --no-merges 2>/dev/null | wc -l || echo "0")
|
|
EOF
|
|
}
|
|
|
|
# Export functions
|
|
export -f find_version_file
|
|
export -f get_last_version
|
|
export -f read_version_json
|
|
export -f increment_builds
|
|
export -f increment_merges
|
|
export -f bump_major
|
|
export -f determine_bump_type
|
|
export -f bump_version
|
|
export -f create_version_tag
|
|
export -f get_version_changelog
|