Skip to content

Commit b7d1ba1

Browse files
committed
tooling: Address PR review comments on bump target.
1 parent f19642a commit b7d1ba1

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,14 @@ bump: ## Create a version tag (PART=patch|minor|major, default: patch)
103103
@if [ -n "$$(git status --porcelain)" ]; then \
104104
echo "Error: working tree is not clean. Commit or stash changes first."; exit 1; \
105105
fi
106-
@LAST=$$(git tag --sort=-v:refname | head -1); \
106+
@set -e; \
107+
LAST=$$(git tag --sort=-v:refname | head -1); \
107108
if [ -z "$$LAST" ]; then \
108109
NEXT="v1.0.0"; \
109110
else \
111+
if ! echo "$$LAST" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$$'; then \
112+
echo "Error: latest tag '$$LAST' is not in supported format v<major>.<minor>.<patch>."; exit 1; \
113+
fi; \
110114
MAJOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f1); \
111115
MINOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f2); \
112116
PATCH=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f3); \
@@ -119,10 +123,11 @@ bump: ## Create a version tag (PART=patch|minor|major, default: patch)
119123
NEXT="v$$MAJOR.$$MINOR.$$PATCH"; \
120124
fi; \
121125
echo "$$LAST → $$NEXT"; \
122-
sed -i "s/^version = \".*\"/version = \"$${NEXT#v}\"/" pyproject.toml; \
126+
VERSION=$${NEXT#v}; \
127+
python3 -c "import re, pathlib; p=pathlib.Path('pyproject.toml'); p.write_text(re.sub(r'^version = \".*\"', 'version = \"$$VERSION\"', p.read_text(), count=1, flags=re.MULTILINE))"; \
123128
git add pyproject.toml; \
124129
git commit -m "chore: Bump version to $$NEXT."; \
125-
git tag "$$NEXT"; \
130+
git tag -a "$$NEXT" -m "Release $$NEXT"; \
126131
git push origin main "$$NEXT"; \
127132
echo "Tag $$NEXT pushed to origin."
128133

0 commit comments

Comments
 (0)