ci-automation/sdk_bootstrap: Put some names into variables

Changing the name of the main branch and the name of the nightly tag
may be useful for testing, so let's have them defined in one place.
This commit is contained in:
Krzesimir Nowak 2023-09-28 15:50:45 +02:00 committed by Kai Lueke
parent 85a7cb4a32
commit 7c62b3cd53
2 changed files with 22 additions and 7 deletions

View File

@ -70,8 +70,16 @@ function _packages_tag_impl() {
# Also push the changes to the branch ONLY IF we're doing a nightly
# build of the 'flatcar-MAJOR' branch AND we're definitely ON the respective branch
local target_branch=''
if [[ "${version}" =~ ^(stable|alpha|beta|lts)-[0-9.]+-nightly-[-0-9]+$ ]] \
&& [[ "$(git rev-parse --abbrev-ref HEAD)" =~ ^flatcar-[0-9]+$ ]] ; then
# These variables are here to make it easier to test nightly
# builds without messing with actual release branches.
local flatcar_branch_prefix='flatcar'
local nightly='nightly'
# Patterns used below.
local nightly_pattern_1='^(stable|alpha|beta|lts)-[0-9.]+-'"${nightly}"'-[-0-9]+$'
local nightly_pattern_2='^(stable|alpha|beta|lts)-[0-9.]+(|-'"${nightly}"'-[-0-9]+)$'
local flatcar_pattern='^'"${flatcar_branch_prefix}"'-[0-9]+$'
if [[ "${version}" =~ ${nightly_pattern_1} ]] \
&& [[ "$(git rev-parse --abbrev-ref HEAD)" =~ ${flatcar_pattern} ]] ; then
target_branch="$(git rev-parse --abbrev-ref HEAD)"
local existing_tag=""
# Check for the existing tag only when we allow shortcutting
@ -83,7 +91,7 @@ function _packages_tag_impl() {
existing_tag=$(git tag --points-at HEAD) # exit code is always 0, output may be empty
fi
# If the found tag is a release or nightly tag, we stop this build if there are no changes
if [[ "${existing_tag}" =~ ^(stable|alpha|beta|lts)-[0-9.]+(|-nightly-[-0-9]+)$ ]]; then
if [[ "${existing_tag}" =~ ${nightly_pattern_2} ]]; then
local ret=0
git diff --exit-code "${existing_tag}" || ret=$?
if [[ ret -eq 0 ]]; then

View File

@ -79,9 +79,16 @@ function _sdk_bootstrap_impl() {
# build of the 'main' branch AND we're definitely ON the main branch.
# This includes intermediate SDKs when doing 2-phase nightly builds.
local target_branch=''
if [[ "${version}" =~ ^main-[0-9.]+-nightly-[-0-9]+(-INTERMEDIATE)?$ ]] \
&& [ "$(git rev-parse HEAD)" = "$(git rev-parse origin/main)" ] ; then
target_branch='main'
# These variables are here to make it easier to test nightly
# builds without messing with actual release branches.
local main_branch='main'
local nightly='nightly'
# Patterns used below.
local nightly_pattern_1='^main-[0-9.]+-'"${nightly}"'-[-0-9]+(-INTERMEDIATE)?$'
local nightly_pattern_2='^main-[0-9.]+-'"${nightly}"'-[-0-9]+$'
if [[ "${version}" =~ ${nightly_pattern_1} ]] \
&& [ "$(git rev-parse HEAD)" = "$(git rev-parse "origin/${main_branch}")" ] ; then
target_branch=${main_branch}
local existing_tag=""
# Check for the existing tag only when we allow shortcutting
# the builds. That way we can skip the checks for build
@ -92,7 +99,7 @@ function _sdk_bootstrap_impl() {
existing_tag=$(git tag --points-at HEAD) # exit code is always 0, output may be empty
fi
# If the found tag is a nightly tag, we stop this build if there are no changes
if [[ "${existing_tag}" =~ ^main-[0-9.]+-nightly-[-0-9]+$ ]]; then
if [[ "${existing_tag}" =~ ${nightly_pattern_2} ]]; then
local ret=0
git diff --exit-code "${existing_tag}" || ret=$?
if [ "$ret" = "0" ]; then