Skip to content

Commit

Permalink
chore(ci): automatically update the appVersion in Chart when release …
Browse files Browse the repository at this point in the history
…new version (#607)

## What type of PR is this?

/kind chore

## What this PR does / why we need it:

When the Release workflow is triggered, a PR will be automatically
created in the [charts
repository](https://github.com/KusionStack/charts), and the change
content in the PR is to upgrade the `chart version` and `app version`.

Demo PR: KusionStack/charts#76

Screenshots:


![image](https://github.com/user-attachments/assets/11f69b98-f803-42ae-b9ad-5f0b0147b29d)

## Which issue(s) this PR fixes:

Fix #547

---------

Co-authored-by: Rajesh Kumar <107089376+rajeshkio@users.noreply.github.com>
  • Loading branch information
elliotxx and rajeshkio authored Dec 20, 2024
1 parent 0f81677 commit 1ec7c60
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
pull-requests: write
jobs:
Test:
name: Unit Test
Expand Down Expand Up @@ -137,3 +138,61 @@ jobs:
args: release --clean --config .goreleaser/${{ env.GO_RELEASER_CONFIG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get new chart version from the chart repo
id: get_chart_version
run: |
helm repo add kusionstack https://kusionstack.github.io/charts
helm repo update
version=$(helm search repo kusionstack/karpor --versions | head -n 2 | tail -n 1 | awk '{print $2}')
if [ -z "$version" ]; then
echo "Error: Unable to fetch chart version" >&2
exit 1
fi
echo "Current chart version is: $version"
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
patch=$(echo "$version" | cut -d. -f3)
new_chart_version="${major}.${minor}.$((patch + 1))"
echo "New chart version is: $new_chart_version"
echo "::set-output name=new_chart_version::$new_chart_version"
- name: Checkout Target repository
uses: actions/checkout@v4
with:
repository: KusionStack/charts
path: charts
token: ${{ secrets.CHART_UPDATER_PAT }}
fetch-depth: 0

- name: Bump version in the related HelmChart Chart.yaml
uses: fjogeleit/yaml-update-action@main
env:
COMMIT_MESSAGE: 'chore(karpor): bump app version to ${{ steps.get_version.outputs.VERSION }}, chart version to ${{ steps.get_chart_version.outputs.new_chart_version }}'
with:
repository: KusionStack/charts
valueFile: 'charts/karpor/Chart.yaml'
changes: '{"version":"${{ steps.get_chart_version.outputs.new_chart_version }}", "appVersion":"${{ steps.get_version.outputs.VERSION }}"}'
value: ${{ steps.get_version.outputs.VERSION }}
branch: bump-karpor-to-${{ steps.get_version.outputs.VERSION }}
targetBranch: master
message: ${{ env.COMMIT_MESSAGE }}
createPR: true
title: ${{ env.COMMIT_MESSAGE }}
description: |
This PR updates the Karpor Helm chart with the following changes:
- Bump the `appVersion` to `${{ steps.get_version.outputs.VERSION }}`
- Bump the `version` to `${{ steps.get_chart_version.outputs.new_chart_version }}`
These updates ensure that the chart reflects the latest Karpor release.
**Note**: This PR was automatically generated by the **karpor-chart-updater[bot]**.
labels: 'karpor-chart-updater[bot]'
token: ${{ secrets.CHART_UPDATER_PAT }}
workDir: charts

- name: Log Test Outputs # Log outputs for debugging
run: |
echo "Testing complete. Check the logs for details."
echo "New chart version: ${{ steps.get_chart_version.outputs.new_chart_version }}"
echo "App version: ${{ steps.get_version.outputs.VERSION }}"

0 comments on commit 1ec7c60

Please sign in to comment.