Last active
March 4, 2023 19:53
-
-
Save echu/8a2bde80d5c8ba221ea428d1e4219d4a to your computer and use it in GitHub Desktop.
Turning `git describe` into acceptable PyPi version strings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assumes releases are tagged with "vMAJOR.MINOR.PATCH" (semver) | |
# The first sed removes the leading "v" (this step is not entirely necessary) | |
# The second sed uses the "number of commits since tag" to create a dev version and uses the sha as the "local version" | |
# | |
# If the second sed fails, it will just print the returns of the first sed | |
# | |
# Sample output: | |
# 0.3.0.dev1+g7a45b05 | |
# 0.3.0.dev3+g8418ac6.dirty | |
# 2.7.1rc2.dev17.dirty | |
git describe --tags --always --dirty=.dirty | | |
sed 's/v\(.*\)/\1/' | | |
sed 's/\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)\(rc[0-9]*\)\{0,1\}-\([0-9][0-9]*\)-\(g.*\)/\1\2.dev\3+\4/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment