-
Notifications
You must be signed in to change notification settings - Fork 9
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
Automation to automatically bump semver #538
Open
magikid
wants to merge
17
commits into
main
Choose a base branch
from
chris/issue-533
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f39fcf3
Bump helm chart versions in PR
magikid d4edf85
Debugging yq issue
magikid dacb262
Define outputs for job
magikid ae8087e
Trying to use step instead of needs
magikid bf7af15
Try it with new_version too
magikid c5843e0
Get new version by stdout
magikid 18c1a03
Change from stdout to output per use-semver-tool code
magikid 6974f91
Make the change in the chart file and verify it
magikid 67108d4
Now get it working for appVersion
magikid ca05b25
Add in commiting and commenting
magikid 09dc7f7
Trying to get the proper branch checked out for the commit
magikid 75269f5
Add write permissions
magikid 930b6b9
Bump helm chart version to 2.10.1
github-actions[bot] d7448f9
Fixing the ping of a user on success
magikid 01996f4
Bump helm chart version to 2.10.2
github-actions[bot] eb2d654
Bump helm version bump into own file
magikid 03b34ba
Merge branch 'main' into chris/issue-533
mathew-fleisch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Name: bump-helm-chart-on-pr-open.yaml | ||
# Author: Chris Jones <[email protected]> | ||
# Description: This action will bump the patch version of the helm chart | ||
# and push the changes to the PR branch when a PR is opened. | ||
# | ||
|
||
name: Bump Helm Chart on PR Open | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: [opened, reopened] | ||
|
||
jobs: | ||
bump_helm_chart_version: | ||
name: Bump Helm Chart Version | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.head_ref }} | ||
- uses: mikefarah/yq@master | ||
id: get_current_version | ||
with: | ||
cmd: echo "current_version=$(yq e '.version' './charts/agimus/Chart.yaml')" >> $GITHUB_OUTPUT | ||
- uses: vitorfhc/use-semver-tool@v1 | ||
id: get_new_version | ||
with: | ||
cmd: bump patch ${{ steps.get_current_version.outputs.current_version }} | ||
- uses: mikefarah/yq@master | ||
with: | ||
cmd: yq -i '.version = "v${{ steps.get_new_version.outputs.output }}"' ./charts/agimus/Chart.yaml | ||
|
||
- uses: mikefarah/yq@master | ||
id: get_current_app_version | ||
with: | ||
cmd: echo "current_app_version=$(yq e '.appVersion' './charts/agimus/Chart.yaml')" >> $GITHUB_OUTPUT | ||
- uses: vitorfhc/use-semver-tool@v1 | ||
id: get_new_app_version | ||
with: | ||
cmd: bump patch ${{ steps.get_current_app_version.outputs.current_app_version }} | ||
- uses: mikefarah/yq@master | ||
with: | ||
cmd: yq -i '.appVersion = "v${{ steps.get_new_app_version.outputs.output }}"' ./charts/agimus/Chart.yaml | ||
|
||
- name: Commit and push the changes | ||
run: | | ||
# Note: the following account information will not work on GHES | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add . | ||
git commit -m "Bump helm chart version to ${{ steps.get_new_version.outputs.output }}" | ||
git push | ||
|
||
- uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: '@${{ github.event.pull_request.user.login }} The helm chart version has been bumped. You will need to pull down the new changes to your local copy with `git pull`.' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where doe this email come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it in a random stackoverflow answer but here's the actual answer: https://ardislu.dev/proper-git-for-github-actions