diff --git a/changes/changelog.d/maintain-api-version-using-poetry.enhancement b/changes/changelog.d/maintain-api-version-using-poetry.enhancement new file mode 100644 index 000000000..339241f43 --- /dev/null +++ b/changes/changelog.d/maintain-api-version-using-poetry.enhancement @@ -0,0 +1 @@ +Maintain api version using poetry diff --git a/docs/developer_documentation/workflows/release.md b/docs/developer_documentation/workflows/release.md index 56af9da62..c1e585d2f 100644 --- a/docs/developer_documentation/workflows/release.md +++ b/docs/developer_documentation/workflows/release.md @@ -55,10 +55,12 @@ Once we're ready to release a new version of the software, we can use the follow nano CHANGELOG # Add these lists to the CHANGELOG ``` -7. Update the `__version__` variable to the next release version +7. Update the next release version ```sh - nano api/funkwhale_api/__init__.py + cd api + poetry version "$NEXT_RELEASE" + cd .. ``` 8. Commit all changes diff --git a/scripts/set-api-build-metadata.sh b/scripts/set-api-build-metadata.sh index 0ecbce59a..5c62f8756 100755 --- a/scripts/set-api-build-metadata.sh +++ b/scripts/set-api-build-metadata.sh @@ -1,13 +1,22 @@ #!/usr/bin/env bash -set -eux +# 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/ -# given a commit hash, will append this to the version number stored -# in api/funkwhale_api/__init__.py +set -eu -COMMIT=$1 -FILE="api/funkwhale_api/__init__.py" +error() { + echo >&2 "error: $*" + exit 1 +} -SUFFIX="\1+git.$COMMIT" -EXPR=$(printf 's@__version__ = "(.*)"@__version__ = "%s"@' "$SUFFIX") -sed -i -E "$EXPR" "$FILE" +command -v poetry > /dev/null || error "poetry command not found!" + +COMMIT_SHA="$1" + +CURRENT_VERSION="$(poetry version --short)" +CURRENT_VERSION="${CURRENT_VERSION%%.dev*}" + +VERSION_SUFFIX="dev+$COMMIT_SHA" + +poetry version "$CURRENT_VERSION.$VERSION_SUFFIX"