mirror of
https://github.com/elisiariocouto/leggen.git
synced 2026-01-30 17:28:29 +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
|
set -ef -o pipefail
|
||||||
|
|
||||||
@@ -13,23 +13,37 @@ check_command git
|
|||||||
check_command git-cliff
|
check_command git-cliff
|
||||||
check_command uv
|
check_command uv
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
# Get current date components
|
||||||
echo " > No semver verb specified, run release with <major|minor|patch> parameter."
|
YEAR=$(date +%Y)
|
||||||
exit 1
|
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
|
fi
|
||||||
|
|
||||||
CURRENT_VERSION=$(uvx poetry version -s)
|
NEXT_VERSION="${YEAR}.${MONTH}.${MICRO}"
|
||||||
|
CURRENT_VERSION=$(uv version --short)
|
||||||
|
|
||||||
echo " > Current version is $CURRENT_VERSION"
|
echo " > Current version is $CURRENT_VERSION"
|
||||||
|
echo " > Setting new version to $NEXT_VERSION"
|
||||||
|
|
||||||
uvx poetry version "$1"
|
# Manually update version in pyproject.toml
|
||||||
NEXT_VERSION=$(uvx poetry version -s)
|
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"
|
echo "Updating CHANGELOG.md"
|
||||||
git-cliff --unreleased --tag "$NEXT_VERSION" --prepend CHANGELOG.md > /dev/null
|
git-cliff --unreleased --tag "$NEXT_VERSION" --prepend CHANGELOG.md > /dev/null
|
||||||
|
|
||||||
echo " > Commiting changes and adding git tag"
|
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 commit -m "chore(ci): Bump version to $NEXT_VERSION"
|
||||||
git tag -a "$NEXT_VERSION" -m "$NEXT_VERSION"
|
git tag -a "$NEXT_VERSION" -m "$NEXT_VERSION"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user