feat: add MR description with release changes

This commit is contained in:
2024-10-05 11:50:29 +02:00
parent c4b4b66692
commit 4112728e1e
+7 -2
View File
@@ -27,11 +27,13 @@ changelog:
GIT_DEPTH: 0 # avoid shallow clone to give cliff all the info it needs GIT_DEPTH: 0 # avoid shallow clone to give cliff all the info it needs
script: script:
- 'echo "Generating changelog"' - 'echo "Generating changelog"'
- 'git-cliff --bump --unreleased > CHANGES.md'
- 'git-cliff --bump > CHANGELOG.md' - 'git-cliff --bump > CHANGELOG.md'
- 'echo "Bumping version"' - 'echo "Bumping version"'
- 'git-cliff --bumped-version 2>/dev/null > VERSION' - 'git-cliff --bumped-version 2>/dev/null > VERSION'
artifacts: artifacts:
paths: paths:
- CHANGES.md
- CHANGELOG.md - CHANGELOG.md
- VERSION - VERSION
rules: rules:
@@ -60,6 +62,7 @@ handle_mr:
MR=$(echo "${MRS}" | jq ".[].iid") MR=$(echo "${MRS}" | jq ".[].iid")
BRANCH=$(echo "${BRANCHES}" | jq ".[].name") BRANCH=$(echo "${BRANCHES}" | jq ".[].name")
TITLE="chore(release): prepare for $(cat VERSION)" TITLE="chore(release): prepare for $(cat VERSION)"
DESCRIPTION="$(cat CHANGES.md)"
CONTENT="$(base64 -w0 <CHANGELOG.md)" CONTENT="$(base64 -w0 <CHANGELOG.md)"
BODY_TMPL='{"branch": "next-release", "start_branch": $startBranch, "author_name": "Unbound Release", "content": $content, "commit_message": $title, "encoding": "base64" }' BODY_TMPL='{"branch": "next-release", "start_branch": $startBranch, "author_name": "Unbound Release", "content": $content, "commit_message": $title, "encoding": "base64" }'
if [ -n "${BRANCH}" ]; then if [ -n "${BRANCH}" ]; then
@@ -96,9 +99,10 @@ handle_mr:
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/merge_requests/${MR}/rebase" "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/merge_requests/${MR}/rebase"
echo "Updating title" echo "Updating title"
BODY_TMPL='{"target_branch":$target,"title":$title,"remove_source_branch":true,"squash":true}' BODY_TMPL='{"target_branch":$target,"title":$title,"description":$description,"remove_source_branch":true,"squash":true}'
BODY=$(jq --null-input -c \ BODY=$(jq --null-input -c \
--arg title "${TITLE}" \ --arg title "${TITLE}" \
--arg description "${DESCRIPTION}" \
--arg target "${CI_DEFAULT_BRANCH}" \ --arg target "${CI_DEFAULT_BRANCH}" \
"${BODY_TMPL}") "${BODY_TMPL}")
curl -sf -X PUT \ curl -sf -X PUT \
@@ -108,9 +112,10 @@ handle_mr:
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/merge_requests/${MR}" "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/merge_requests/${MR}"
else else
echo "Creating new MR" echo "Creating new MR"
BODY_TMPL='{"source_branch":"next-release","target_branch":$target,"title":$title,"remove_source_branch":true,"squash":true}' BODY_TMPL='{"source_branch":"next-release","target_branch":$target,"title":$title,"description":$description,"remove_source_branch":true,"squash":true}'
BODY=$(jq --null-input -c \ BODY=$(jq --null-input -c \
--arg title "${TITLE}" \ --arg title "${TITLE}" \
--arg description "${DESCRIPTION}" \
--arg target "${CI_DEFAULT_BRANCH}" \ --arg target "${CI_DEFAULT_BRANCH}" \
"${BODY_TMPL}") "${BODY_TMPL}")
curl -sf -X POST \ curl -sf -X POST \