|
| 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