Merge pull request #1578 from stevehipwell/release-chart-v3.12.2 #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Chart | |
on: | |
push: | |
branches: | |
- release-* | |
paths: | |
- charts/metrics-server/Chart.yaml | |
permissions: | |
contents: read | |
jobs: | |
release: | |
name: Release | |
if: github.repository == 'kubernetes-sigs/metrics-server' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
- name: Get chart version | |
id: chart_version | |
uses: mikefarah/yq@dd648994340a5d03225d97abf19c9bf1086c3f07 # v4.40.5 | |
with: | |
cmd: yq eval '.version' './charts/metrics-server/Chart.yaml' | |
- name: Get chart app version | |
id: chart_app_version | |
uses: mikefarah/yq@dd648994340a5d03225d97abf19c9bf1086c3f07 # v4.40.5 | |
with: | |
cmd: yq eval '.appVersion' './charts/metrics-server/Chart.yaml' | |
- name: Check can release | |
id: check_can_release | |
run: | | |
set -euo pipefail | |
branch_name="${GITHUB_REF##*/}" | |
app_version_prefix="${branch_name##*-}" | |
app_version_regex="^${app_version_prefix//./\.}" | |
chart_version_match="$(echo "${{ steps.chart_version.outputs.result }}" | grep -Po "^\d+\.\d+\.\d+$" || true)" | |
app_version_match="$(echo "${{ steps.chart_app_version.outputs.result }}" | grep -Po "^${app_version_prefix//./\.}" || true)" | |
if [[ -z "${chart_version_match}" ]] || [[ -z "${app_version_match}" ]] | |
then | |
echo "continue=false" >> $GITHUB_OUTPUT | |
else | |
echo "continue=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Set-up Helm | |
if: steps.check_can_release.outputs.continue == 'true' | |
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
version: latest | |
- name: Get CHANGELOG entry | |
id: changelog_reader | |
if: steps.check_can_release.outputs.continue == 'true' | |
uses: mindsers/changelog-reader-action@b97ce03a10d9bdbb07beb491c76a5a01d78cd3ef # v2.2.2 | |
with: | |
path: charts/metrics-server/CHANGELOG.md | |
version: ${{ steps.chart_version.outputs.version }} | |
- name: Create release notes | |
if: steps.check_can_release.outputs.continue == 'true' | |
run: | | |
set -euo pipefail | |
cat <<"EOF" > charts/metrics-server/RELEASE.md | |
${{ steps.changelog_reader.outputs.changes }} | |
EOF | |
- name: Run chart-releaser | |
if: steps.check_can_release.outputs.continue == 'true' | |
uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0 | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_RELEASE_NAME_TEMPLATE: "metrics-server-helm-chart-{{ .Version }}" | |
CR_RELEASE_NOTES_FILE: RELEASE.md | |
CR_MAKE_RELEASE_LATEST: false |