diff --git a/ci-automation/packages-tag.sh b/ci-automation/packages-tag.sh index 2a7408e817..053f893546 100644 --- a/ci-automation/packages-tag.sh +++ b/ci-automation/packages-tag.sh @@ -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 diff --git a/ci-automation/sdk_bootstrap.sh b/ci-automation/sdk_bootstrap.sh index 8b9c719ffc..d7390c0833 100644 --- a/ci-automation/sdk_bootstrap.sh +++ b/ci-automation/sdk_bootstrap.sh @@ -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