-
Notifications
You must be signed in to change notification settings - Fork 1.9k
96 lines (81 loc) · 3.09 KB
/
release-chart.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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@d632683dd7b4114ad314bca15554477dd762a938 #v4.2.0
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@bbdd97482f2d439126582a59689eb1c855944955 # v4.44.3
with:
cmd: yq eval '.version' './charts/metrics-server/Chart.yaml'
- name: Get chart app version
id: chart_app_version
uses: mikefarah/yq@bbdd97482f2d439126582a59689eb1c855944955 # v4.44.3
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@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
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@32aa5b4c155d76c94e4ec883a223c947b2f02656 # v2.2.3
with:
path: charts/metrics-server/CHANGELOG.md
version: ${{ steps.chart_version.outputs.result }}
- 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