diff --git a/pyproject.toml b/pyproject.toml index c09e7ed..1663868 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,16 +56,28 @@ build-backend = "setuptools.build_meta" [tool.setuptools.dynamic] version = { attr = "pytest_codspeed.__version__" } -[tool.hatch.envs.default] -python = "3.11" -features = ["lint", "test", "compat"] -[tool.hatch.envs.test] -features = ["test"] +[tool.bumpver] +current_version = "3.0.0" +version_pattern = "MAJOR.MINOR.PATCH[-TAG]" +commit_message = "Release v{new_version} 🚀" +tag_message = "Release v{new_version} 🚀" +tag_scope = "default" +allow_dirty = false +pre_commit_hook = "./scripts/pre-release.sh" +post_commit_hook = "./scripts/post-release.sh" +commit = true +tag = false +push = false + + +[tool.bumpver.file_patterns] +"pyproject.toml" = ['current_version = "{version}"'] +"src/pytest_codspeed/__init__.py" = [ + '__version__ = "{pep440_version}"', + '__semver_version__ = "{version}"', +] -[[tool.hatch.envs.test.matrix]] -python = ["3.9", "3.10", "3.11", "3.12", "3.13"] -features = ["compat", "test"] [tool.mypy] python_version = "3.12" diff --git a/scripts/post-release.sh b/scripts/post-release.sh new file mode 100755 index 0000000..552b62a --- /dev/null +++ b/scripts/post-release.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +VERSION=v$BUMPVER_NEW_VERSION + +git tag v$VERSION -m "Release v$VERSION 🚀" +git push --follow-tags diff --git a/scripts/pre-release.sh b/scripts/pre-release.sh new file mode 100755 index 0000000..af7845f --- /dev/null +++ b/scripts/pre-release.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +VERSION=v$BUMPVER_NEW_VERSION + +# Skip alpha/beta/rc changelog generation +if [[ $VERSION == *"alpha"* ]] || [[ $VERSION == *"beta"* ]] || [[ $VERSION == *"rc"* ]]; then + echo "Skipping changelog generation for alpha/beta/rc release" +else + echo "Generating changelog for $VERSION" + # Check that GITHUB_TOKEN is set + if [ -z "$GITHUB_TOKEN" ]; then + echo "GITHUB_TOKEN is not set. Trying to fetch it from gh" + GITHUB_TOKEN=$(gh auth token) + fi + git cliff -o CHANGELOG.md --tag $VERSION + git add CHANGELOG.md +fi + +uv sync +git add uv.lock diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index 6db80b7..0000000 --- a/scripts/release.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# Usage: ./scripts/release.sh -set -ex - -if [ $# -ne 1 ]; then - echo "Usage: ./release.sh " - exit 1 -fi - -hatch version $1 -python scripts/generate_semver.py -NEW_VERSION=$(hatch version) -git add src/pytest_codspeed/__init__.py -# Fail if there are any unstaged changes left -git diff --exit-code -git commit -am "Release v$NEW_VERSION 🚀" -git tag v$NEW_VERSION -m "Release v$NEW_VERSION 🚀" -git push --follow-tags