Skip to content

Commit 1e7d447

Browse files
Make it magical
Signed-off-by: Michi Mutsuzaki <[email protected]>
1 parent a043afd commit 1e7d447

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
on:
2+
pull_request: {}
3+
4+
name: Generate Cilium Helm chart
5+
6+
jobs:
7+
build:
8+
env:
9+
# Just imagine this version comes from somewhere.
10+
VERSION: v1.16.0-pre.1
11+
name: Generate Cilium Helm chart
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
16+
17+
# Top level Makefile.defs runs go. struggle.
18+
- name: Set up Go
19+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
20+
with:
21+
go-version: 1.22.2
22+
23+
- name: Generate Cilium Helm chart
24+
run: |
25+
git config user.email "[email protected]"
26+
git config user.name "Cilium Bot"
27+
./magical-script.sh "${VERSION}"
28+
helm inspect chart cilium-"${VERSION:1}".tgz
29+
git show

magical-script.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
shopt -s expand_aliases
5+
6+
DOCKER=${DOCKER:-docker}
7+
8+
cosign() {
9+
"${DOCKER}" run --rm gcr.io/projectsigstore/cosign:v2.2.4 "$@"
10+
}
11+
12+
helm() {
13+
"${DOCKER}" run --user "$(id -u):$(id -g)" --rm -v "$(pwd)":/apps alpine/helm:3.12.0 "$@"
14+
}
15+
16+
jq () {
17+
"${DOCKER}" run --rm -i ghcr.io/jqlang/jq:1.7.1 "$@"
18+
}
19+
20+
CWD=$(git rev-parse --show-toplevel)
21+
version=$1
22+
semver="${version:1}"
23+
chart_dir="cilium/install/kubernetes"
24+
rm -rf cilium
25+
git clone --depth 1 --branch "$version" https://github.com/cilium/cilium.git
26+
cd "${chart_dir}" || exit
27+
grep export < Makefile.digests | while IFS= read -r line; do
28+
variable_name=$(echo "$line" | cut -d ' ' -f 2)
29+
image=$(echo "$variable_name" | sed -e "s/_DIGEST$//" | tr '[:upper:]' '[:lower:]' | tr '_' '-')
30+
digest=$(cosign verify --certificate-github-workflow-repository cilium/cilium \
31+
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
32+
--certificate-github-workflow-name "Image Release Build" \
33+
--certificate-github-workflow-ref "refs/tags/${version}" \
34+
--certificate-identity "https://github.com/cilium/cilium/.github/workflows/build-images-releases.yaml@refs/tags/${version}" \
35+
"quay.io/cilium/${image}:${version}" 2>/dev/null | jq '.[].critical.image.["docker-manifest-digest"]')
36+
echo "export $variable_name := $digest" >> Makefile.digests.tmp
37+
done
38+
mv Makefile.digests.tmp Makefile.digests
39+
# TODO i don't want to have to specify CILIUM_BRANCH. struggle.
40+
make RELEASE=yes CILIUM_BRANCH=main CILIUM_VERSION="${version}"
41+
git --no-pager diff
42+
helm package cilium
43+
cd -
44+
helm repo index --merge index.yaml cilium/install/kubernetes
45+
mv "${chart_dir}"/cilium-"${semver}".tgz "${chart_dir}"/index.yaml "${CWD}"
46+
./generate_readme.sh > README.md
47+
git add README.md index.yaml cilium-"${semver}".tgz
48+
git commit -s -m "Add cilium $version@$(cd cilium; git rev-parse HEAD)"

0 commit comments

Comments
 (0)