From ca6d4b6ea64dc43ea436753d207b4902b59168ca Mon Sep 17 00:00:00 2001 From: lanath Date: Thu, 14 Nov 2024 17:04:31 +0100 Subject: [PATCH] ci: tagging and releasing --- .gitlab-ci.yml | 37 +++++++++++++++++++++++++++++++++---- values.txt | 1 - version.txt | 2 +- 3 files changed, 34 insertions(+), 6 deletions(-) delete mode 100644 values.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa6c495..c910482 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,9 @@ test clearndr: image: git.stamus-networks.com:4567/devel/stamus-ctl/cli:main tags: - k8s + rules: + - if: $CI_COMMIT_BRANCH + when: on_success variables: DOCKER_HOST: tcp://docker:2376 DOCKER_TLS_CERTDIR: '/certs' @@ -50,9 +53,9 @@ tests: "${CI_PROJECT_DIR}/." -f "${CI_PROJECT_DIR}/Dockerfile" --build-arg "path=/tests" - -t "${CI_REGISTRY_IMAGE}/tests:${CI_COMMIT_SHORT_SHA}" + -t "${CI_REGISTRY_IMAGE}/tests:${CI_COMMIT_REF_NAME}" -t "${CI_REGISTRY_IMAGE}/tests:${CI_COMMIT_BRANCH}" - - docker push ${CI_REGISTRY_IMAGE}/tests:${CI_COMMIT_SHORT_SHA} + - docker push ${CI_REGISTRY_IMAGE}/tests:${CI_COMMIT_REF_NAME} - docker push ${CI_REGISTRY_IMAGE}/tests:${CI_COMMIT_BRANCH} @@ -74,9 +77,9 @@ clearndr: "${CI_PROJECT_DIR}/." -f "${CI_PROJECT_DIR}/Dockerfile" --build-arg "path=/clearndr" - -t "${CI_REGISTRY_IMAGE}/clearndr:${CI_COMMIT_SHORT_SHA}" + -t "${CI_REGISTRY_IMAGE}/clearndr:${CI_COMMIT_REF_NAME}" -t "${CI_REGISTRY_IMAGE}/clearndr:${CI_COMMIT_BRANCH}" - - docker push ${CI_REGISTRY_IMAGE}/clearndr:${CI_COMMIT_SHORT_SHA} + - docker push ${CI_REGISTRY_IMAGE}/clearndr:${CI_COMMIT_REF_NAME} - docker push ${CI_REGISTRY_IMAGE}/clearndr:${CI_COMMIT_BRANCH} release-to-github: @@ -94,3 +97,29 @@ release-to-github: - git branch --set-upstream-to github/next - git pull --rebase - git push github HEAD:next + + +create-tags: + stage: release + image: bitnami/git + allow_failure: true + rules: + - if: '$CI_COMMIT_BRANCH == "latest"' + when: on_success + script: + - git config --global user.email $GITLAB_USER_EMAIL + - git config --global user.name $GITLAB_USER_NAME + - tag=$(cat version.txt) + - git tag "$tag" + - git push --tags https://repo-token:$ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:main + +create release: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + rules: + - if: $CI_COMMIT_TAG + script: + - echo "running release_job" + release: + tag_name: '$CI_COMMIT_TAG' + description: '$CI_COMMIT_TAG' \ No newline at end of file diff --git a/values.txt b/values.txt deleted file mode 100644 index dc88186..0000000 --- a/values.txt +++ /dev/null @@ -1 +0,0 @@ -always \ No newline at end of file diff --git a/version.txt b/version.txt index 7bcd0e3..ea66673 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.0.2 \ No newline at end of file +0.0.1-rc1 \ No newline at end of file