16
16
17
17
# This script is executed in the Update-Bot container.
18
18
# It checks if the Dockerfile for the build container has changed.
19
- # If so, it uses the version of the main branch as the basis for creating a new image tag.
20
- # The script also checks if the image tag for the build image exists in the main branch.
21
- # We assume that only one branch and one PR will be created for the changes in the build container.
19
+ # If so, it uses the version of the main branch as the basis for creating a new image tag.
20
+ # The script also checks if the image tag for the build image exists in the main branch.
21
+ # We assume that only one branch and one PR will be created for the changes in the build container.
22
22
# Therefore, we can update this branch as many times as we want and reuse the next available tag after the one from the main branch.
23
23
24
- set -o errexit
25
- set -o nounset
26
- set -o pipefail
24
+ # Usage:
25
+ # Step 1: Update images/builder/Dockerfile (for example increate Go version)
26
+ # Step 2: Update .builder-image-version.txt
27
+ # Step 3: Run this script
28
+
29
+ # Bash Strict Mode: https://github.com/guettli/bash-strict-mode
30
+ trap ' echo "Warning: A command has failed. Exiting the script. Line was ($0:$LINENO): $(sed -n "${LINENO}p" "$0")"; exit 3' ERR
27
31
28
32
export BUILDER_IMAGE=ghcr.io/syself/caph-builder
29
33
30
- REPO_ROOT=$( realpath $( dirname " ${BASH_SOURCE[0]} " ) /..)
34
+ REPO_ROOT=$( realpath " $( dirname " ${BASH_SOURCE[0]} " ) /.." )
31
35
cd " ${REPO_ROOT} " || exit 1
32
36
37
+ # shellcheck disable=SC1091
33
38
source " ${REPO_ROOT} /hack/semver-upgrade.sh"
34
39
35
- if git diff --exit-code .builder-image-version.txt images/builder/Dockerfile images/builder/build.sh > /dev/null; then
40
+ if git diff --exit-code .builder-image-version.txt images/builder/Dockerfile images/builder/build.sh > /dev/null; then
36
41
echo " nothing seems to have changed."
37
42
exit 0
38
43
fi
39
44
40
- if [ " ${CI:- false} " = true ] ; then
45
+ if [ " ${CI:- false} " = true ]; then
41
46
echo " $BUILD_IMAGE_TOKEN " | docker login ghcr.io -u " $BUILD_IMAGE_USER " --password-stdin
42
47
fi
43
48
@@ -51,19 +56,22 @@ export VERSION
51
56
NEW_VERSION=$( semver_upgrade patch " $VERSION " )
52
57
export NEW_VERSION
53
58
54
- if ! docker manifest inspect " $BUILDER_IMAGE :$VERSION " > /dev/null; then
59
+ if ! docker manifest inspect " $BUILDER_IMAGE :$VERSION " > /dev/null; then
55
60
echo " could not find image $BUILDER_IMAGE :$VERSION "
56
61
exit 1
57
62
fi
58
- echo " $NEW_VERSION " > .builder-image-version.txt
63
+ echo " $NEW_VERSION " > .builder-image-version.txt
59
64
echo " Wrote new version $NEW_VERSION to .builder-image-version.txt"
60
65
61
- if docker manifest inspect ghcr.io/syself/caph-builder:${NEW_VERSION} > /dev/null ; echo $? ; then
62
-
66
+ if
67
+ docker manifest inspect ghcr.io/syself/caph-builder:" ${NEW_VERSION} " > /dev/null
68
+ echo $?
69
+ then
70
+
63
71
sed -i -e " /^BUILDER_IMAGE_VERSION /s/:=.*$/:= ${NEW_VERSION} /" Makefile
64
72
grep -r -E ' ghcr.io/syself/caph-builder:[0-9].*.*' -l | xargs sed -i -e " s/ghcr.io\/syself\/caph-builder:${VERSION} /ghcr.io\/syself\/caph-builder:${NEW_VERSION} /g"
65
- docker build -t ghcr.io/syself/caph-builder:${NEW_VERSION} ./images/builder
66
- docker push ghcr.io/syself/caph-builder:${NEW_VERSION}
73
+ docker build -t ghcr.io/syself/caph-builder:" ${NEW_VERSION} " ./images/builder
74
+ docker push ghcr.io/syself/caph-builder:" ${NEW_VERSION} "
67
75
else
68
76
exit 1
69
- fi
77
+ fi
0 commit comments