diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e01d66a..8395e63 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ build: script: - env | sort -prepare_release: +changelog: stage: prepare image: name: orhunp/git-cliff:latest @@ -19,9 +19,33 @@ prepare_release: GIT_STRATEGY: clone # clone entire repo instead of reusing workspace GIT_DEPTH: 0 # avoid shallow clone to give cliff all the info it needs script: - - git-cliff --current > CHANGELOG.md + - 'git-cliff --bump --unreleased > CHANGES.md' + - 'git-cliff --bump > CHANGELOG.md' + - 'git-cliff --bumped-version 2>/dev/null > VERSION' artifacts: paths: + - CHANGES.md - CHANGELOG.md + - VERSION + rules: + - if: $CI_DEFAULT_BRANCH == $CI_COMMIT_BRANCH + +handle_mr: + stage: prepare + image: alpine:latest + needs: + - changelog + variables: + GIT_STRATEGY: clone # clone entire repo instead of reusing workspace + GIT_DEPTH: 0 # avoid shallow clone to give cliff all the info it needs + before_script: + - 'apk add --no-cache git jq curl' + - 'git config --global user.email "${GIT_USER_EMAIL:-$GITLAB_USER_EMAIL}"' + - 'git config --global user.name "${GIT_USER_NAME:-$GITLAB_USER_NAME}"' + script: + - 'git checkout -b next-release' + - 'git add CHANGELOG.md' + - 'git commit -m "ci: prepare release $(git-cliff --bumped-version 2>/dev/null)"' + - 'git push origin next-release --force' rules: - if: $CI_DEFAULT_BRANCH == $CI_COMMIT_BRANCH