You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ci-automation: Update sdk-bootstrap, packages-tag and upload functions
- Tighten the patterns used for nightly tags detection.
- Compare hashes instead of names to figure out if we are on top of a
branch (fixes the issue of no nightly tags reachable from the
release branches). Jenkins is doing `git fetch origin "${branch}";
git checkout FETCH_HEAD` and this was confusing the `git rev-parse
--abbrev-ref HEAD` code (it returned `HEAD` instead of `${branch}`).
- Account for possible multiple tags in a single commit.
- Made the tagging fail in dubious situations.
- Reindent the code, modernize a bit.
if [[ $(git rev-parse HEAD)!="${branch_hash}" ]];then
93
+
echo"We are doing a nightly build but we are not on top of the ${branch_name} branch. This is wrong and would result in the nightly tag not being a part of the branch.">&2
94
+
exit 1
95
+
fi
96
+
target_branch=${branch_name}
88
97
# Check for the existing tag only when we allow shortcutting
89
98
# the builds. That way we can skip the checks for build
90
99
# shortcutting.
91
100
if bool_is_true "${AVOID_NIGHTLY_BUILD_SHORTCUTS}";then
92
101
echo"Continuing the build because AVOID_NIGHTLY_BUILD_SHORTCUTS is bool true (${AVOID_NIGHTLY_BUILD_SHORTCUTS})">&2
93
102
else
94
-
existing_tag=$(git tag --points-at HEAD)# exit code is always 0, output may be empty
103
+
git fetch --all --tags --force
104
+
# exit code of git tag is always 0; output may be empty,
105
+
# but may also have multiple tags
106
+
mapfile -t existing_tags <<(git tag --points-at HEAD)
95
107
fi
96
-
# If the found tag is a release or nightly tag, we stop this build if there are no changes
97
-
if [[ "${existing_tag}"=~${nightly_pattern_2} ]];then
98
-
local ret=0
99
-
git diff --exit-code "${existing_tag}"|| ret=$?
100
-
if [[ ret -eq 0 ]];then
108
+
fi
109
+
local nightly_or_release_tag=''
110
+
if [[ major_version -gt 0 &&${#existing_tags[@]}-gt 0 ]];then
111
+
local nightly_or_release_pattern='^(stable|alpha|beta|lts)-'"${major_version}"'(\.[0-9]+){2}(-'"${nightly}"'-[0-9]{8}-[0-9]{4})?$'
112
+
local tag
113
+
fortagin"${existing_tags[@]}";do
114
+
if [[ ${tag}=~${nightly_or_release_pattern} ]];then
115
+
nightly_or_release_tag=${tag}
116
+
break
117
+
fi
118
+
done
119
+
fi
120
+
# If the found tag is a release or nightly tag, we stop this build
121
+
# if there are no changes and the relevant images can be found in
echo"Creating ./skip-build flag file, indicating that the build must not to continue because no new tag got created as there are no changes since tag ${existing_tag} and the Flatcar images exist">&2
133
+
echo"Creating ./skip-build flag file, indicating that the build must not to continue because no new tag got created as there are no changes since tag ${nightly_or_release_tag} and the Flatcar images exist">&2
106
134
return 0
107
135
fi
108
136
echo"No changes but continuing build because Flatcar images do not exist"
109
-
elif [[ ret -eq 1 ]];then
110
-
echo"Found changes since last tag ${existing_tag}">&2
111
-
else
137
+
elif [[ ret -eq 1 ]];then
138
+
echo"HEAD is tagged with a nightly tag and yet there a differences? This is fishy and needs to be investigated. Maybe you forgot to commit your changes?">&2
if [[ $(git rev-parse HEAD)!="${main_branch_hash}" ]] ;then
100
+
echo"We are doing a nightly build but we are not on top of the ${main_branch} branch. This is wrong and would result in the nightly tag not being a part of the branch.">&2
101
+
exit 1
102
+
fi
94
103
target_branch=${main_branch}
95
-
local existing_tag=""
96
-
# Check for the existing tag only when we allow shortcutting
97
-
# the builds. That way we can skip the checks for build
98
-
# shortcutting.
104
+
# Check for the existing tag only when we allow
105
+
# shortcutting the builds. That way we can skip the checks
106
+
# for build shortcutting.
99
107
if bool_is_true "${AVOID_NIGHTLY_BUILD_SHORTCUTS}";then
100
108
echo"Continuing the build because AVOID_NIGHTLY_BUILD_SHORTCUTS is bool true (${AVOID_NIGHTLY_BUILD_SHORTCUTS})">&2
101
109
else
102
-
existing_tag=$(git tag --points-at HEAD)# exit code is always 0, output may be empty
110
+
git fetch --all --tags --force
111
+
# exit code is always 0, output may be empty
112
+
mapfile -t existing_tags <<(git tag --points-at HEAD)
103
113
fi
104
-
# If the found tag is a nightly tag, we stop this build if there are no changes
105
-
if [[ "${existing_tag}"=~${nightly_pattern_2} ]];then
106
-
local ret=0
107
-
git diff --exit-code "${existing_tag}"|| ret=$?
108
-
if [ "$ret"="0" ];then
109
-
local versions=(
110
-
$(
111
-
source sdk_lib/sdk_container_common.sh
112
-
source"${sdk_container_common_versionfile}"
113
-
echo"${FLATCAR_SDK_VERSION}"
114
-
echo"${FLATCAR_VERSION}"
115
-
)
114
+
fi
115
+
local nightly_pattern_2='^main-[0-9]+(\.[0-9]+){2}-'"${nightly}"'-[0-9]{8}-[0-9]{4}$'
116
+
local tag nightly_tag=''
117
+
fortagin"${existing_tags[@]}";do
118
+
if [[ ${tag}=~${nightly_pattern_2} ]];then
119
+
nightly_tag=${tag}
120
+
break
121
+
fi
122
+
done
123
+
# If the found tag is a nightly tag, we stop this build if there
124
+
# are no changes and the relevant images can be found in the
echo"Stopping build because there are no changes since tag ${existing_tag}, the SDK container tar ball and the Flatcar images exist">&2
146
+
echo"Stopping build because there are no changes since tag ${nightly_tag}, the SDK container tar ball and the Flatcar images exist">&2
126
147
return 0
127
148
fi
128
149
echo"No changes but continuing build because SDK container tar ball and/or the Flatcar images do not exist">&2
129
-
elif [ "$ret"="1" ];then
130
-
echo"Found changes since last tag ${existing_tag}">&2
131
-
else
150
+
elif [[ ret -eq 1 ]];then
151
+
echo"HEAD is tagged with a nightly tag and yet there a differences? This is fishy and needs to be investigated. Maybe you forgot to commit your changes?">&2
0 commit comments