Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit dce17b2

Browse files
authored
fix: auto-bump release version on main (#38)
Signed-off-by: Michael Kantor <6068672+kantorcodes@users.noreply.github.com>
1 parent e16369e commit dce17b2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,22 @@ jobs:
4343
id: version
4444
env:
4545
GITHUB_REF: ${{ github.ref }}
46-
GITHUB_RUN_NUMBER: ${{ github.run_number }}
46+
GITHUB_EVENT_NAME: ${{ github.event_name }}
4747
run: |
4848
BASE_VERSION=$(python3 -c "import tomllib; p=tomllib.load(open('pyproject.toml','rb')); print(p['project']['version'])")
4949
VERSION="$BASE_VERSION"
5050
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
5151
VERSION="${GITHUB_REF#refs/tags/v}"
52+
elif [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REF" == "refs/heads/main" ]]; then
53+
LAST_TAG=$(git tag --list 'v*' --sort=-version:refname | head -n1)
54+
if [[ -n "$LAST_TAG" ]]; then
55+
IFS=. read -r MAJOR MINOR PATCH <<< "${LAST_TAG#v}"
56+
if [[ -z "$MAJOR" || -z "$MINOR" || -z "$PATCH" ]]; then
57+
echo "Unsupported release tag format: $LAST_TAG" >&2
58+
exit 1
59+
fi
60+
VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
61+
fi
5262
fi
5363
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
5464
echo "Computed version: $VERSION"

0 commit comments

Comments
 (0)