From d11236dabcf707b7fc6ebf1d60adfba0acdca78e Mon Sep 17 00:00:00 2001 From: Tim Kreuzer <t.kreuzer@fz-juelich.de> Date: Mon, 22 Apr 2024 15:38:34 +0200 Subject: [PATCH] Update .gitlab-ci.yml --- .gitlab-ci.yml | 67 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2270db1..826cd08 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,6 @@ stages: - - pypi + - prepare-release + - release workflow: rules: @@ -7,13 +8,71 @@ workflow: - when: never pypi: - stage: pypi + stage: release image: - name: python:3.11-alpine3.18 + name: python:alpine before_script: - pip install twine build script: - python -m build - twine upload -u __token__ -p ${PYPI_JUPYTERJSC_TOKEN} dist/* rules: - - if: $CI_COMMIT_TAG + - if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/' + +testpypi: + stage: release + image: + name: python:alpine + before_script: + - pip install twine build + script: + - python -m build + - twine upload --repository testpypi -u __token__ -p ${TESTPYPI_JUPYTERJSC_TOKEN} dist/* + rules: + - if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+(-.+)$/' + + +### +# +# Prepare release notes +# +### + +prepare_job: + stage: prepare-release + image: alpine:latest + rules: + - if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/' + script: + - apk add curl jq + - 'curl -H "PRIVATE-TOKEN: $CI_API_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=$CI_COMMIT_TAG" | jq -r .notes > release_notes.md' + - 'curl -H "PRIVATE-TOKEN: $CI_API_TOKEN" -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=$CI_COMMIT_TAG"' + artifacts: + paths: + - release_notes.md + +### +# +# Create release +# +### + +release_job: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + needs: + - job: prepare_job + artifacts: true + rules: + - if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/' + script: + - echo "Creating release" + release: + name: 'Release $CI_COMMIT_TAG' + description: release_notes.md + tag_name: '$CI_COMMIT_TAG' + ref: '$CI_COMMIT_SHA' + assets: + links: + - name: 'jupyterhub-unicorespawner python package $CI_COMMIT_TAG' + url: "https://pypi.org/project/jupyterhub-unicorespawner/${CI_COMMIT_TAG}/" -- GitLab