Skip to content

tooling: Add version bump target to Makefile.#237

Merged
nedseb merged 3 commits intomainfrom
tooling/make-bump
Mar 25, 2026
Merged

tooling: Add version bump target to Makefile.#237
nedseb merged 3 commits intomainfrom
tooling/make-bump

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 25, 2026

Summary

  • Configure semantic-release for automated versioning on merge to main
  • Automatic CHANGELOG.md generation, pyproject.toml version update, git tag, and GitHub release
  • Release rules: feat: → minor, fix:/perf:/refactor:/tooling: → patch, BREAKING CHANGE: → major
  • docs:/style:/test:/ci:/chore: commits do not trigger a release
  • Keep make bump as manual override with safety checks (main branch + clean tree)
  • Document release workflow in CONTRIBUTING.md

New files

  • .releaserc.json — semantic-release configuration
  • .github/workflows/release.yml — CI workflow triggered on push to main

Modified files

  • Makefile — add bump target with warning to prefer semantic-release
  • CONTRIBUTING.md — document automated and manual release workflows
  • package.json / package-lock.json — add @semantic-release/exec dependency

Closes #236

Copilot AI review requested due to automatic review settings March 25, 2026 09:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a release helper to standardize semantic version bumps via make bump, aligning repo tooling and documentation around a simple tagging workflow.

Changes:

  • Introduce make bump target that computes the next semver, updates pyproject.toml, commits, tags, and pushes.
  • Add safety checks (must be on main, working tree must be clean).
  • Document the release workflow in CONTRIBUTING.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
Makefile Adds a bump target to automate version updates, tagging, and pushing with safety checks.
CONTRIBUTING.md Documents how to run make bump and what it does.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile Outdated
Comment on lines +123 to +124
git tag "$$NEXT"; \
git push origin main "$$NEXT"; \
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a lightweight tag (git tag "$NEXT"), but the linked issue’s desired behavior calls for an annotated tag. If annotated tags are required for releases, switch to creating an annotated tag (and include a message), so metadata is preserved and git describe behaves as expected.

Copilot uses AI. Check for mistakes.
Comment thread Makefile Outdated
Comment on lines +104 to +125
@LAST=$$(git tag --sort=-v:refname | head -1); \
if [ -z "$$LAST" ]; then \
NEXT="v1.0.0"; \
else \
MAJOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f1); \
MINOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f2); \
PATCH=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f3); \
case "$(PART)" in \
major) MAJOR=$$((MAJOR + 1)); MINOR=0; PATCH=0 ;; \
minor) MINOR=$$((MINOR + 1)); PATCH=0 ;; \
patch) PATCH=$$((PATCH + 1)) ;; \
*) echo "Error: PART must be patch, minor or major."; exit 1 ;; \
esac; \
NEXT="v$$MAJOR.$$MINOR.$$PATCH"; \
fi; \
echo "$$LAST → $$NEXT"; \
sed -i "s/^version = \".*\"/version = \"$${NEXT#v}\"/" pyproject.toml; \
git add pyproject.toml; \
git commit -m "chore: Bump version to $$NEXT."; \
git tag "$$NEXT"; \
git push origin main "$$NEXT"; \
echo "Tag $$NEXT pushed to origin."
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this Makefile uses .ONESHELL, the long command chain starting here uses ; separators, so failures from sed, git commit, git tag, or git push may not stop the target (the final echo will still exit 0). Consider enabling fail-fast for this recipe (e.g., set -e at the start of the bump recipe or chaining critical commands with &&) so make bump reliably fails on errors and doesn't leave the repo in a partially-updated state.

Copilot uses AI. Check for mistakes.
Comment thread Makefile Outdated
NEXT="v$$MAJOR.$$MINOR.$$PATCH"; \
fi; \
echo "$$LAST → $$NEXT"; \
sed -i "s/^version = \".*\"/version = \"$${NEXT#v}\"/" pyproject.toml; \
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sed -i is not portable across GNU/BSD sed (e.g., macOS requires sed -i '' ...). Since this target is intended for contributors’ local environments, consider switching to a cross-platform edit approach (e.g., a small Python one-liner) or handling GNU vs BSD sed explicitly.

Suggested change
sed -i "s/^version = \".*\"/version = \"$${NEXT#v}\"/" pyproject.toml; \
VERSION=$${NEXT#v}; \
python - "$$VERSION" << 'PY'; \
import sys
import pathlib
import re
path = pathlib.Path("pyproject.toml")
text = path.read_text()
version = sys.argv[1]
text = re.sub(r'^version = ".*"$', f'version = "{version}"', text, count=1, flags=re.MULTILINE)
path.write_text(text)
PY

Copilot uses AI. Check for mistakes.
Comment thread Makefile
Comment on lines +108 to +117
MAJOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f1); \
MINOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f2); \
PATCH=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f3); \
case "$(PART)" in \
major) MAJOR=$$((MAJOR + 1)); MINOR=0; PATCH=0 ;; \
minor) MINOR=$$((MINOR + 1)); PATCH=0 ;; \
patch) PATCH=$$((PATCH + 1)) ;; \
*) echo "Error: PART must be patch, minor or major."; exit 1 ;; \
esac; \
NEXT="v$$MAJOR.$$MINOR.$$PATCH"; \
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bump logic assumes the latest tag is exactly v<major>.<minor>.<patch>. If the repo ever has non-semver tags (e.g., v1.2.3-rc1) or tags without a leading v, MAJOR/MINOR/PATCH parsing and arithmetic can fail. Add a validation step (regex match) and error out with a clear message when LAST isn't a supported format.

Suggested change
MAJOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f1); \
MINOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f2); \
PATCH=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f3); \
case "$(PART)" in \
major) MAJOR=$$((MAJOR + 1)); MINOR=0; PATCH=0 ;; \
minor) MINOR=$$((MINOR + 1)); PATCH=0 ;; \
patch) PATCH=$$((PATCH + 1)) ;; \
*) echo "Error: PART must be patch, minor or major."; exit 1 ;; \
esac; \
NEXT="v$$MAJOR.$$MINOR.$$PATCH"; \
if echo "$$LAST" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$$'; then \
MAJOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f1); \
MINOR=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f2); \
PATCH=$$(echo "$$LAST" | sed 's/^v//' | cut -d. -f3); \
case "$(PART)" in \
major) MAJOR=$$((MAJOR + 1)); MINOR=0; PATCH=0 ;; \
minor) MINOR=$$((MINOR + 1)); PATCH=0 ;; \
patch) PATCH=$$((PATCH + 1)) ;; \
*) echo "Error: PART must be patch, minor or major."; exit 1 ;; \
esac; \
NEXT="v$$MAJOR.$$MINOR.$$PATCH"; \
else \
echo "Error: latest tag '$$LAST' is not in supported format v<major>.<minor>.<patch>."; exit 1; \
fi; \

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 161cf42d89

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Makefile
Comment on lines +124 to +125
git push origin main "$$NEXT"; \
echo "Tag $$NEXT pushed to origin."
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fail bump target when git push errors

The bump recipe runs all release steps in one .ONESHELL block and ends with echo, so a failed git push (e.g., auth issue, network problem, or non-fast-forward) is masked and make bump still exits successfully. This can leave a local commit/tag that was never published while printing a success message, which is risky for release automation.

Useful? React with 👍 / 👎.

@nedseb
Copy link
Copy Markdown
Contributor Author

nedseb commented Mar 25, 2026

All 5 review comments addressed in b7d1ba1:

  1. Annotated tags — Switched to git tag -a "$NEXT" -m "Release $NEXT" for proper metadata.
  2. Fail-fast — Added set -e at the start of the recipe so any failure stops immediately.
  3. Portable sed — Replaced sed -i with a Python one-liner for cross-platform compatibility.
  4. Tag format validation — Added regex check on latest tag, errors out if not v<major>.<minor>.<patch>.
  5. Push error masking — Covered by set -e, a failed git push now stops the recipe with a non-zero exit.

@nedseb nedseb merged commit 60b1a55 into main Mar 25, 2026
3 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7d1ba1337

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Makefile
git add pyproject.toml; \
git commit -m "chore: Bump version to $$NEXT."; \
git tag -a "$$NEXT" -m "Release $$NEXT"; \
git push origin main "$$NEXT"; \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Push branch and tag atomically in bump target

The git push origin main "$$NEXT" call can partially update the remote: if main is accepted but the tag is rejected (for example because the tag already exists remotely or tag creation is restricted), the bump commit is published without its release tag. git push only guarantees all-or-nothing behavior when --atomic is used, so this target can leave the repository in an inconsistent release state even though it reports failure.

Useful? React with 👍 / 👎.

nedseb added a commit that referenced this pull request Mar 25, 2026
* tooling: Add version bump target to Makefile.

* tooling: Configure semantic-release for automated versioning.

* tooling: Address PR review comments on bump target.
@nedseb nedseb deleted the tooling/make-bump branch March 25, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tooling: Add version management (semantic-release + make bump).

2 participants