Skip to content

Commit 8283d89

Browse files
authored
Make sure GoReleaser provides fleet-helm charts checksums too (#4975) (#5022)
* Make sure GoReleaser signs fleet-helm charts too
1 parent 5b64fdd commit 8283d89

4 files changed

Lines changed: 42 additions & 26 deletions

File tree

.github/scripts/package-charts.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
TAG="${1:?TAG argument required}"
5+
VERSION="${2:?VERSION argument required}"
6+
7+
rm -rf .charts
8+
mkdir .charts
9+
10+
# Skip chart packaging for hotfix releases
11+
if [[ "${IS_HOTFIX:-false}" == "true" ]]; then
12+
exit 0
13+
fi
14+
15+
TMP_DIR="$(mktemp -d)"
16+
trap 'rm -rf "${TMP_DIR}"' EXIT
17+
18+
find charts -maxdepth 1 -mindepth 1 -type d -exec cp -R {} "${TMP_DIR}/" \;
19+
20+
# Update image tags in all chart values files
21+
find "${TMP_DIR}" -maxdepth 2 -name "values.yaml" -exec sed -i.bak \
22+
-e "s@repository: rancher/\(fleet[-a-z]*\).*@repository: rancher/\1@" \
23+
-e "s@tag: dev@tag: ${TAG}@" \
24+
{} \;
25+
find "${TMP_DIR}" -name "*.bak" -delete
26+
27+
while IFS= read -r chart_dir; do
28+
helm package \
29+
--version="${VERSION}" \
30+
--app-version="${VERSION}" \
31+
-d .charts \
32+
"${chart_dir}"
33+
done < <(find "${TMP_DIR}" -maxdepth 1 -mindepth 1 -type d | sort)

.github/workflows/release.yml

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -235,31 +235,6 @@ jobs:
235235
cosign attest --yes --predicate provenance-slsav1.json --type slsaprovenance1 "${URL}"
236236
done
237237
238-
- name: Upload charts to release
239-
if: ${{ env.IS_HOTFIX == 'false' }}
240-
env:
241-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
242-
repo: "rancher"
243-
run: |
244-
version=$(jq -r '.version' <<< '${{ steps.goreleaser.outputs.metadata }}')
245-
tag=$(jq -r '.tag' <<< '${{ steps.goreleaser.outputs.metadata }}')
246-
echo "publishing helm chart for (repo: $repo, tag: $tag, version: $version)"
247-
248-
# Replace rancher/fleet and rancher/fleet-agent and rancher/gitjob image names
249-
sed -i \
250-
-e "s@repository: rancher/\(fleet.*\|gitjob\).*@repository: $repo/\\1@" \
251-
-e "s/tag:.*/tag: $tag/" \
252-
charts/fleet/values.yaml
253-
254-
sed -i \
255-
-e "s@repository: rancher/\(fleet.*\|gitjob\).*@repository: $repo/\\1@" \
256-
-e "s/tag: dev/tag: $tag/" \
257-
charts/fleet-agent/values.yaml
258-
259-
find charts/ -maxdepth 1 -mindepth 1 -type d -exec helm package --version="$version" --app-version="$version" -d ./dist {} \;
260-
261-
find dist/ -name '*.tgz' -exec gh release upload "$tag" {} +
262-
263238
- name: Add charts to branch
264239
if: ${{ env.IS_HOTFIX == 'false' }}
265240
env:
@@ -292,7 +267,7 @@ jobs:
292267
fi
293268
294269
mkdir -p charts
295-
find dist/ -name '*.tgz' -exec tar -xf {} -C charts/ \;
270+
find .charts/ -name '*.tgz' -exec tar -xf {} -C charts/ \;
296271
297272
git add charts/**/*
298273
git commit -m "Update charts to version $version"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/.cache
33
/bin
44
/dist
5+
/.charts
56
*.swp
67
.idea
78
*.DS_Store

.goreleaser.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ env:
1111
release:
1212
prerelease: auto
1313
disable: "{{ .Env.IS_HOTFIX }}"
14+
extra_files:
15+
- glob: .charts/*.tgz
16+
17+
checksum:
18+
extra_files:
19+
- glob: .charts/*.tgz
1420

1521
changelog:
1622
disable: false
@@ -19,6 +25,7 @@ changelog:
1925
before:
2026
hooks:
2127
- go mod download
28+
- bash .github/scripts/package-charts.sh {{ .Tag }} {{ .Version }}
2229

2330
archives:
2431
- id: fleet-controller

0 commit comments

Comments
 (0)