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

feat(ci): chart release workflow #71

Merged
merged 7 commits into from
Jun 30, 2023
Merged

Conversation

tthvo
Copy link
Member

@tthvo tthvo commented Jun 1, 2023

Fixes #8
Fixes #76
Depends on #73 (i.e. restructure chart directory)
Depends on cryostatio/cryostatio.github.io#132

Release CI for helm charts. Release drafter is replaced with Github automated release note generations to avoid conflict with helm-releaser-actions. See #76.

@tthvo tthvo added the feat New feature or request label Jun 1, 2023
@tthvo tthvo marked this pull request as draft June 1, 2023 00:51
@tthvo tthvo changed the title feat(ci): helm release feat(ci): chart release workflow Jun 1, 2023
@tthvo tthvo added the ci label Jun 1, 2023
@tthvo tthvo force-pushed the helm-release branch 2 times, most recently from 14c3082 to 02459e3 Compare June 9, 2023 02:35
@tthvo tthvo requested review from andrewazores and ebaron June 9, 2023 02:38
@tthvo tthvo marked this pull request as ready for review June 9, 2023 02:38
Copy link
Member

@ebaron ebaron left a comment

Choose a reason for hiding this comment

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

@tthvo thanks for taking this on! I've been trying to think of ways we can make this work with the Chart Releaser Action. What about making the workflow manual only?
https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow

It should allow us to run the workflow on a branch (when we're ready to release), and then leave the rest up to the Chart Releaser Action?

@tthvo
Copy link
Member Author

tthvo commented Jun 9, 2023

What about making the workflow manual only?
https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow

It should allow us to run the workflow on a branch (when we're ready to release), and then leave the rest up to the Chart Releaser Action?

Oh yes manual trigger sounds good! I am just concerned about these requirements: https://github.com/helm/chart-releaser-action#pre-requisites

It requires gh-pages branch to work while upstream doc build is done on main...

@ebaron
Copy link
Member

ebaron commented Jun 9, 2023

It requires gh-pages branch to work while upstream doc build is done on main...

Do you mean the release notes drafter?

@tthvo
Copy link
Member Author

tthvo commented Jun 9, 2023

Do you mean the release notes drafter?

Oh no i mean our upstream website here: https://github.com/cryostatio/cryostatio.github.io. I remember we want to host the chart repository under cryostat.io/helm-charts right?

@ebaron
Copy link
Member

ebaron commented Jun 9, 2023

Do you mean the release notes drafter?

Oh no i mean our upstream website here: https://github.com/cryostatio/cryostatio.github.io. I remember we want to host the chart repository under cryostat.io/helm-charts right?

Oh right. Are we able to add the gh-pages branch of this repo as a submodule to the website's main repo?

@tthvo
Copy link
Member Author

tthvo commented Jun 9, 2023

Are we able to add the gh-pages branch of this repo as a submodule to the website's main repo?

Oh wait now that it makes sense about the submodule. I think its really possible.

In this PR, I am doing updates manually and triggered on every tag release. Do u think its easier this way or submodule is better?

@ebaron
Copy link
Member

ebaron commented Jun 9, 2023

In this PR, I am doing updates manually. Do u think its easier this way or submodule is better?

Sorry, what updates are you referring to?

Also, I thought of another problem. The Release Drafter action creates draft releases, which will probably conflict with the releases that the Chart Releaser Action tries to make. I think it should actually be possible to substitute GitHub's built-in release notes generator for this action. We add a file to customize the format of the release notes, using labels as we do currently:
https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes

The Chart Releaser Action uses the GitHub Release API to generate release notes if they're not provided. Unfortunately this API doesn't provide a way to specify the previous tag to compare against. It does have a separate API to do this and return the release notes as JSON: https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#generate-release-notes-content-for-a-release

We can call this API inside the workflow which should already have the GitHub CLI installed:

# GitHub CLI api
# https://cli.github.com/manual/gh_api

gh api \
  --method POST \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  /repos/OWNER/REPO/releases/generate-notes \
  -f tag_name='v1.0.0' \
 -f target_commitish='main' \
 -f previous_tag_name='v0.9.2' \
 -f configuration_file_path='.github/custom_release_config.yml' 

We can use jq to grab the body from the response and output it to a file. Then create a config.yaml with release-notes-file: /path/to/release-notes[1]. Then pass the config file to the Chart Releaser Action like this: https://github.com/helm/chart-releaser-action#example-using-custom-config

We might be able to use this action to quickly compute the previous semver tag. If not it should be easy to do ourselves.

[1] https://github.com/helm/chart-releaser/blob/fce24e7688b7dd9b6091ff2e84d1eaabce8de1ee/pkg/config/config.go#LL61C45-L61C63

@tthvo
Copy link
Member Author

tthvo commented Jun 9, 2023

Sorry, what updates are you referring to?

Sorry I am referring to updates to this index.yaml file here: cryostatio/cryostatio.github.io#132. Currently, this PR will listen for a new release and patch that file with new chart version.

Also, I thought of another problem....

Ah yes! I will look into the direction then if we go with submodule + Release Action then.

@ebaron
Copy link
Member

ebaron commented Jun 9, 2023

Sorry, what updates are you referring to?

Sorry I am referring to updates to this index.yaml file here: cryostatio/cryostatio.github.io#132. Currently, this PR will listen for a new release and patch that file with new chart version.

The submodule seems like it would avoid you having to do this. I would concentrate first on getting the workflow working in this repository. Once that's done we can see how to integrate it into the website. Hopefully it's as easy as it sounds.

Also, I thought of another problem....

Ah yes! I will look into the direction then if we go with submodule + Release Action then.

I filed #76 since it's tangential, but releated work.

@tthvo
Copy link
Member Author

tthvo commented Jun 9, 2023

Thanks I will get back to this after PTO then. I think it should be easy enough to have index.yaml hosted on cryostat.io/helm-charts :))

@tthvo tthvo marked this pull request as draft June 9, 2023 21:40
@tthvo tthvo force-pushed the helm-release branch 2 times, most recently from 6d27465 to 95d8746 Compare June 22, 2023 20:10
@tthvo tthvo changed the title feat(ci): chart release workflow ci(chart-release): chart release workflow Jun 22, 2023
Signed-off-by: Thuan Vo <thvo@redhat.com>
@tthvo tthvo removed the feat New feature or request label Jun 22, 2023
@tthvo tthvo added the feat New feature or request label Jun 22, 2023
@tthvo tthvo changed the title ci(chart-release): chart release workflow feat(ci): chart release workflow Jun 22, 2023
Reference error: The release note file ".github/release-notes.md", is not present in the chart package
@tthvo tthvo marked this pull request as ready for review June 22, 2023 22:00
@tthvo
Copy link
Member Author

tthvo commented Jun 22, 2023

@ebaron @andrewazores Ready for review again. Here are a sample run on my fork:

Release: https://github.com/tthvo/cryostat-helm/releases

Gh-pages update: https://github.com/tthvo/cryostat-helm/tree/gh-pages (see index.yaml).

Action Run: https://github.com/tthvo/cryostat-helm/actions/runs/5350680838/jobs/9703606956

@tthvo
Copy link
Member Author

tthvo commented Jun 22, 2023

I got some issue when testing the release note on my fork as nothing was reported. However, when testing on upstream, the release note is generated correctly (i.e. using my upstream branch as main does not have config file):

$ gh api --method POST -H "Accept: application/vnd.github+json" /repos/cryostatio/cryostat-helm/releases/generate-notes -f tag_name='v0.4.0' -f target_commitish='helm-release' -f previous_tag_name='v0.3.0' | jq -r .body
<!-- Release notes generated using configuration in .github/release.yml at helm-release -->

## What's Changed
### 🚀 Features
* feat(deploy): minimal parameter for deploying Cryostat without grafana and datasource by @tthvo in https://github.com/cryostatio/cryostat-helm/pull/66
* feat(ci): workflow to lint and test charts  by @tthvo in https://github.com/cryostatio/cryostat-helm/pull/73
### 🔧 Fixes
* fix(chart): consider pre-release versioning by @ebaron in https://github.com/cryostatio/cryostat-helm/pull/59
* fix(deploy): set CRYOSTAT_K8S_NAMESPACES by @ebaron in https://github.com/cryostatio/cryostat-helm/pull/58
* fix(secret): use release name in database secret by @tthvo in https://github.com/cryostatio/cryostat-helm/pull/65
* fix(note): fix incorrect service field in NOTES.txt by @tthvo in https://github.com/cryostatio/cryostat-helm/pull/68
* fix(ci): increase timeout for chart testing process by @tthvo in https://github.com/cryostatio/cryostat-helm/pull/74
### ⚙️ Maintenance
* chore(github): add pr + issue templates + add release drafter by @maxcao13 in https://github.com/cryostatio/cryostat-helm/pull/56
* ci(mergify): update config for latest release branch by @tthvo in https://github.com/cryostatio/cryostat-helm/pull/55

## New Contributors
* @maxcao13 made their first contribution in https://github.com/cryostatio/cryostat-helm/pull/56

**Full Changelog**: https://github.com/cryostatio/cryostat-helm/compare/v0.3.0...v0.4.0

@tthvo
Copy link
Member Author

tthvo commented Jun 22, 2023

Also, i wonder if we could initialize the gh-pages branch with an intial index.yaml that contains previous releases? New chart release will just patch that file with new release information.

I already generated one here: cryostatio/cryostatio.github.io@95076a5#diff-09d0d2fba18742bdcc0d3f6a345da7e93c6522d1fdf5bcb02a9ed5d47b05219c

@ebaron
Copy link
Member

ebaron commented Jun 27, 2023

Also, i wonder if we could initialize the gh-pages branch with an intial index.yaml that contains previous releases? New chart release will just patch that file with new release information.

I already generated one here: cryostatio/cryostatio.github.io@95076a5#diff-09d0d2fba18742bdcc0d3f6a345da7e93c6522d1fdf5bcb02a9ed5d47b05219c

That should be fine.

@tthvo
Copy link
Member Author

tthvo commented Jun 27, 2023

Nice thanks! Created and cleaned up for upstream gh-pages branch here: https://github.com/cryostatio/cryostat-helm/tree/gh-pages

I will rebase it after this PR just to mark where it all started.

@mergify mergify bot mentioned this pull request Jun 30, 2023
Copy link
Member

@ebaron ebaron left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks a lot @tthvo, excellent work as always!

@ebaron ebaron merged commit 04c9baa into cryostatio:main Jun 30, 2023
@tthvo tthvo deleted the helm-release branch July 2, 2023 22:50
mergify bot pushed a commit that referenced this pull request Sep 11, 2023
* feat(ci): chart release workflow

Signed-off-by: Thuan Vo <thvo@redhat.com>

* ci(release-config): adjust release config category labels

* feat(helm-release): use github auto-generated release notes

* ci(helm-release): add missing github token

* ci(release-notes): put release notes into chart packages

Reference error: The release note file ".github/release-notes.md", is not present in the chart package

* ci(release): manually compute previous tag

* ci(release): reuse previous step output

---------

Signed-off-by: Thuan Vo <thvo@redhat.com>
(cherry picked from commit 04c9baa)
ebaron pushed a commit that referenced this pull request Sep 11, 2023
* feat(ci): chart release workflow

Signed-off-by: Thuan Vo <thvo@redhat.com>

* ci(release-config): adjust release config category labels

* feat(helm-release): use github auto-generated release notes

* ci(helm-release): add missing github token

* ci(release-notes): put release notes into chart packages

Reference error: The release note file ".github/release-notes.md", is not present in the chart package

* ci(release): manually compute previous tag

* ci(release): reuse previous step output

---------

Signed-off-by: Thuan Vo <thvo@redhat.com>
(cherry picked from commit 04c9baa)

Co-authored-by: Thuan Vo <thvo@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Task] Switch to GitHub's generated release notes [Story] Explore release options
2 participants