From 89b5d406493a74e8eaf23d21a1ba2072cf6b9e6f Mon Sep 17 00:00:00 2001 From: Tom Teichler <tom.teichler@teckids.org> Date: Sun, 15 Nov 2020 13:00:38 +0100 Subject: [PATCH] Configure deployment to pypi registry --- .gitlab-ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1224312..544495e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,49 @@ include: - - project: "AlekSIS/official/AlekSIS" - file: /ci/general.yml - project: "AlekSIS/official/AlekSIS" file: /ci/test.yml - project: "AlekSIS/official/AlekSIS" file: /ci/build_dist.yml + +image: registry.edugit.org/teckids/team-sysadmin/docker-images/python-pimped:latest + +stages: + - test + - build + - deploy + +variables: + GIT_SUBMODULE_STRATEGY: recursive + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + FF_NETWORK_PER_BUILD: "true" + POETRY_REPOSITORIES_GITLAB_URL: "$CI_API_V4_URL/projects/${CI_PROJECT_ID}/packages/pypi" + POETRY_HTTP_BASIC_GITLAB_USERNAME: ticdesk + POETRY_HTTP_BASIC_GITLAB_PASSWORD: "$TICDESK_PUBLISH_TOKEN" + POETRY_PYPI_TOKEN_PYPI: "$TICDESK_PUBLISH_TOKEN" + +cache: + key: + files: + - poetry.lock + - pyproject.toml + paths: + - .cache/pip + - .tox + +deploy_pypi: + stage: deploy + script: + - if [ $CI_COMMIT_REF_NAME = master ]; then + poetry version $(poetry version | cut -d" " -f2)+$(date --date=${CI_COMMIT_TIMESTAMP} +%Y%m%d%H%M%S).${CI_COMMIT_SHORT_SHA} ; + elif [ x$CI_COMMIT_REF_NAME = x$CI_COMMIT_TAG ]; then + if ! [ "$(poetry version | cut -d" " -f2)" = $CI_COMMIT_REF_NAME ]; then + echo "Package version does not match tag. Aborting build of tag!" >/dev/fd/2 ; + exit 1 ; + fi ; + fi + - poetry publish -r gitlab + - if [ x$CI_COMMIT_REF_NAME = x$CI_COMMIT_TAG ]; then + poetry publish -r gitlab; + fi + only: + - master + - tags -- GitLab