mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-08-28 05:27:41 +00:00
Switch release script to date-based versioning
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
98f2097263
commit
945d51ffd4
1 changed files with 12 additions and 27 deletions
|
|
@ -6,37 +6,22 @@ CARGO_TOML="$(git rev-parse --show-toplevel)/Cargo.toml"
|
|||
current_version=$(grep -m1 '^version = ' "$CARGO_TOML" | sed 's/version = "\(.*\)"/\1/')
|
||||
echo "Current version: $current_version"
|
||||
|
||||
IFS='.' read -r major minor patch <<< "$current_version"
|
||||
# Days since 2026-01-01 + 100
|
||||
epoch_2026=$(date -j -f "%Y-%m-%d" "2026-01-01" "+%s")
|
||||
epoch_today=$(date "+%s")
|
||||
days=$(( (epoch_today - epoch_2026) / 86400 ))
|
||||
minor=$(( days + 100 ))
|
||||
|
||||
echo ""
|
||||
echo "Select bump type:"
|
||||
echo " 1) patch ($current_version -> $major.$minor.$((patch + 1)))"
|
||||
echo " 2) minor ($current_version -> $major.$((minor + 1)).0)"
|
||||
echo " 3) major ($current_version -> $((major + 1)).0.0)"
|
||||
echo ""
|
||||
read -rp "Choice [1/2/3]: " choice
|
||||
|
||||
case "$choice" in
|
||||
1) new_version="$major.$minor.$((patch + 1))" ;;
|
||||
2) new_version="$major.$((minor + 1)).0" ;;
|
||||
3) new_version="$((major + 1)).0.0" ;;
|
||||
*) echo "Invalid choice"; exit 1 ;;
|
||||
esac
|
||||
# Find next available patch for today's minor
|
||||
patch=0
|
||||
while git rev-parse "v0.${minor}.${patch}" >/dev/null 2>&1; do
|
||||
patch=$((patch + 1))
|
||||
done
|
||||
|
||||
new_version="0.${minor}.${patch}"
|
||||
tag="v$new_version"
|
||||
|
||||
if git rev-parse "$tag" >/dev/null 2>&1; then
|
||||
echo "Error: tag $tag already exists"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Will bump $current_version -> $new_version and push tag $tag"
|
||||
read -rp "Continue? [y/N]: " confirm
|
||||
if [[ "$confirm" != [yY] ]]; then
|
||||
echo "Aborted"
|
||||
exit 1
|
||||
fi
|
||||
echo "Releasing $new_version (tag $tag)"
|
||||
|
||||
sed -i '' "s/^version = \"$current_version\"/version = \"$new_version\"/" "$CARGO_TOML"
|
||||
echo "Updated $CARGO_TOML"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue