Skip to content

Version fractional-indexing from git tags instead of committing a bump - #4

Merged
gil-doesit merged 3 commits into
mainfrom
gil/version-from-tags
Nov 13, 2026
Merged

gil-doesit merged 3 commits into
mainfrom
gil/version-from-tags

Conversation

@gil-doesit

@gil-doesit gil-doesit commented Nov 4, 2026 •

Copy link
Copy Markdown

Overview

The next release of fractional-indexing will fail whenever someone bumps the version. The release workflow pushes a version-bump commit, and the org ruleset has rejected unsigned commits on main since 23 Oct. Both releases so far, v1.0.0 and v1.1.0, ran before the ruleset.

The version now lives only in the vX.Y.Z git tags, read by hatch-vcs, so nothing commits to main. This is path A from the signed-commits rollout, as in Doist/todoist-id-python#79.

Changes

  • Releases stay manual. The bump input is now patch, minor or major, and the workflow works out the next version from the latest tag.
  • The none option is gone. "Release the version in pyproject.toml" no longer means anything.
  • The workflow refuses to run off main, to create a tag that already exists, to release a commit that already has a release tag, or to release code older than the latest tag.
  • The build sets the version from the tag and checks the wheel's Version: before it publishes.
  • The GitHub release tags the released commit (github.sha). It still runs after the publish, so a failed publish leaves no tag behind.
  • Only vX.Y.Z tags count. The legacy 0.1.x tags and the httpie upstream's tags (such as 4.0.0) never set the version.
  • __version__ now reads the installed package metadata, which also fixes it saying 1.0.0. It falls back to 0.0.0 when the package isn't installed, as in test.yml.
  • uv.lock drops the package's own version line. A newer uv also moved its revision from 3 to 5.
  • Unrelated: the test matrix now runs on ubuntu-24.04. ubuntu-latest is now 26.04, which has no setup-python builds for 3.8 or 3.9 (failed run).

Note

main is still at v1.1.0. The first release after merge should be 1.1.1, containing only this PR.

Testing

  • The version step, run against the repo's tags in a scratch clone, gives 1.1.1 for patch, 1.2.0 for minor and 2.0.0 for major.
  • The same step refuses a run on the v1.1.0 commit, a run on the older v1.0.0 commit, and a tag that already exists on the remote.
  • With decoy 4.0.0 and 0.1.9 tags on HEAD, the build version still comes from v1.1.0.
  • SETUPTOOLS_SCM_PRETEND_VERSION=1.1.1 uv build gives a wheel with Version: 1.1.1, and __version__ is 1.1.1 once installed.
  • The tests pass both with the package installed and in the test.yml setup, without it.
  • Not run: the workflow itself. actionlint passes. The first real run is the next manual release.
  • Not checked: whether the ruleset also covers tags. If it does, the release step fails after the publish.

References

  • Signed-commits rollout thread, which lists fractional-indexing-python for path A.
  • Doist/todoist-id-python#79, the same change for todoist-id-python.

The org ruleset now rejects unsigned commits on `main`, so the release
workflow can no longer push its `chore: bump version` commit. The version
now comes from the `v*` tags through hatch-vcs, matched strictly so the
legacy `0.1.x` tags and the upstream fork's tags never count. The release
works out the next version from the latest tag, builds with it, and tags
the released commit, so nothing is committed. `__version__` reads the
installed metadata, which also fixes it still saying 1.0.0.
@gil-doesit gil-doesit added the 🙋 Ask PR requires passing checks and independent human review before merge. label Nov 4, 2026
`ubuntu-latest` now resolves to Ubuntu 26.04, and `actions/setup-python`
has no Python 3.8 or 3.9 builds for it, so those two jobs fail before any
test runs. The package still supports 3.8, so the tests stay on 24.04 until
the 3.8 and 3.9 support is dropped on purpose.
@gil-doesit
gil-doesit marked this pull request as ready for review November 4, 2026 10:06

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR moves fractional-indexing's versioning from a committed bump to deriving it from vX.Y.Z git tags via hatch-vcs, reworks the release workflow with tag-based guards and build-time version checks, and switches __version__ to package metadata with a 0.0.0 fallback.

Few things worth tightening:

  • CI never exercises the installed __version__ path — test.yml only runs pytest uninstalled, so every run tests the 0.0.0 fallback. Adding a pip install . step in one matrix job and asserting __version__ != '0.0.0' would catch any drift between the hardcoded package name in fractional_indexing.py and the published name, which the release workflow's wheel Version: grep wouldn't catch.

I also included a few optional follow-up notes in the details below.

Optional follow-up notes (3)
  • P3 .github/workflows/release.yml:89: This remote check only verifies the computed v$NEXT_VERSION; it doesn't ensure the local LATEST_TAG used to compute that version is still the newest release tag on the remote. If a newer tag (say v1.2.0) is pushed after checkout, LATEST_TAG stays v1.1.0, this run computes v1.1.1, and ls-remote for v1.1.1 passes even though the run would publish an older version than the remote's latest. Derive LATEST_TAG from git ls-remote --tags origin (filtered and sort -V) instead of the local clone, or additionally check that no remote vX.Y.Z tag is newer than $LATEST_TAG.
  • P3 .github/workflows/release.yml:56: The RELEASE_TAG regex re-declares the "only vX.Y.Z tags are releases" rule that [tool.hatch.version] already owns in pyproject.toml (tag-pattern and describe_command). The two copies already disagree: this regex rejects leading zeros, while pyproject's \d+ pattern accepts v01.2.3. Keep one source of truth, or at least make both patterns identical, so a future tag can't be treated as a release by one and ignored by the other.
  • P3 .github/workflows/release.yml:89: git ls-remote --exit-code exits 2 when the tag is absent, but any other non-zero exit (network failure, auth error) lands on the same if and is treated as "tag doesn't exist", silently skipping the guard and publishing anyway. Only exit code 2 means "safe to proceed": bash if git ls-remote --exit-code --tags origin "refs/tags/v$NEXT_VERSION" > /dev/null; then echo "::error::Tag v$NEXT_VERSION already exists." exit 1 elif [ $? -ne 2 ]; then echo "::error::Could not check remote tags." exit 1 fi Otherwise a transient failure re-publishes the same version to CodeArtifact before the later tag-creation step fails.

Share Feedback • Review Logs

Comment thread .github/workflows/test.yml Resolved

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR moves fractional-indexing's versioning from a committed bump to deriving it from vX.Y.Z git tags via hatch-vcs, reworks the release workflow with tag-based guards and build-time version checks, and switches __version__ to package metadata with a 0.0.0 fallback.

Few things worth tightening:

  • CI never exercises the installed __version__ path — test.yml only runs pytest uninstalled, so every run tests the 0.0.0 fallback. Adding a pip install . step in one matrix job and asserting __version__ != '0.0.0' would catch any drift between the hardcoded package name in fractional_indexing.py and the published name, which the release workflow's wheel Version: grep wouldn't catch.

I also included a few optional follow-up notes in the details below.

Optional follow-up notes (3)
  • P3 .github/workflows/release.yml:89: This remote check only verifies the computed v$NEXT_VERSION; it doesn't ensure the local LATEST_TAG used to compute that version is still the newest release tag on the remote. If a newer tag (say v1.2.0) is pushed after checkout, LATEST_TAG stays v1.1.0, this run computes v1.1.1, and ls-remote for v1.1.1 passes even though the run would publish an older version than the remote's latest. Derive LATEST_TAG from git ls-remote --tags origin (filtered and sort -V) instead of the local clone, or additionally check that no remote vX.Y.Z tag is newer than $LATEST_TAG.
  • P3 .github/workflows/release.yml:56: The RELEASE_TAG regex re-declares the "only vX.Y.Z tags are releases" rule that [tool.hatch.version] already owns in pyproject.toml (tag-pattern and describe_command). The two copies already disagree: this regex rejects leading zeros, while pyproject's \d+ pattern accepts v01.2.3. Keep one source of truth, or at least make both patterns identical, so a future tag can't be treated as a release by one and ignored by the other.
  • P3 .github/workflows/release.yml:89: git ls-remote --exit-code exits 2 when the tag is absent, but any other non-zero exit (network failure, auth error) lands on the same if and is treated as "tag doesn't exist", silently skipping the guard and publishing anyway. Only exit code 2 means "safe to proceed": bash if git ls-remote --exit-code --tags origin "refs/tags/v$NEXT_VERSION" > /dev/null; then echo "::error::Tag v$NEXT_VERSION already exists." exit 1 elif [ $? -ne 2 ]; then echo "::error::Could not check remote tags." exit 1 fi Otherwise a transient failure re-publishes the same version to CodeArtifact before the later tag-creation step fails.

Share Feedback • Review Logs

Comment thread .github/workflows/test.yml Resolved
The release job asks the remote whether the next tag already exists, but
`git ls-remote --exit-code` exits 2 for a missing tag and 128 when the
lookup itself fails, and both counted as "missing". A network or auth
failure skipped the check silently. Only exit 2 lets the release continue
now.

The tests run without the package installed, so `__version__` always took
the 0.0.0 fallback, and a mismatch between the name it looks up and the
published name would reach users unnoticed. CI installs the package and
fails if the version still falls back. The hatch-vcs `tag-pattern` uses
release.yml's pattern, so both agree on which tags are releases.
@gil-doesit

Copy link
Copy Markdown
Author

ec136b0 also applies the ls-remote exit-code fix and gives pyproject's tag-pattern the same strict pattern as release.yml. I'm leaving the remote-latest-tag note as it is: the deploy concurrency group already runs releases one at a time, so a newer tag could only appear if someone pushed one by hand in the seconds between checkout and the check. Posted by a 🤖

@gil-doesit
gil-doesit requested review from amleczko and kumarnmanoj and removed request for kumarnmanoj November 5, 2026 09:43

@amleczko amleczko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. The two rulesets on this repo target branches only, so tag creation after the publish is not blocked.

@gil-doesit
gil-doesit merged commit c923447 into main Nov 13, 2026
13 checks passed
@gil-doesit
gil-doesit deleted the gil/version-from-tags branch November 13, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙋 Ask PR requires passing checks and independent human review before merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants