Created
April 13, 2023 08:41
-
-
Save approximatenumber/3e8dbddb8c261bb04b5d8e8d6ddba900 to your computer and use it in GitHub Desktop.
This file contains 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
# dumb function to replace setuptools-scm in python packaging | |
get_version () { | |
if hash docker 2>/dev/null; then | |
git_version=$(docker run --rm -v $(pwd):/git alpine/git describe --tags --long) | |
else | |
git_version=$(git describe --tags --long) | |
fi | |
tag=$(echo ${git_version} | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') | |
dev=$(echo ${git_version} | grep -oE '\-[0-9]+\-' | tr -d '-') | |
hash=$(echo ${git_version} | grep -oE '\-[a-z0-9]+$' | tr -d '-') | |
if [ $dev -eq "0" ]; then | |
version="$tag" | |
else | |
version="$tag.dev$dev+$hash" | |
fi | |
echo $version | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment