#!/bin/sh

OLD_VERSION_TAG=$1
OLD_VERSION=$(echo "$OLD_VERSION_TAG" | cut -c 2-)
NEW_VERSION=$(echo "$2" | cut -c 2-)

# replace version in pyproject.toml
sed -i "s/version = \"$OLD_VERSION\"/version = \"$NEW_VERSION\"/" pyproject.toml
uv sync
git add pyproject.toml uv.lock

# generate changelog entries from git
gbp dch --git-author --id-length=7 --since="$OLD_VERSION_TAG" --new-version="$NEW_VERSION" --ignore-branch

# copy release from last version
EDITOR=true dch -r --no-force-save-on-release

git add debian/changelog

git commit -m "prepare for v$NEW_VERSION release"
