Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use auto bump functionality in release charts #3365

Merged
merged 4 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 41 additions & 33 deletions .github/scripts/release-against-charts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Submit new Fleet version against rancher/charts

set -ue
set -e

PREV_FLEET_VERSION="$1" # e.g. 0.5.2-rc.3
NEW_FLEET_VERSION="$2"
Expand All @@ -19,44 +19,52 @@ if [ ! -e ~/.gitconfig ]; then
git config --global user.email [email protected]
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" {} \;
if [[ "$(git rev-parse --abbrev-ref HEAD)" =~ dev-v2\.1[0-9]+ ]]; then
# Use new auto bump scripting until the Github action CI works as expected
# no parameters besides the target branch are needed in theory, but the pr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this comment, as those parameters seem to be very much required 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as the auto bump works as expected we do not need this script anymore to bump the charts.

I am using the command make chart-bump package=fleet branch="$(git rev-parse --abbrev-ref HEAD)" of the auto bump automation which extracts the latest fleet and chart version on its own, so nothing needs to be provided.

But since there was an issue we rely on our script which still needs these values for creating the pr. It would be possible to extract them too, but not worth it since it should be not needed in the future.

# creation still needs the new Chart and Fleet version
make chart-bump package=fleet branch="$(git rev-parse --abbrev-ref HEAD)"
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
# Sort keys in release.yaml
yq -i -P 'sort_keys(..)' release.yaml

# Adapt Gitjob version in generated patch
if grep -q '^- version: ' ./packages/fleet/fleet/generated-changes/patch/Chart.yaml.patch; then
GITJOB_VERSION=$(curl -s "https://raw.githubusercontent.com/rancher/fleet/v${NEW_FLEET_VERSION}/charts/fleet/charts/gitjob/Chart.yaml" | yq e .version)
sed -i -e "s/^- version: .*$/- version: ${GITJOB_VERSION}/" ./packages/fleet/fleet/generated-changes/patch/Chart.yaml.patch
fi
# For Rancher versions before 2.10 run the legacy implementation
if [ ! -f bin/charts-build-scripts ]; then
make pull-scripts
fi

git add packages/fleet release.yaml
git commit -m "Updating to Fleet v${NEW_FLEET_VERSION}"
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

if [ "${REPLACE}" == "true" ]; then
for i in fleet fleet-crd fleet-agent; do
CHART=$i VERSION=${PREV_CHART_VERSION}+up${PREV_FLEET_VERSION} make remove
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
fi
# Sort keys in release.yaml
yq -i -P 'sort_keys(..)' release.yaml

# Adapt Gitjob version in generated patch
if grep -q '^- version: ' ./packages/fleet/fleet/generated-changes/patch/Chart.yaml.patch; then
GITJOB_VERSION=$(curl -s "https://raw.githubusercontent.com/rancher/fleet/v${NEW_FLEET_VERSION}/charts/fleet/charts/gitjob/Chart.yaml" | yq e .version)
sed -i -e "s/^- version: .*$/- version: ${GITJOB_VERSION}/" ./packages/fleet/fleet/generated-changes/patch/Chart.yaml.patch
fi

git add packages/fleet release.yaml
git commit -m "Updating to Fleet v${NEW_FLEET_VERSION}"

PACKAGE=fleet make charts
git checkout release.yaml # reset unwanted changes to release.yaml, relevant ones are already part of the previous commit
git add assets/fleet* charts/fleet* index.yaml
git commit -m "Autogenerated changes for Fleet v${NEW_FLEET_VERSION}"
if [ "${REPLACE}" == "true" ]; then
for i in fleet fleet-crd fleet-agent; do
CHART=$i VERSION=${PREV_CHART_VERSION}+up${PREV_FLEET_VERSION} make remove
done
fi

PACKAGE=fleet make charts
git checkout release.yaml # reset unwanted changes to release.yaml, relevant ones are already part of the previous commit
git add assets/fleet* charts/fleet* index.yaml
git commit -m "Autogenerated changes for Fleet v${NEW_FLEET_VERSION}"
fi

PACKAGE=fleet make validate

Expand Down
9 changes: 0 additions & 9 deletions .github/scripts/release-against-test-charts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ 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
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/e2e-test-fleet-in-rancher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ name: Test Fleet in Rancher
on:
workflow_dispatch:
inputs:
ref:
description: "checkout git branch/tag"
required: true
default: "main"
type: string
charts_repo:
description: Repository from which to source Fleet charts
default: "fleetrepoci/charts"
Expand All @@ -22,11 +17,6 @@ on:
workflow_call:
# Variables to set when calling this reusable workflow
inputs:
ref:
description: "checkout git branch/tag"
required: true
default: "main"
type: string
charts_repo:
description: Repository from which to source Fleet charts
default: "fleetrepoci/charts"
Expand All @@ -46,7 +36,7 @@ env:
GOARCH: amd64
CGO_ENABLED: 0
SETUP_K3D_VERSION: 'v5.8.3'
SETUP_K3S_VERSION: 'v1.32.1-k3s1'
SETUP_K3S_VERSION: 'v1.31.1-k3s1'

jobs:
rancher-integration:
Expand All @@ -64,7 +54,6 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.ref }}

-
name: Install Go
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-against-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ on:
charts_ref:
description: "Submit PR against the following rancher/charts branch (e.g. dev-v2.7)"
required: true
default: "dev-v2.10"
default: "dev-v2.11"
prev_fleet:
description: "Previous Fleet version (e.g. 0.6.0-rc.3)"
required: true
required: false
default: ""
new_fleet:
description: "New Fleet version"
required: true
default: ""
prev_chart:
description: "Previous Rancher Chart version (e.g. 101.1.0)"
required: true
required: false
default: ""
new_chart:
description: "New Rancher Chart version"
required: true
default: ""
should_replace:
description: "Should the old Fleet version be replaced/removed? (e.g. true in case of release candidate bumps)"
required: true
required: false
default: "true"

jobs:
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/release-against-test-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ on:
- cron: '0 13 * * *'
workflow_dispatch:
inputs:
ref:
description: "Branch to use for GitHub action workflow"
required: true
default: "main"
charts_base_branch:
description: "Use the following rancher/charts branch as a base (e.g. dev-v2.7)"
required: true
Expand Down Expand Up @@ -37,24 +33,19 @@ jobs:
- name: Set environment variables
id: compute_env
run: |
tmp=${{github.event.inputs.ref}}
ref=${tmp:-${{github.ref}}}

tmp=${{github.event.inputs.charts_base_branch}}
charts_base_branch=${tmp:-'dev-v2.11'}

tmp=${{github.event.inputs.charts_repo}}
charts_repo=${tmp:-fleetrepoci/charts}

echo "ref=$ref" >> "$GITHUB_ENV"
echo "charts_base_branch=$charts_base_branch" >> "$GITHUB_OUTPUT"
echo "charts_repo=$charts_repo" >> "$GITHUB_OUTPUT"

- name: Checkout rancher/fleet
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.inputs.ref}}
path: fleet

- uses: actions/setup-go@v5
Expand Down Expand Up @@ -162,9 +153,9 @@ jobs:
run: |
fleet_test_version=9.9.9

latest_chart=$(grep '^version: ' ./charts/packages/fleet/fleet/package.yaml | cut -d' ' -f2)
latest_fleet=$(ls -1 ./charts/charts/fleet/ | grep $latest_chart)
latest_fleet=${latest_fleet#*+up}
latest_fleet_rancher_version=$(ls ./charts/charts/fleet/ | tail -1)
latest_chart="${latest_fleet_rancher_version%%+*}"
latest_fleet="${latest_fleet_rancher_version#*+up}"

./fleet/.github/scripts/release-against-test-charts.sh \
$latest_fleet \
Expand All @@ -182,7 +173,6 @@ jobs:
uses: ./.github/workflows/e2e-test-fleet-in-rancher.yml
needs: push-test-rancher-charts
with:
ref: ${{ github.ref }}
charts_repo: ${{ needs.push-test-rancher-charts.outputs.charts_repo }}
charts_branch: ${{ needs.push-test-rancher-charts.outputs.target_branch }}
fleet_version: 999.9.9+up9.9.9
Loading