diff --git a/.gitignore b/.gitignore index 0a0e9bd4..575ba80e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ mender-*.tgz /values*.yaml /index.yaml tests/hm-values.yaml +cliff.toml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 302c0148..bfd2d5a9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,10 +34,40 @@ variables: options: - "true" - "false" + GITHUB_REPO_URL: + description: "The Github Repo URL for release-please, in the format of 'owner/repo'" + value: "mendersoftware/mender-helm" + DEFAULT_BRANCH: "master" + GITHUB_REPO_URL: + description: "The Github Repo URL for release-please, in the format of 'owner/repo'" + value: "mendersoftware/mender-helm" + GITHUB_USER: + description: "The Github user for release-please" + value: "mender-test-bot" + GITHUB_USER_NAME: + description: "The Github username for release-please" + value: "mender-test-bot" + GITHUB_USER_EMAIL: + description: "The Github user email for release-please" + value: "mender@northern.tech" + RUN_RELEASE: + description: "Run a new release" + value: "false" + options: + - "true" + - "false" + GIT_CLIFF: + description: "Run git cliff to override the release-please changelog" + value: "true" + options: + - "true" + - "false" stages: - build - test + - changelog + - release - publish - version-bump @@ -790,3 +820,77 @@ cleanup_eks_cluster:success: cleanup_eks_cluster:failed:manual: when: manual <<: *eks_cleanup + +changelog: + image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:20 + stage: changelog + tags: + - hetzner-amd-beefy + rules: + - if: $CI_PIPELINE_SOURCE == "pipeline" + when: never + - if: $RUN_RELEASE == "true" + when: never + - if: $CI_COMMIT_BRANCH =~ "/^\d+\.\d+\.x$/" + - if: $CI_COMMIT_BRANCH == $DEFAULT_BRANCH + before_script: + # install release-please + - npm install -g release-please + # install github-cli + - | + mkdir -p -m 755 /etc/apt/keyrings \ + && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \ + && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && apt update \ + && apt install gh jq -y + # Setting up git + - | + echo "INFO - setting up git" + git config --global user.email "${GITHUB_USER_EMAIL}" + git config --global user.name "${GITHUB_USER_NAME}" + - npm install -g git-cliff + # GITHUB_TOKEN for Github cli authentication + - export GITHUB_TOKEN=${GITHUB_CLI_TOKEN} + # getting the centralized git cliff config + - wget --output-document cliff.toml https://raw.githubusercontent.com/mendersoftware/mendertesting/master/utils/cliff.toml + script: + - release-please release-pr + --token=${GITHUB_BOT_TOKEN_REPO_FULL} + --repo-url=${GITHUB_REPO_URL} + --target-branch=${CI_COMMIT_REF_NAME} + # git cliff: override the changelog + - test $GIT_CLIFF == "false" && echo "INFO - Skipping git-cliff" && exit 0 + - git clone https://${GITHUB_USER}:${GITHUB_BOT_TOKEN_REPO_FULL}@github.com/${GITHUB_REPO_URL} + - cd ${GITHUB_REPO_URL#*/} + - RELEASE_PLEASE_PR=$(gh pr list --author "${GITHUB_USER_NAME}" --head "release-please--branches--${CI_COMMIT_REF_NAME}" --json number | jq -r '.[0].number // empty') + - test -z "$RELEASE_PLEASE_PR" && echo "No release-please PR found" && exit 0 + - echo "INFO - generating changelog notes from git cliff" + && gh pr checkout $RELEASE_PLEASE_PR + && git cliff --output mender/CHANGELOG.md --bump --github-repo ${GITHUB_REPO_URL} + && git add mender/CHANGELOG.md + && git commit --amend -s --no-edit + && git push origin --force + # note: using sed to prevent release-please to mess up with the Github Release body + - echo "INFO - updating PR body" + && git cliff --unreleased --bump -o tmp_pr_body.md --github-repo ${GITHUB_REPO_URL} + && sed -i 's/## mender-\([0-9.]*\)/## \1/' tmp_pr_body.md + && gh pr edit $RELEASE_PLEASE_PR --body-file tmp_pr_body.md + && rm tmp_pr_body.md + +release:github: + image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:20 + stage: release + tags: + - hetzner-amd-beefy + rules: + - if: $CI_PIPELINE_SOURCE == "pipeline" + when: never + - if: $CI_COMMIT_BRANCH =~ "/^\d+\.\d+\.x$/" && $RUN_RELEASE == "true" + - if: $CI_COMMIT_BRANCH == $DEFAULT_BRANCH && $RUN_RELEASE == "true" + script: + - npm install -g release-please + - release-please github-release + --token=${GITHUB_BOT_TOKEN_REPO_FULL} + --repo-url=${GITHUB_REPO_URL} + --target-branch=${CI_COMMIT_REF_NAME} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..608f8b9d --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,4 @@ +{ + "mender": "5.10.1" +} + diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..152494bc --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,17 @@ +{ + "packages": { + "mender": { + "changelog-path": "CHANGELOG.md", + "bump-minor-pre-major": false, + "bump-patch-for-minor-pre-major": false, + "draft": false, + "prerelease": false + } + }, + "release-type": "helm", + "include-component-in-tag": true, + "include-v-in-tag": false, + "bootstrap-sha": "bced4eecaebc707975b011d64bc28354367433c0", + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" +} +