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
+ echo
32
+ if ! [[ $REPLY =~ ^[Yy]$ ]]; then
25
33
exit 1
26
34
fi
27
35
@@ -36,31 +44,49 @@ export BUILD_USER="$git_user"
36
44
export BUILD_DATE=$( date +%Y%m%d ) # Release date is only to day-granularity
37
45
export VERBOSE=true
38
46
39
- # Build the release binary with libpfm4 for docker container
40
- export GO_FLAGS=" -tags=libpfm,netgo"
41
- build/build.sh
42
-
43
47
# Build the docker image
44
48
echo " >> building cadvisor docker image"
45
- gcr_tag= " gcr.io/cadvisor/cadvisor: $VERSION "
46
- docker build -t $gcr_tag -f deploy/Dockerfile .
49
+ image_name= ${IMAGE_NAME :- " gcr.io/cadvisor/cadvisor" }
50
+ final_image= " $image_name : ${VERSION} "
47
51
48
- # Build the release binary without libpfm4 to not require libpfm4 in runtime environment
49
- unset GO_FLAGS
50
- build/build.sh
52
+ docker buildx inspect cadvisor-builder > /dev/null \
53
+ || docker buildx create --name cadvisor-builder --use
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 "
52
79
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 "
80
+ echo " Release info (copy to the release page)" :
58
81
echo
59
- echo " Release info (copy to the release page):"
82
+ echo Multi Arch Container Image:
83
+ echo $final_image
60
84
echo
61
- echo " Docker Image: N/A"
62
- echo " gcr.io Image: $gcr_tag "
85
+ echo Architecture Specific Container Images:
86
+ for arch in " ${! arches[@]} " ; do
87
+ echo " ${image_name} -${arch} :${VERSION} "
88
+ done
63
89
echo
64
- sha256sum --tag cadvisor
65
-
90
+ echo Binaries:
91
+ (cd _output && find . -name " cadvisor- ${VERSION} * " -exec sha256sum --tag {} \; )
66
92
exit 0
0 commit comments