Commit 0a58a672 authored by Michael Tesch's avatar Michael Tesch
Browse files

Fix auto-tag to use API, bump to v0.7.1

parent 8368ce46
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -97,19 +97,24 @@ pages:
    when: manual
    allow_failure: true

# Auto-tag when version in CMakeLists.txt is newer than latest git tag
# Auto-tag when version in CMakeLists.txt is newer than latest git tag.
# Uses the API to create the tag so that a tag pipeline is triggered.
auto-tag:
  stage: tag
  image: curlimages/curl:latest
  script:
  - dnf install -y git
  - VERSION=$(sed -n 's/.*VERSION \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' CMakeLists.txt)
  - |
    if git ls-remote --tags origin "refs/tags/v${VERSION}" | grep -q .; then
    EXISTING=$(curl -s --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
      "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/repository/tags/v${VERSION}" \
      | grep -c '"name"') || true
    if [ "$EXISTING" -gt 0 ]; then
      echo "Tag v${VERSION} already exists, skipping"
    else
      echo "Creating tag v${VERSION}"
      git tag "v${VERSION}"
      git push "https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "v${VERSION}"
      curl -s --fail --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
        --request POST \
        "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/repository/tags?tag_name=v${VERSION}&ref=${CI_COMMIT_SHA}"
    fi
  rules:
  - if: $CI_COMMIT_TAG
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
#
cmake_minimum_required (VERSION 3.14)
project (cppduals
  VERSION 0.7.0
  VERSION 0.7.1
  LANGUAGES C CXX
  )
include (GNUInstallDirs)