diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8395e63..0e991fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -39,13 +39,21 @@ handle_mr: 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' + - '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 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2ce54b1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +