Skip to content

Commit f0f54dd

Browse files
committed
Adjust release scripts to work with scripts as monorepo
The change prepared in flatcar/scripts#699 means that we don't use the coreos-overlay/portage-stable repos anymore. Skip these repositories and the submodule handling, too. Leave existing logic there to support doing releases the old way (at least for the nearer future).
1 parent 34a1687 commit f0f54dd

File tree

3 files changed

+46
-17
lines changed

3 files changed

+46
-17
lines changed

mirror-repos-branch

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ trap '{ export EXT="$?"; rm -rf "${REPOS_DIR}" && exit "${EXT}"; }' EXIT
4141

4242
cd "${REPOS_DIR}"
4343

44+
# Check if we are in the monorepo case
45+
[ ! -d scripts ] && git clone --recurse-submodules "git@github.com:flatcar/scripts"
46+
if [ "$(git -C scripts show "origin/${SRC_BUILD_BRANCH}":.gitmodules 2>/dev/null)" = "" ]; then
47+
FLATCAR_REPOS=("scripts")
48+
fi
49+
4450
for repo in "${FLATCAR_REPOS[@]}"; do
4551
# Note: systemd repo has neither flatcar-build-* branches nor flatcar-master
4652
# branch. So we should skip systemd completely.
@@ -62,7 +68,7 @@ for repo in "${FLATCAR_REPOS[@]}"; do
6268
fi
6369

6470
echo "Mirroring a branch ${src_branch} to ${DST_BUILD_BRANCH}"
65-
git checkout -B "${DST_BUILD_BRANCH}" "origin/${src_branch}"
71+
git checkout --recurse-submodules --force -B "${DST_BUILD_BRANCH}" "origin/${src_branch}"
6672
git push ${PUSH_OPTIONS} origin "${DST_BUILD_BRANCH}"
6773

6874
popd

show-changes

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,31 +55,37 @@ for section in security bugfixes changes updates; do
5555
OLDREF="${OLD}"
5656
NEWREF="${NEW}"
5757
REPOPATH="${repo}"
58+
PREPEND=""
5859
# For the submodule detection, assume that the "scripts" repo name is ok
59-
if [ "${repo}" != "scripts" ] && [ -d "scripts/sdk_container/src/third_party/${repo}" ]; then
60+
if [ "${repo}" != "scripts" ]; then
6061
if [ "${FETCH}" = 1 ]; then
6162
git -C "scripts" fetch -t -f 2> /dev/null > /dev/null || { echo "Error: git fetch -t -f failed" ; exit 1 ; }
6263
fi
63-
# Find the pinned submodule refs because there may be no release tags inside the submodules
64-
# Pipe to awk instead of using --object-only for git 2.35 support
65-
OLDREF=$(git -C "scripts" ls-tree "${OLD}" "sdk_container/src/third_party/${repo}" | awk '{print $3 }')
66-
NEWREF=$(git -C "scripts" ls-tree "${NEW}" "sdk_container/src/third_party/${repo}" | awk '{print $3 }')
67-
REPOPATH="scripts/sdk_container/src/third_party/${repo}"
64+
# Check if we are in the monorepo case where we can use the scripts ref or not
65+
if [ "$(git -C scripts show "${OLD}":.gitmodules 2>/dev/null)" != "" ]; then
66+
# Find the pinned submodule refs because there may be no release tags inside the submodules
67+
# Pipe to awk instead of using --object-only for git 2.35 support
68+
OLDREF=$(git -C "scripts" ls-tree "${OLD}" "sdk_container/src/third_party/${repo}" | awk '{print $3 }')
69+
NEWREF=$(git -C "scripts" ls-tree "${NEW}" "sdk_container/src/third_party/${repo}" | awk '{print $3 }')
70+
REPOPATH="scripts/sdk_container/src/third_party/${repo}"
71+
else
72+
PREPEND="sdk_container/src/third_party/${repo}/"
73+
fi
6874
fi
6975
if [ "${FETCH}" = 1 ]; then
7076
git -C "${REPOPATH}" fetch -t -f 2> /dev/null > /dev/null || { echo "Error: git fetch -t -f failed" ; exit 1 ; }
7177
fi
7278
if [ "${section}" = "security" ] && [ "${repo}" = "coreos-overlay" ]; then
73-
FROM_KERNEL=$(git -C "${REPOPATH}" show "${OLDREF}":sys-kernel/coreos-kernel/ | grep -m 1 'coreos-kernel-.*\.ebuild' | cut -d - -f 3 | cut -d . -f 1-3)
74-
TO_KERNEL=$(git -C "${REPOPATH}" show "${NEWREF}":sys-kernel/coreos-kernel/ | grep -m 1 'coreos-kernel-.*\.ebuild' | cut -d - -f 3 | cut -d . -f 1-3)
79+
FROM_KERNEL=$(git -C "${REPOPATH}" show "${OLDREF}":"${PREPEND}"sys-kernel/coreos-kernel/ | grep -m 1 'coreos-kernel-.*\.ebuild' | cut -d - -f 3 | cut -d . -f 1-3)
80+
TO_KERNEL=$(git -C "${REPOPATH}" show "${NEWREF}":"${PREPEND}"sys-kernel/coreos-kernel/ | grep -m 1 'coreos-kernel-.*\.ebuild' | cut -d - -f 3 | cut -d . -f 1-3)
7581
if [ "${FROM_KERNEL}" != "${TO_KERNEL}" ]; then
7682
KERNEL_ENTRIES=$("${SCRIPTFOLDER}"/show-fixed-kernel-cves.py -f "${FROM_KERNEL}" -t "${TO_KERNEL}")
7783
if [ "${KERNEL_ENTRIES}" != "" ]; then
7884
echo "- Linux (${KERNEL_ENTRIES})"
7985
fi
8086
fi
8187
fi
82-
git -C "${REPOPATH}" difftool --no-prompt --extcmd='sh -c "cat \"$REMOTE\"" --' "${OLDREF}..${NEWREF}" -- "changelog/${section}/" | sort || { echo "Error: git difftool failed" ; exit 1 ; }
88+
git -C "${REPOPATH}" difftool --no-prompt --extcmd='sh -c "cat \"$REMOTE\"" --' "${OLDREF}..${NEWREF}" -- "${PREPEND}changelog/${section}/" | sort || { echo "Error: git difftool failed" ; exit 1 ; }
8389
# The -x 'sh -c "cat \"$REMOTE\"" --' command assumes that new changes have their own changelog files,
8490
# and thus ignores the LOCAL file (which is the empty /dev/null) and prints out the REMOTE completly.
8591
# If an existing file got changed, we assume that this is just a correction for the old change but

tag-release

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ echo "SCRIPTS_REF=$SCRIPTS_REF OVERLAY_REF=$OVERLAY_REF PORTAGE_REF=$PORTAGE_REF
3636
REPOS="coreos-overlay portage-stable scripts"
3737
# scripts should be last as it binds the other two together as submodules, if they exist
3838

39+
# Check if we are in the monorepo, in this case only work on "scripts"
40+
cd "$SCRIPTFOLDER/.."
41+
if [ ! -d "scripts" ]; then
42+
git clone --recurse-submodules 'git@github.com:flatcar/scripts.git'
43+
fi
44+
git -C scripts fetch origin
45+
if [ "$(git -C scripts show "origin/$MAINT-$MAJOR":.gitmodules 2>/dev/null)" = "" ]; then
46+
REPOS="scripts"
47+
fi
48+
49+
3950
for REPO in ${REPOS}; do
4051
echo "Preparing ${REPO}"
4152
cd "$SCRIPTFOLDER/.."
@@ -52,13 +63,17 @@ for REPO in ${REPOS}; do
5263
git tag -d "$TAG" || echo "No local tags deleted"
5364
git push --delete origin "$TAG" || echo "No remote tags deleted"
5465
# Check if we have to update the submodules while tagging
55-
if [ "${REPO}" = "scripts" ] && git show "origin/$MAINT-$MAJOR":sdk_container/src > /dev/null 2>/dev/null ; then
66+
if [ "${REPO}" = "scripts" ]; then
5667
if [ "${REF}" != "origin/$MAINT-$MAJOR" ]; then
5768
echo "Error: can't find the scripts branch to push the updated submodule to, you can't overwrite SCRIPTS_REF anymore"
5869
exit 1
5970
fi
60-
echo "Checking out scripts branch $MAINT-$MAJOR to update submodules"
61-
git checkout --recurse-submodules -B "$MAINT-$MAJOR" "origin/$MAINT-$MAJOR" || { echo "Error: could not checkout the right branch in your 'scripts' repo" ; exit 1 ; }
71+
if [ "$(git status --porcelain)" != "" ]; then
72+
echo "Error: uncommitted changes found which will be lost"
73+
exit 1
74+
fi
75+
echo "Checking out scripts branch $MAINT-$MAJOR to update submodules and create version file"
76+
git checkout --force --recurse-submodules -B "$MAINT-$MAJOR" "origin/$MAINT-$MAJOR" || { echo "Error: could not checkout the right branch in your 'scripts' repo" ; exit 1 ; }
6277
git pull --recurse-submodules || { echo "Error: could not pull the branch in your 'scripts' repo" ; exit 1 ; }
6378
if [ "$(git log HEAD.."origin/$MAINT-$MAJOR")" != "" ] || ! git diff --quiet "origin/$MAINT-$MAJOR" ; then
6479
echo "Error: local changes in your 'scripts' repo"
@@ -68,14 +83,16 @@ for REPO in ${REPOS}; do
6883
(
6984
source sdk_lib/sdk_container_common.sh
7085
source ci-automation/ci_automation_common.sh
71-
cd "sdk_container/src/third_party/coreos-overlay"; git fetch --all --tags --force; cd -
72-
cd "sdk_container/src/third_party/portage-stable"; git fetch --all --tags --force; cd -
73-
update_submodules "${OVERLAY_REF}" "${PORTAGE_REF}"
86+
if [ "$(git show "origin/$MAINT-$MAJOR":.gitmodules 2>/dev/null)" != "" ]; then
87+
cd "sdk_container/src/third_party/coreos-overlay"; git fetch --all --tags --force; cd -
88+
cd "sdk_container/src/third_party/portage-stable"; git fetch --all --tags --force; cd -
89+
update_submodules "${OVERLAY_REF}" "${PORTAGE_REF}"
90+
fi
7491
create_versionfile "${SDK_VERSION}" "${VERSION}"
7592
SIGN=1 update_and_push_version "${TAG}" true
7693
)
7794
else
78-
# Tag the other repos or the LTS scripts repo
95+
# Tag the other repos
7996
echo "Tagging ${REF} as ${TAG}"
8097
git tag -s "${TAG}" -m "${TAG}" "${REF}"
8198
echo "Pushing tag"

0 commit comments

Comments
 (0)