16
16
17
17
set -e
18
18
19
- VERSION=$( git describe --tags --dirty --abbrev=14 | sed -E ' s/-([0-9]+)-g/.\1+/' )
20
- # Only allow releases of tagged versions.
21
- TAGGED=' ^v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.?[0-9]*)?$'
22
- if [[ ! " $VERSION " =~ $TAGGED ]]; then
23
- echo " Error: Only tagged versions are allowed for releases" >&2
24
- echo " Found: $VERSION " >&2
19
+ if [ -z " $VERSION " ]; then
20
+ VERSION=$( git describe --tags --dirty --abbrev=14 | sed -E ' s/-([0-9]+)-g/.\1+/' )
21
+ # Only allow releases of tagged versions.
22
+ TAGGED=' ^v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.?[0-9]*)?$'
23
+ if [[ ! " $VERSION " =~ $TAGGED ]]; then
24
+ echo " Error: Only tagged versions are allowed for releases" >&2
25
+ echo " Found: $VERSION " >&2
26
+ exit 1
27
+ fi
28
+ fi
29
+
30
+ read -p " Please confirm: $VERSION is the desired version (Type y/n to continue):" -n 1 -r
31
+ if ! [[ $REPLY =~ ^[Yy]$ ]]; then
25
32
exit 1
26
33
fi
27
34
@@ -36,31 +43,51 @@ export BUILD_USER="$git_user"
36
43
export BUILD_DATE=$( date +%Y%m%d ) # Release date is only to day-granularity
37
44
export VERBOSE=true
38
45
39
- # Build the release binary with libpfm4 for docker container
40
- export GO_FLAGS=" -tags=libpfm,netgo"
41
- build/build.sh
42
-
43
46
# Build the docker image
44
47
echo " >> building cadvisor docker image"
45
- gcr_tag= " gcr.io/cadvisor/cadvisor: $VERSION "
46
- docker build -t $gcr_tag -f deploy/Dockerfile .
48
+ image_name= ${IMAGE_NAME :- " gcr.io/cadvisor/cadvisor" }
49
+ final_image= " $image_name : ${VERSION} "
47
50
48
- # Build the release binary without libpfm4 to not require libpfm4 in runtime environment
49
- unset GO_FLAGS
50
- build/build.sh
51
+ docker buildx rm cadvisor-builder || true
52
+ docker buildx create --name cadvisor-builder
53
+ docker buildx use cadvisor-builder
51
54
55
+ # Build binaries
56
+
57
+ # A mapping of the docker arch name to the qemu arch name
58
+ declare -A arches=( [" amd64" ]=" x86_64" [" arm" ]=" arm" [" arm64" ]=" aarch64" )
59
+
60
+ for arch in " ${arches[@]} " ; do
61
+ if ! hash " qemu-${arch} -static" ; then
62
+ echo Releasing multi arch containers requires qemu-user-static.
63
+ echo
64
+ echo Please install using apt-get install qemu-user-static or
65
+ echo a similar package for your OS.
66
+
67
+ exit 1
68
+ fi
69
+ done
70
+
71
+ for arch in " ${! arches[@]} " ; do
72
+ GOARCH=" $arch " OUTPUT_NAME_WITH_ARCH=" true" build/build.sh
73
+ arch_specific_image=" ${image_name} -${arch} :${VERSION} "
74
+ docker buildx build --platform " linux/${arch} " --build-arg VERSION=" $VERSION " -f deploy/Dockerfile -t " $arch_specific_image " --progress plain --push .
75
+ docker manifest create --amend " $final_image " " $arch_specific_image "
76
+ docker manifest annotate --os=linux --arch=" $arch " " $final_image " " $arch_specific_image "
77
+ done
78
+ docker manifest push " $final_image "
79
+ docker buildx rm cadvisor-builder
52
80
echo
53
- echo " double-check the version below:"
54
- echo " VERSION=$VERSION "
55
- echo
56
- echo " To push docker image to gcr:"
57
- echo " docker push $gcr_tag "
81
+ echo " Release info (copy to the release page)" :
58
82
echo
59
- echo " Release info (copy to the release page):"
83
+ echo Multi Arch Container Image:
84
+ echo $final_image
60
85
echo
61
- echo " Docker Image: N/A"
62
- echo " gcr.io Image: $gcr_tag "
86
+ echo Architecture Specific Container Images:
87
+ for arch in " ${! arches[@]} " ; do
88
+ echo " ${image_name} -${arch} :${VERSION} "
89
+ done
63
90
echo
64
- sha256sum --tag cadvisor
65
-
91
+ echo Binaries:
92
+ (cd _output && find . -name " cadvisor- ${VERSION} * " -exec sha256sum --tag {} \; )
66
93
exit 0
0 commit comments