FAQ | This is a LIVE service | Changelog

fix: release-it to read version from git tag

Part of #3 (closed)

While reading the documentation from @release-it/bumper (https://github.com/release-it/bumper), it says:

  • Use only the in option to read the version from this file in the release-it process.
  • Use only the out option to write the version that was determined by release-it to this file.
  • Use both to read and write the version property from/to this file.

And then reading the documentation of release-it:

How does release-it determine the latest version?

  • For projects with a package.json, its version will be used (see npm to skip this).
  • Otherwise, release-it uses the latest Git tag to determine which version should be released.
  • As a last resort, 0.0.0 will be used as the latest version.

My thinking initially was that it would take the version from the file it tries to write to. But this is not true for Python projects, it would pick the latest git tag. Because I specified in, release-it would bump the version again after it bumped it before.

This MR will probably fix this. We will only really know when we merge this though.

A dryrun on this branch shows:

% npx -p @release-it/bumper -p release-it -p @release-it/conventional-changelog release-it -d

$ git diff --quiet HEAD
$ git rev-parse --abbrev-ref HEAD
$ git config --get branch.fix-release-it.remote
$ git remote get-url origin
! git fetch
$ git rev-parse --abbrev-ref HEAD  [cached]
$ git describe --tags --match=* --abbrev=0
$ git symbolic-ref HEAD
$ git for-each-ref --format="%(upstream:short)" refs/heads/fix-release-it
$ git rev-parse --abbrev-ref HEAD  [cached]
$ git config --get branch.fix-release-it.remote  [cached]
$ git remote get-url origin  [cached]
! git fetch
$ git rev-parse --abbrev-ref HEAD  [cached]
$ git describe --tags --match=* --abbrev=0  [cached]

🚀 Let's release message-schemas (0.2.4...0.2.5)


Changelog:
## [0.2.5](https://gitlab.developers.cam.ac.uk/uis/devops/iam/activate-account/message-schemas/compare/0.2.4...0.2.5) (2025-03-18)
### Bug Fixes
* release-it to read version from git tag ([57a0b6b](https://gitlab.developers.cam.ac.uk/uis/devops/iam/activate-account/message-schemas/commit/57a0b6bfce64fb062964882f282a9f16af67e2ef))

$ Writing version to pyproject.toml
$ Writing version to generator-static/python/pyproject.toml
$ Writing changelog to CHANGELOG.md
$ git status --short --untracked-files=no

Empty changeset

! git add . --update
✔ Commit (chore(release): 0.2.5)? Yes
! git commit --message chore(release): 0.2.5
✔ Tag (0.2.5)? No
✔ Push? No
✔ Create a release on GitLab (0.2.5)? No
🏁 Done (in 12s.)
Edited by Sebastiaan ten Pas

Merge request reports

Loading