This script exists to compute the 'monoversion' of the repo. The monoversion is designed to represent in a somewhat human readable format what commit was released and roughly what repository state that represents.
This script is intended for use under Bazel as a --workspace_status_command
,
so that we can build artifacts out of Bazel which include a somewhat meaningful
version numbers.
Monoversion versions are formatted as follows
let y = <year>
w = <week>
cw = <commits since first commit of the week to the merge base>
cb = <commits since the merge base>
id = <sha7 of HEAD>
marker = ".dirty" if `git status --porcelain` else ""
in
f"{y}.{w}.{cw}" + f"-{cb}.{id:11}{marker}" if cb > 0 else ""
- Compliant SemVer version https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions
- Sorts by date and sequence of commits to
main
under PyPi/Maven/Semver comparison - Releases not from
main
are immediately obvious because they aren't+0
and are tagged with the commit - If a branch is rebased the
main
stem will change but the sequence will remain - The current date is not a factor; the only consideration is commit dates
- Dirty states are explicitly marked
2024.23.1
The 23rd week of 2024, 1st commit of the week.2024.28.52-1.fad96ae6fa8
The 28th week of 2024, 52 commits into the week, one commit into a branch.2024.28.46-0.9aae26a05be.dirty
The 28th week of 2024, 46 commits since the first commit of the week, +0 (on main), last commit9aae26a05be
, dirty.
Somewhat inspired by https://blog.aspect.build/versioning-releases-from-a-monorepo Somewhat inspired by https://calver.org/