|
| 1 | +## Used on Renovate PRs to bump the chart version and add a changelog entry |
| 2 | +## Reference: https://github.com/stefanzweifel/git-auto-commit-action |
| 3 | +## Reference: https://github.com/marketplace/actions/changed-files |
| 4 | +name: 'Chart Version Bump and Changelog' |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + types: |
| 9 | + - labeled |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + helm-bumper: |
| 16 | + if: ${{ (contains(github.event.pull_request.labels.*.name, 'renovate')) }} |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 20 | + with: |
| 21 | + token: ${{ secrets.PAT }} |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Get changed files |
| 25 | + id: changed-files |
| 26 | + uses: tj-actions/changed-files@716b1e13042866565e00e85fd4ec490e186c4a2f # v41.0.1 |
| 27 | + with: |
| 28 | + files: charts/{argo-workflows,argo-cd,argo-events,argo-rollouts,argocd-image-updater}/Chart.yaml |
| 29 | + |
| 30 | + - name: "Bump Version and Changelog" |
| 31 | + run: | |
| 32 | + chartName="$(echo \"${{ steps.changed-files.outputs.all_changed_files }}\" | cut -d '/' -f2)" |
| 33 | + echo "Changed chart name is: $chartName" |
| 34 | + echo "----------------------------------------" |
| 35 | +
|
| 36 | + parentDir="charts/${chartName}" |
| 37 | +
|
| 38 | + # Bump the chart version by one patch version |
| 39 | + version=$(grep '^version:' ${parentDir}/Chart.yaml | awk '{print $2}') |
| 40 | + major=$(echo $version | cut -d. -f1) |
| 41 | + minor=$(echo $version | cut -d. -f2) |
| 42 | + patch=$(echo $version | cut -d. -f3) |
| 43 | + patch=$(expr $patch + 1) |
| 44 | + sed -i "s/^version:.*/version: ${major}.${minor}.${patch}/g" ${parentDir}/Chart.yaml |
| 45 | +
|
| 46 | + # Add a changelog entry |
| 47 | + appVersion=$(grep '^appVersion:' ${parentDir}/Chart.yaml | awk '{print $2}') |
| 48 | + sed -i -e '/^ artifacthub.io\/changes: |/,$d' ${parentDir}/Chart.yaml |
| 49 | + echo " artifacthub.io/changes: |" >> ${parentDir}/Chart.yaml |
| 50 | + echo " - kind: changed" >> ${parentDir}/Chart.yaml |
| 51 | + echo " description: Bump ${chartName} to ${appVersion}" >> ${parentDir}/Chart.yaml |
| 52 | + cat ${parentDir}/Chart.yaml |
| 53 | +
|
| 54 | + - name: "Commit and push changes" |
| 55 | + uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d # v5.0.0 |
| 56 | + with: |
| 57 | + commit_options: '--signoff' |
0 commit comments