Skip to content

feat(ci): add automatic chart version bump workflow#411

Draft
pierluigilenoci wants to merge 4 commits into
oauth2-proxy:mainfrom
pierluigilenoci:feat/auto-version-bump
Draft

feat(ci): add automatic chart version bump workflow#411
pierluigilenoci wants to merge 4 commits into
oauth2-proxy:mainfrom
pierluigilenoci:feat/auto-version-bump

Conversation

@pierluigilenoci
Copy link
Copy Markdown
Member

Summary

This PR introduces an automatic chart version bump workflow inspired by the pattern described by @jsoref in #410.

The problem today: Every PR that touches the Helm chart must manually bump version: in Chart.yaml. Concurrent PRs always conflict on this line, requiring constant rebases and coordination.

How this works:

  • Contributors add a small file to changelogs/minor/ (new feature) or changelogs/major/ (breaking change) alongside their chart changes — no need to pick a version number.
  • On merge to main, the bump-version workflow (using GarnerCorp/build-actions) reads those files, determines the bump type (major > minor > patch), updates version: in Chart.yaml, commits, and pushes.
  • The changelog files are consumed (deleted) by that commit.
  • Patch bumps happen automatically when no changelog file is present.

Changes

  • .github/workflows/bump-version.yaml — new workflow that runs on push to main
  • .github/workflows/lint-test.yaml — adds a check in CI that fails fast when chart files are modified without a changelog entry
  • changelogs/README.md — documents the convention for contributors
  • changelogs/minor/.gitkeep, changelogs/major/.gitkeep — seed the directories

Notes

  • Requires a PUSH_KEY secret (deploy key with write access) so the bot commit can trigger downstream workflows.
  • The !contains(github.actor, 'oauth2-proxy-bot') guard prevents the workflow from eating its own tail.
  • This is an exploratory/RFC PR — happy to iterate on the approach before merging.

cc @jsoref @tuunit

Introduce a GarnerCorp/build-actions-based bump-version workflow that
eliminates manual version bump conflicts between concurrent PRs.

How it works:
- Contributors add a file to changelogs/minor/ (feature) or
  changelogs/major/ (breaking change) alongside their chart changes.
- On merge to main, the bump-version workflow reads those files,
  determines the bump type (major > minor > patch), updates
  version: in Chart.yaml, commits, and pushes.
- The changelog files are consumed (git rm'd) by the workflow.
- Patch bumps happen automatically when no file is present.

The lint-test workflow is extended with a check that fails fast
when chart files are modified without a changelog entry.

Inspired by the pattern described in oauth2-proxy#410 by
@jsoref.

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Copy link
Copy Markdown

@jsoref jsoref left a comment

Choose a reason for hiding this comment

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

Some thoughts

Comment thread .github/workflows/bump-version.yaml Outdated
Comment thread .github/workflows/bump-version.yaml Outdated
Comment thread .github/workflows/bump-version.yaml Outdated
Comment on lines +32 to +33
version-type: raw
version-file-path: helm/oauth2-proxy/Chart.yaml
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You'd probably want to do a bit more magic so that you can update this section:

artifacthub.io/changes: |

We weren't actively maintaining helm charts, so it wasn't something I was worried about, but I'm starting to do more work with helm charts, so I might add that support myself...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point! I added scripts/chart-version-parser.sh as a custom version-parser for the action. It handles both version: and the artifacthub.io/changes block — it reads the commit-log produced by next-version, extracts the kind (added/changed) and description from each changelog file, and rewrites the annotation in place.

Would love your thoughts on whether the approach is sound — especially the changelog parsing logic. Happy to iterate!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's pretty much what I envisioned when I designed this. Beyond this, I'd need some sample inputs and outputs to test it, but it feels about right.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Great to hear — thanks for the validation! I'll add a few example inputs/outputs to the script's header comments to make it easier to test and reason about. Will update the PR shortly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just pushed a fix and added the inline examples you mentioned. The script now has 5 documented test cases in the header (parse, update without log, two minor entries with PR refs, breaking change detection, no PR ref), and the changelog splice was rewritten in a single Python pass to avoid awk issues with multi-line strings containing slashes (URLs).

Tested locally — all 5 cases produce the expected output. Happy to add a proper bats test file if you think that's worth it.

Addresses review feedback from @jsoref:
- Pin actions/checkout to SHA (df4cb1c, v6)
- Pin GarnerCorp/build-actions/bump-version to SHA (ed29b86)
- Introduce scripts/chart-version-parser.sh as a version-parser that
  updates both version: and the artifacthub.io/changes block in
  Chart.yaml from the commit-log produced by next-version, so the
  changelog is always in sync with the version bump commit.

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
- Replace awk+python multi-step approach with a single python pass to
  avoid issues passing multi-line strings with slashes via awk -v
- Add comprehensive inline examples to the script header:
  * Input commit-log format
  * Example Chart.yaml before/after for parse and update
- Verified locally with 5 test cases:
  parse, update-no-log, two-minor-entries, breaking-change, no-pr-ref

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Comment thread scripts/chart-version-parser.sh Outdated

# Splice the new changes block into Chart.yaml using python for reliable multi-line handling
changes_block="$(printf '%b' "$changes_yaml")"
python3 - "$CHART_FILE" "$changes_block" << 'PYEOF'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd pull this out of line as a script w/ .py instead of using python3 - ..., since your .sh script is bash, you'll have access to the current bash script's path (it may require some bash magic).

Or, you might replace the whole .sh with .py. -- Personally, by the time I've started writing Python, I prefer to switch entirely.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call — I went ahead and rewrote the whole thing as scripts/chart-version-parser.py. The bash was just glue at that point anyway. All 5 test cases still pass, and the inline heredoc is gone entirely.

Replace the bash+inline-heredoc approach with a clean Python script
as suggested by @jsoref. All logic is now in chart-version-parser.py:
- parse: extract version from Chart.yaml
- update: bump version + splice artifacthub.io/changes block

All 5 test cases verified locally (parse, update-no-log, two-minor-entries,
breaking-change, no-pr-ref).

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
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