From 7cadae957aee86c764c116f9de8d290957058144 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Wed, 23 Feb 2022 20:41:57 +0100 Subject: [PATCH 1/3] ci-automation: SDK build updates version.txt in main branch This change has sdk_bootstrap update the origin branch when run from the main branch, updating the SDK and OS version in 'main' for each SDK bootstrap build. Release / maintenance branches have the SDK version set in the versionfile at release time. But main is never updated. Updating the versionfile in main when a new SDK is built ensures that dev branches based on main will also use the correct SDK version (e.g. in subsequent CI builds). --- ci-automation/ci_automation_common.sh | 6 ++++-- ci-automation/sdk_bootstrap.sh | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ci-automation/ci_automation_common.sh b/ci-automation/ci_automation_common.sh index e98a44ca45..181821ad92 100644 --- a/ci-automation/ci_automation_common.sh +++ b/ci-automation/ci_automation_common.sh @@ -48,6 +48,7 @@ function update_submodules() { function update_and_push_version() { local version="$1" + local push_to_branch="${2:-false}" # set up author and email so git does not complain when tagging if ! git config --get user.name >/dev/null 2>&1 ; then @@ -71,8 +72,9 @@ function update_and_push_version() { git tag -f "${TAG_ARGS[@]}" "${version}" - if [ "${PUSH-0}" = 1 ]; then - git push + if [ "${push_to_branch}" = "true" ]; then + local branch="$(git rev-parse --abbrev-ref HEAD)" + git push origin "${branch}" fi if git push origin "${version}" ; then diff --git a/ci-automation/sdk_bootstrap.sh b/ci-automation/sdk_bootstrap.sh index 085e67e5f5..d7b14effad 100644 --- a/ci-automation/sdk_bootstrap.sh +++ b/ci-automation/sdk_bootstrap.sh @@ -84,7 +84,13 @@ function sdk_bootstrap() { copy_to_buildcache "sdk/${ARCH}/${vernum}" "${dest_tarball}"* cd - - # Create new tag in scripts repo w/ updated versionfile + submodules - update_and_push_version "sdk-${git_vernum}" + # Create new tag in scripts repo w/ updated versionfile + submodules. + # When on the 'main' branch then also push to the branch so the versionfile + # and git submodules stay up to date. + local push_branch="false" + if [ "$(git rev-parse --abbrev-ref HEAD)" = "main" ] ; then + push_branch="true" + fi + update_and_push_version "sdk-${git_vernum}" "${push_branch}" } # -- From 82da911c27b8978baf87b535d3f014730183293f Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Thu, 24 Feb 2022 11:02:34 +0100 Subject: [PATCH 2/3] ci-automation/sdk_bootstrap: Only push to main in nightlies Signed-off-by: Thilo Fromm --- ci-automation/sdk_bootstrap.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ci-automation/sdk_bootstrap.sh b/ci-automation/sdk_bootstrap.sh index d7b14effad..c0758e3e3c 100644 --- a/ci-automation/sdk_bootstrap.sh +++ b/ci-automation/sdk_bootstrap.sh @@ -85,10 +85,11 @@ function sdk_bootstrap() { cd - # Create new tag in scripts repo w/ updated versionfile + submodules. - # When on the 'main' branch then also push to the branch so the versionfile - # and git submodules stay up to date. + # Also push the changes to the branch ONLY IF we're doing a nightly + # build of the 'main' branch AND we're definitely ON the main branch. local push_branch="false" - if [ "$(git rev-parse --abbrev-ref HEAD)" = "main" ] ; then + if [[ "${version}" =~ ^main-[0-9.]+-nightly-[-0-9]+$ ]] \ + && [ "$(git rev-parse --abbrev-ref HEAD)" = "main" ] ; then push_branch="true" fi update_and_push_version "sdk-${git_vernum}" "${push_branch}" From 308a2a2ab6c5c35ffa507603ba87fe2666eb2a6a Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Thu, 24 Feb 2022 12:06:28 +0100 Subject: [PATCH 3/3] ci-automation/sdk_bootstrap: check submodules for nightly branch push Signed-off-by: Thilo Fromm --- ci-automation/sdk_bootstrap.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ci-automation/sdk_bootstrap.sh b/ci-automation/sdk_bootstrap.sh index c0758e3e3c..c8b33df9f4 100644 --- a/ci-automation/sdk_bootstrap.sh +++ b/ci-automation/sdk_bootstrap.sh @@ -86,10 +86,13 @@ function sdk_bootstrap() { # Create new tag in scripts repo w/ updated versionfile + submodules. # Also push the changes to the branch ONLY IF we're doing a nightly - # build of the 'main' branch AND we're definitely ON the main branch. + # build of the 'main' branch AND we're definitely ON the main branch + # (`scripts` and submodules). local push_branch="false" if [[ "${version}" =~ ^main-[0-9.]+-nightly-[-0-9]+$ ]] \ - && [ "$(git rev-parse --abbrev-ref HEAD)" = "main" ] ; then + && [ "$(git rev-parse --abbrev-ref HEAD)" = "main" ] \ + && [ "$(git -C sdk_container/src/third_party/coreos-overlay/ rev-parse --abbrev-ref HEAD)" = "main" ] \ + && [ "$(git -C sdk_container/src/third_party/portage-stable/ rev-parse --abbrev-ref HEAD)" = "main" ] ; then push_branch="true" fi update_and_push_version "sdk-${git_vernum}" "${push_branch}"