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

Automation to automatically bump semver #538

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/bump-helm-chart-on-pr-open.yaml
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"
Copy link
Collaborator

@mathew-fleisch mathew-fleisch Jun 28, 2024

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?

Copy link
Collaborator Author

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

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`.'
})
9 changes: 4 additions & 5 deletions .github/workflows/pr-test-and-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
-
-
name: Install stuff with asdf
uses: asdf-vm/actions/install@v1
with:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
-
-
name: Install stuff with asdf
uses: asdf-vm/actions/install@v1
with:
Expand Down Expand Up @@ -109,9 +109,9 @@ jobs:
echo "AGIMUS is NOT online!!!"
exit 1
fi

-
name: Debug
name: Debug
if: ${{ always() }}
shell: bash
env:
Expand All @@ -133,4 +133,3 @@ jobs:
kubectl --namespace agimus describe pod $(kubectl --namespace agimus get pods | grep agimus | awk '{print $1}') || true
echo "Logs:"
kubectl --namespace agimus logs $(kubectl --namespace agimus get pods | grep agimus | awk '{print $1}') || true

4 changes: 2 additions & 2 deletions charts/agimus/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: agimus
description: A helm chart for a discord bot that also runs a mysql db
type: application
version: v2.10.1
appVersion: v2.10.1
version: v2.10.2
appVersion: v2.10.2
Loading