Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release please CHANGELOG automation #341

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

oldgiova
Copy link
Contributor

@oldgiova oldgiova commented Sep 11, 2024

Added release-please and git cliff. After including a new fix|feat|feat! to master, the tools are creating a new Changelog PR with the new version bumped accordingly to the commit messages.

Notes

  1. the old changelog will be overridden
  2. the new tag should include the component: mender-5.10.2 instead of 5.10.2. This is configurable, but I'm doing this in preparation to the possible mender-server component

@oldgiova oldgiova marked this pull request as draft September 18, 2024 08:33
@oldgiova oldgiova marked this pull request as ready for review September 18, 2024 09:40
}
},
"release-type": "helm",
"include-component-in-tag": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this setting we'll have tags named mender-5.10.2 instead of just 5.10.2.

.gitlab-ci.yml Outdated
Comment on lines 859 to 876
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time I read this script I keep wondering what's the purpose of release-please. Isn't it simply a glorified gh pr create/gh release create?
If I'm not mistaken, this snippet is forcefully overwriting the entire content of the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the --unreleased flag to just add the latest release, without overriding the previous ones.

Every time I read this script I keep wondering what's the purpose of release-please. Isn't it simply a glorified gh pr create/gh release create?

That, but most importantly it has the logic to check every commit and understand which will be the next version; the logic also applies to maintenance branches.
We could just rewrite this logic implementing a git cliff wrapper in bash/python, but this will end up in a custom tool, something that we'd like to avoid. The tool could be pretty simple, but would still require a fair amount of code and cases.

OTOH, we're still considering release-please experimental, so if the experience is these "testing" repositories is bad, we could simply try with another (internal?) tool.

With release-please and git cliff, the CHANGELOG.md and the releases are automated

Ticket: MC-7582

Signed-off-by: Roberto Giovanardi <[email protected]>
@oldgiova oldgiova merged commit d1b7a7b into mendersoftware:master Oct 4, 2024
1 check passed
@oldgiova oldgiova deleted the MC-7577-release-please branch October 4, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants