chore: add __version__ and automated tools to update it

- also add a checker to verify that versions are in sync
This commit is contained in:
Arthur Meyre
2021-09-30 16:21:15 +02:00
parent edcbc0cffd
commit 6fc6991839
5 changed files with 102 additions and 3 deletions

View File

@@ -0,0 +1,60 @@
#!/usr/bin/env bash
VERSION_TO_SET=
SRC_DIR=
while [ -n "$1" ]
do
case "$1" in
"--version" )
shift
VERSION_TO_SET="$1"
;;
"--src-dir" )
shift
SRC_DIR="$1"
;;
*)
echo "Unknown param : $1"
exit 1
;;
esac
shift
done
if [[ "${VERSION_TO_SET}" == "" ]]; then
echo "--version is required. Aborting"
exit 1
fi
if [[ "${SRC_DIR}" == "" ]]; then
echo "--src-dir is required. Aborting"
exit 1
fi
rx='^(v)?([0-9]+\.){2}[0-9]+(rc[0-9]+)?$'
if [[ ! "${VERSION_TO_SET}" =~ $rx ]]; then
echo "ERROR: Unable to validate version: '${VERSION_TO_SET}'"
exit 1
fi
echo "INFO: Version ${VERSION_TO_SET}"
VERSION_TO_SET="${VERSION_TO_SET/v/}"
echo "${VERSION_TO_SET}"
poetry version "${VERSION_TO_SET}"
VERSION_FILE="${SRC_DIR}/version.py"
rm "${VERSION_FILE}"
{
echo '"""Package version module."""'
echo '# Auto-generated by "make set_version" do not modify'
echo ''
echo "__version__ = \"${VERSION_TO_SET}\""
} >> "${VERSION_FILE}"