Skip to content

Commit 428237a

Browse files
authored
Make sure GoReleaser provides fleet-helm charts checksums too (#4975)
* Make sure GoReleaser signs fleet-helm charts too
1 parent 595d66f commit 428237a

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
@@ -243,31 +243,6 @@ jobs:
243243
echo ""
244244
echo "✓ Provenance attestation completed for all images"
245245
246-
- name: Upload charts to release
247-
if: ${{ env.IS_HOTFIX == 'false' }}
248-
env:
249-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250-
repo: "rancher"
251-
run: |
252-
version=$(jq -r '.version' <<< '${{ steps.goreleaser.outputs.metadata }}')
253-
tag=$(jq -r '.tag' <<< '${{ steps.goreleaser.outputs.metadata }}')
254-
echo "publishing helm chart for (repo: $repo, tag: $tag, version: $version)"
255-
256-
# Replace rancher/fleet and rancher/fleet-agent and rancher/gitjob image names
257-
sed -i \
258-
-e "s@repository: rancher/\(fleet.*\|gitjob\).*@repository: $repo/\\1@" \
259-
-e "s/tag:.*/tag: $tag/" \
260-
charts/fleet/values.yaml
261-
262-
sed -i \
263-
-e "s@repository: rancher/\(fleet.*\|gitjob\).*@repository: $repo/\\1@" \
264-
-e "s/tag: dev/tag: $tag/" \
265-
charts/fleet-agent/values.yaml
266-
267-
find charts/ -maxdepth 1 -mindepth 1 -type d -exec helm package --version="$version" --app-version="$version" -d ./dist {} \;
268-
269-
find dist/ -name '*.tgz' -exec gh release upload "$tag" {} +
270-
271246
- name: Add charts to branch
272247
if: ${{ env.IS_HOTFIX == 'false' }}
273248
env:
@@ -300,7 +275,7 @@ jobs:
300275
fi
301276
302277
mkdir -p charts
303-
find dist/ -name '*.tgz' -exec tar -xf {} -C charts/ \;
278+
find .charts/ -name '*.tgz' -exec tar -xf {} -C charts/ \;
304279
305280
git add charts/**/*
306281
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)