diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5e63d48d..7242af52 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,6 +10,7 @@ on: - 'v[0-9]+.[0-9]+.[0-9]+' permissions: contents: write + pull-requests: write jobs: Test: name: Unit Test @@ -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 }}"