Commit 3df079e9 authored by Bart Kamphorst's avatar Bart Kamphorst
Browse files

feat: semantic-version-tag-checker

parent 63617d20
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -2,6 +2,32 @@
include:
  - local: project-automation/generic.yaml

semantic-version-tag-checker:
  stage: .pre
  image:
    name: docker.io/docker:git
    entrypoint: [""]
  script:
    - echo "[*] Validating that a semantic version tag is already available on 'origin/${CI_DEFAULT_BRANCH}' to prevent semantic-release from creating the initial release (v1.0.0). You can disable this check by setting the variable
      ALLOW_INITIAL_SEMANTIC_RELEASE."
    - |
      if [ "$(git rev-parse --is-shallow-repository)" != "false" ]; then
        echo "[*] Repository is shallow. Unshallowing."
        git fetch --unshallow -q
      fi
    - |
      if ! $( (git tag --merged origin/${CI_DEFAULT_BRANCH} ||:) | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]and-some-more$'); then # prevent SIGPIPE (exit 141) if grep exists before piped input is finished, see https://unix.stackexchange.com/a/582850/558271
        echo "[!] No semantic version tag is available in the history of 'origin/${CI_DEFAULT_BRANCH}'. Please first create a tag (e.g. 'v0.0.1') on 'origin/${CI_DEFAULT_BRANCH}' and rebase (intermediate branches and) the current branch on that."
        exit 1
      else
        echo "[+] Semantic version tags are available in the history of 'origin/${CI_DEFAULT_BRANCH}'."
      fi
  rules:
    - if: $ALLOW_INITIAL_SEMANTIC_RELEASE != null
      when: never
    - !reference [.release:rules, rules]
    - allow_failure: true

find-next-release:
  extends: .release:rules
  stage: build
@@ -15,6 +41,9 @@ find-next-release:
    - semantic-release --dry-run --no-ci
    - echo "TBUMP_NEXT_VERSION=$(cat .VERSION 2>/dev/null || echo "[!] No new
      release" 1>&2)" > TBUMP_NEXT_VERSION.env
  needs:
    - job: semantic-version-tag-checker
      optional: true
  artifacts:
    reports:
      dotenv: TBUMP_NEXT_VERSION.env
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
      exists:
        - tbump.toml
        - pyproject.toml
    - when: never
# - when: never is implicit so that the configuration can be extended elsewhere

.release:install:
  script:
+3 −0
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@ semantic-release:
    - export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}"
    - semantic-release --version
    - semantic-release ${SEMANTIC_RELEASE_EXTRA_ARGS}
  needs:
    - job: semantic-version-tag-checker
      optional: true
  artifacts:
    paths:
      - .releaserc