Check release tag version and chart versions during the release process (#2524)

Co-authored-by: Bassem Dghaidi <568794+Link-@users.noreply.github.com>
This commit is contained in:
Nikola Jokic 2023-05-03 11:53:42 +02:00 committed by GitHub
parent 41ebb43c65
commit 73e676f951
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 9 deletions

View File

@ -36,7 +36,7 @@ permissions:
packages: write
jobs:
build-push-image:
build-push-image:
name: Build and push controller image
runs-on: ubuntu-latest
steps:
@ -46,7 +46,14 @@ jobs:
# If inputs.ref is empty, it'll resolve to the default branch
ref: ${{ inputs.ref }}
- name: Resolve parameters
- name: Check chart versions
# Binary version and chart versions need to match.
# In case of an upgrade, the controller will try to clean up
# resources with older versions that should have been cleaned up
# during the upgrade process
run: ./hack/check-gh-chart-versions.sh ${{ inputs.release_tag_name }}
- name: Resolve parameters
id: resolve_parameters
run: |
resolvedRef="${{ inputs.ref }}"
@ -67,7 +74,7 @@ jobs:
uses: docker/setup-buildx-action@v2
with:
# Pinning v0.9.1 for Buildx and BuildKit v0.10.6
# BuildKit v0.11 which has a bug causing intermittent
# BuildKit v0.11 which has a bug causing intermittent
# failures pushing images to GHCR
version: v0.9.1
driver-opts: image=moby/buildkit:v0.10.6
@ -115,7 +122,7 @@ jobs:
# If inputs.ref is empty, it'll resolve to the default branch
ref: ${{ inputs.ref }}
- name: Resolve parameters
- name: Resolve parameters
id: resolve_parameters
run: |
resolvedRef="${{ inputs.ref }}"
@ -126,7 +133,7 @@ jobs:
echo "INFO: Resolving short SHA for $resolvedRef"
echo "short_sha=$(git rev-parse --short $resolvedRef)" >> $GITHUB_OUTPUT
echo "INFO: Normalizing repository name (lowercase)"
echo "repository_owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
echo "repository_owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Helm
# Using https://github.com/Azure/setup-helm/releases/tag/v3.5
@ -163,7 +170,7 @@ jobs:
# If inputs.ref is empty, it'll resolve to the default branch
ref: ${{ inputs.ref }}
- name: Resolve parameters
- name: Resolve parameters
id: resolve_parameters
run: |
resolvedRef="${{ inputs.ref }}"
@ -174,7 +181,7 @@ jobs:
echo "INFO: Resolving short SHA for $resolvedRef"
echo "short_sha=$(git rev-parse --short $resolvedRef)" >> $GITHUB_OUTPUT
echo "INFO: Normalizing repository name (lowercase)"
echo "repository_owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
echo "repository_owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Helm
# Using https://github.com/Azure/setup-helm/releases/tag/v3.5

2
.gitignore vendored
View File

@ -35,3 +35,5 @@ bin
.DS_STORE
/test-assets
/.tools

View File

@ -202,7 +202,7 @@ generate: controller-gen
# Run shellcheck on runner scripts
shellcheck: shellcheck-install
$(TOOLS_PATH)/shellcheck --shell bash --source-path runner runner/*.sh
$(TOOLS_PATH)/shellcheck --shell bash --source-path runner runner/*.sh hack/*.sh
docker-buildx:
export DOCKER_CLI_EXPERIMENTAL=enabled ;\

42
hack/check-gh-chart-versions.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
# Checks the chart versions against an input version. Fails on mismatch.
#
# Usage:
# check-gh-chart-versions.sh <VERSION>
set -eo pipefail
TEXT_RED='\033[0;31m'
TEXT_RESET='\033[0m'
TEXT_GREEN='\033[0;32m'
target_version=$1
if [[ $# -eq 0 ]]; then
echo "Release version argument is required"
echo
echo "Usage: ${0} <VERSION>"
exit 1
fi
chart_dir="$(pwd)/charts"
controller_version=$(yq .version < "${chart_dir}/gha-runner-scale-set-controller/Chart.yaml")
controller_app_version=$(yq .appVersion < "${chart_dir}/gha-runner-scale-set-controller/Chart.yaml")
scaleset_version=$(yq .version < "${chart_dir}/gha-runner-scale-set/Chart.yaml")
scaleset_app_version=$(yq .appVersion < "${chart_dir}/gha-runner-scale-set/Chart.yaml")
if [[ "${controller_version}" != "${target_version}" ]] ||
[[ "${controller_app_version}" != "${target_version}" ]] ||
[[ "${scaleset_version}" != "${target_version}" ]] ||
[[ "${scaleset_app_version}" != "${target_version}" ]]; then
echo -e "${TEXT_RED}Chart versions do not match${TEXT_RESET}"
echo "Target version: ${target_version}"
echo "Controller version: ${controller_version}"
echo "Controller app version: ${controller_app_version}"
echo "Scale set version: ${scaleset_version}"
echo "Scale set app version: ${scaleset_app_version}"
exit 1
fi
echo -e "${TEXT_GREEN}Chart versions: ${controller_version}"

View File

@ -2,7 +2,7 @@
COMMIT=$(git rev-parse HEAD)
TAG=$(git describe --exact-match --abbrev=0 --tags "${COMMIT}" 2> /dev/null || true)
BRANCH=$(git branch | grep \* | cut -d ' ' -f2 | sed -e 's/[^a-zA-Z0-9+=._:/-]*//g' || true)
BRANCH=$(git branch | grep "\*" | cut -d ' ' -f2 | sed -e 's/[^a-zA-Z0-9+=._:/-]*//g' || true)
VERSION=""
if [ -z "$TAG" ]; then