mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-13 11:22:21 +00:00
feat: Change versioning scheme to calver.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ef -o pipefail
|
||||
|
||||
@@ -13,23 +13,37 @@ check_command git
|
||||
check_command git-cliff
|
||||
check_command uv
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo " > No semver verb specified, run release with <major|minor|patch> parameter."
|
||||
exit 1
|
||||
# Get current date components
|
||||
YEAR=$(date +%Y)
|
||||
MONTH=$(date +%-m) # %-m removes zero padding
|
||||
|
||||
# Get the latest version for current year and month
|
||||
LATEST_TAG=$(git tag -l "${YEAR}.${MONTH}.*" | sort -V | tail -n 1)
|
||||
|
||||
if [ -z "$LATEST_TAG" ]; then
|
||||
# No version for current year/month exists, start at 0
|
||||
MICRO=0
|
||||
else
|
||||
# Extract micro version and increment
|
||||
MICRO=$(echo "$LATEST_TAG" | cut -d. -f3)
|
||||
MICRO=$((MICRO + 1))
|
||||
fi
|
||||
|
||||
CURRENT_VERSION=$(uvx poetry version -s)
|
||||
NEXT_VERSION="${YEAR}.${MONTH}.${MICRO}"
|
||||
CURRENT_VERSION=$(uv version --short)
|
||||
|
||||
echo " > Current version is $CURRENT_VERSION"
|
||||
echo " > Setting new version to $NEXT_VERSION"
|
||||
|
||||
uvx poetry version "$1"
|
||||
NEXT_VERSION=$(uvx poetry version -s)
|
||||
# Manually update version in pyproject.toml
|
||||
sed -i '' "s/^version = .*/version = \"${NEXT_VERSION}\"/" pyproject.toml
|
||||
|
||||
echo " > leggen bumped to $NEXT_VERSION"
|
||||
echo " > Version bumped to $NEXT_VERSION"
|
||||
echo "Updating CHANGELOG.md"
|
||||
git-cliff --unreleased --tag "$NEXT_VERSION" --prepend CHANGELOG.md > /dev/null
|
||||
|
||||
echo " > Commiting changes and adding git tag"
|
||||
git add pyproject.toml CHANGELOG.md
|
||||
git add pyproject.toml CHANGELOG.md uv.lock
|
||||
git commit -m "chore(ci): Bump version to $NEXT_VERSION"
|
||||
git tag -a "$NEXT_VERSION" -m "$NEXT_VERSION"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user