60 lines
2.0 KiB
YAML
60 lines
2.0 KiB
YAML
include:
|
|
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
|
|
|
|
stages:
|
|
- prepare
|
|
- build
|
|
|
|
build:
|
|
stage: build
|
|
script:
|
|
- env | sort
|
|
|
|
changelog:
|
|
stage: prepare
|
|
image:
|
|
name: orhunp/git-cliff:latest
|
|
entrypoint: [ "" ]
|
|
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
|
|
script:
|
|
- '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 jq curl'
|
|
script: |
|
|
echo "Project: ${CI_PROJECT_ID}"
|
|
echo "Token: ${CI_JOB_TOKEN}"
|
|
MRS=$(curl -s -H "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/merge_requests?state=opened&source_branch=next-release")
|
|
echo "${MRS}"
|
|
MR=$(echo "${MRS} | jq ".[].id")
|
|
if [ -n "${MR}" ]; then
|
|
curl -s -X POST -H "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/repository/branches?branch=next-release&ref=${CI_DEFAULT_BRANCH}"
|
|
fi
|
|
BODY="$(jq --null-input -c --arg title "ci: prepare release $(cat VERSION)" --arg content "$(cat CHANGES.md | base64 -w0)" '{"branch": "next-release", "author_email": "releaser@unbound.se", "author_name": "Releaser", "content": $content, "commit_message": $title, "encoding": "base64"}')"
|
|
curl -X PUT \
|
|
-H "JOB-TOKEN: $CI_JOB_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
--data "${BODY}" \
|
|
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/repository/files/CHANGELOG%2Emd"
|
|
rules:
|
|
- if: $CI_DEFAULT_BRANCH == $CI_COMMIT_BRANCH
|