funquail/scripts/set-api-build-metadata.sh

26 lines
658 B
Bash
Raw Normal View History

2022-11-24 21:14:59 +01:00
#!/usr/bin/env bash
# Given a commit hash, this script will update the version in api/pyproject.toml
# The version must follow the pep440 specification https://peps.python.org/pep-0440/
2022-11-24 21:14:59 +01:00
set -eu
error() {
echo >&2 "error: $*"
exit 1
}
2022-11-24 21:14:59 +01:00
command -v git > /dev/null || error "git command not found!"
command -v poetry > /dev/null || error "poetry command not found!"
# We assume this script only runs in a git repository
cd "$(git rev-parse --show-toplevel)/api"
COMMIT_SHA="$1"
CURRENT_VERSION="$(poetry version --short)"
CURRENT_VERSION="${CURRENT_VERSION%%.dev*}"
VERSION_SUFFIX="dev+$COMMIT_SHA"
poetry version "$CURRENT_VERSION-$VERSION_SUFFIX"