diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c10700f6f69155c2e773872a01aaf89919caae6b..194125609689c7545d6b3b96a59f1768f7f59bb9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -240,6 +240,7 @@ docker_release: - cp -r front/dist api/frontend - cd api script: + - if [ "$CI_COMMIT_REF_NAME" == "develop" ]; then ./scripts/set-api-build-metadata $CI_COMMIT_SHORT_SHA; fi); - docker build -t $IMAGE . - docker push $IMAGE only: @@ -257,6 +258,7 @@ build_api: paths: - api script: + - if [ "$CI_COMMIT_REF_NAME" == "develop" ]; then ./scripts/set-api-build-metadata $CI_COMMIT_SHORT_SHA; fi); - chmod -R 750 api - echo Done! only: diff --git a/scripts/set-api-build-metadata.sh b/scripts/set-api-build-metadata.sh new file mode 100755 index 0000000000000000000000000000000000000000..62c826caacd7a6085c2783f381c84724ae037fc0 --- /dev/null +++ b/scripts/set-api-build-metadata.sh @@ -0,0 +1,9 @@ +#!/bin/bash -eu +# given a commit hash, will append this to the version number stored +# in api/funkwhale_api/__init__.py + +commit=$1 +suffix="+git.$commit" +replace="__version__ = \"\1${suffix}\"" +file="api/funkwhale_api/__init__.py" +sed -i -E 's@__version__ = \"(.*)\"@'"$replace"'@' $file