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

chore(ci): automatically update the appVersion in Chart when release new version #607

Merged
merged 18 commits into from
Dec 20, 2024
Merged
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
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 }}"
Loading