From 56664a76199a9c4220155cfd54f36c718b9c8454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20N=C3=A9au?= Date: Wed, 3 Jul 2024 10:23:11 +0200 Subject: [PATCH] [TMP] Add scripts needed for test release This commit is only relevant to release test charts for this branch and test it within Rancher 2.8. It can be, and should be, safely reverted afterwards. --- .github/scripts/build-fleet-binaries.sh | 15 ++++ .../scripts/release-against-test-charts.sh | 75 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 .github/scripts/build-fleet-binaries.sh create mode 100644 .github/scripts/release-against-test-charts.sh diff --git a/.github/scripts/build-fleet-binaries.sh b/.github/scripts/build-fleet-binaries.sh new file mode 100644 index 0000000000..4b914f233e --- /dev/null +++ b/.github/scripts/build-fleet-binaries.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Description: build fleet binary and image with debug flags + +set -euxo pipefail + +export GOARCH="${GOARCH:-amd64}" +export CGO_ENABLED=0 +export GOOS=linux + +# fleet +go build -gcflags='all=-N -l' -o bin/fleetcontroller-linux-"$GOARCH" ./cmd/fleetcontroller + +# fleet agent +go build -gcflags='all=-N -l' -o "bin/fleet-linux-$GOARCH" ./cmd/fleetcli +go build -gcflags='all=-N -l' -o "bin/fleetagent-linux-$GOARCH" ./cmd/fleetagent diff --git a/.github/scripts/release-against-test-charts.sh b/.github/scripts/release-against-test-charts.sh new file mode 100644 index 0000000000..7feb1b8629 --- /dev/null +++ b/.github/scripts/release-against-test-charts.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# +# Submit new Fleet version against a test fork of rancher/charts + +set -ue + +PREV_FLEET_VERSION="$1" # e.g. 0.5.2-rc.3 +NEW_FLEET_VERSION="$2" +PREV_CHART_VERSION="$3" # e.g. 101.2.0 +NEW_CHART_VERSION="$4" +UUID="$5" # for ttl.sh image resolution + +if [ -z "${GITHUB_WORKSPACE:-}" ]; then + CHARTS_DIR="$(dirname -- "$0")/../../../charts" +else + CHARTS_DIR="${GITHUB_WORKSPACE}/charts" +fi + +pushd "${CHARTS_DIR}" > /dev/null + +if [ ! -e ~/.gitconfig ]; then + git config --global user.name "fleet-bot" + git config --global user.email fleet@suse.de +fi + +if [ ! -f bin/charts-build-scripts ]; then + make pull-scripts +fi + +if grep -q "version: ${PREV_CHART_VERSION}" ./packages/fleet/fleet/package.yaml && grep -q "${PREV_FLEET_VERSION}" ./packages/fleet/fleet/package.yaml; then + + find ./packages/fleet/ -type f -exec sed -i -e "s/${PREV_FLEET_VERSION}/${NEW_FLEET_VERSION}/g" {} \; + find ./packages/fleet/ -type f -exec sed -i -e "s/version: ${PREV_CHART_VERSION}/version: ${NEW_CHART_VERSION}/g" {} \; +else + echo "Previous Fleet version references do not exist in ./packages/fleet/ so replacing it with the new version is not possible. Exiting..." + exit 1 +fi + +for i in fleet fleet-crd fleet-agent; do + yq --inplace "del( .${i}.[] | select(. == \"${PREV_CHART_VERSION}+up${PREV_FLEET_VERSION}\") )" release.yaml + yq --inplace ".${i} += [\"${NEW_CHART_VERSION}+up${NEW_FLEET_VERSION}\"]" release.yaml +done + +git add packages/fleet release.yaml +git commit -m "Updating to Fleet v${NEW_FLEET_VERSION}" + +NEW_FULL_VERSION=${NEW_CHART_VERSION}+up${NEW_FLEET_VERSION} + +for suffix in '' '-agent' '-crd'; do + chart_dir=charts/fleet$suffix/${NEW_FULL_VERSION} + mkdir -p $chart_dir + cp -r ../fleet/charts/fleet$suffix/* $chart_dir + cd $chart_dir + + # Replace rancher/fleet and rancher/fleet-agent image names, but not eg. rancher/kubectl + sed -i \ + -e "s@repository: rancher/\(fleet.*\).*@repository: ttl.sh/rancher-\\1-$UUID@" \ + -e "s/tag: dev/tag: 1h/" \ + values.yaml + + cd - + + helm package \ + --version="$NEW_FULL_VERSION" \ + --app-version="$NEW_FLEET_VERSION" \ + -d ./assets/fleet$suffix \ + $chart_dir +done + +make index # Merge new chart entries into `index.yaml` + +git add assets/fleet* charts/fleet* index.yaml +git commit -m "Autogenerated changes for Fleet v${NEW_FLEET_VERSION}" + +popd > /dev/null