From 8b5e6f0f2ce9de2162acf11c095d6d74af744a75 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 28 Sep 2023 18:02:06 +0200 Subject: [PATCH] ci-automation/image-changes: Do not expect HEAD commit to have a tag It certainly does happen on GitHub Actions that the HEAD commit has no tag. In such case, fake the tag from version file. The git tag in this scenario is used to figure out a channel transition. --- ci-automation/image_changes.sh | 39 ++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/ci-automation/image_changes.sh b/ci-automation/image_changes.sh index fe8ad0dd6e..7734d5b361 100644 --- a/ci-automation/image_changes.sh +++ b/ci-automation/image_changes.sh @@ -129,6 +129,42 @@ function git_tag_for_release() { git_tag_var_name=${1}; shift head_git_tag "${scripts_repo}" "${git_tag_var_name}" + + local -n git_tag_ref="${git_tag_var_name}" + local version_file version_id build_id minor_version channel + if [[ ${git_tag_ref} = 'HEAD' ]]; then + # Welp, we wanted to have something in form of + # --, fake something up from + # version file. Figuring out the channel is a heuristic at + # best. + version_file="${scripts_repo}/sdk_container/.repo/manifests/version.txt" + if [[ ! -e ${version_file} ]]; then + echo "The scripts repo at '${scripts_repo}' is messed up, has no version file" >&2 + exit 1 + fi + version_id=$(source "${version_file}"; printf '%s' "${FLATCAR_VERSION_ID}") + build_id=$(source "${version_file}"; printf '%s' "${FLATCAR_BUILD_ID}") + minor_version=${version_id#*.} + minor_version=${minor_version%.*} + case ${minor_version} in + 0) + channel=alpha + ;; + 1) + channel=beta + ;; + 2) + channel=stable + ;; + 3) + channel=lts + ;; + *) + channel=main + ;; + esac + git_tag_ref="${channel}-${version_id}-${build_id}" + fi } function head_git_tag() { @@ -138,8 +174,7 @@ function head_git_tag() { git_tag_ref=$(git -C "${scripts_repo}" tag --points-at HEAD) if [[ -z ${git_tag_ref} ]]; then - echo 'expected git HEAD commit to contain a tag' >&2 - exit 1 + git_tag_ref='HEAD' fi }