forked from cyberark/conjur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_utils.sh
55 lines (45 loc) · 1.31 KB
/
build_utils.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
# Functions to generate version numbers for this project
function version_tag() {
git rev-parse --short=8 HEAD
}
# generate set of less specific versions, eg. given 1.2.3 will print 1.2.3,
# 1.2 and 1
function gen_versions()
{
local version=$1
echo "$version"
while [[ $version = *.* ]]; do
version=${version%.*}
echo "$version"
done
}
# tag_and_publish tag source image1 image2 ...
function tag_and_push() {
local tag="$1"; shift
local source="$1"; shift
for image in "$@"; do
local target=$image:$tag
echo "Tagging $source as $target and pushing..."
docker tag "$source" "$target"
docker push "$target"
done
}
# prepare_manifest image tag
function prepare_manifest() {
local image="$1"
local tag="$2"
docker pull "${image}:${tag}-amd64"
docker pull "${image}:${tag}-arm64"
docker manifest create \
--insecure \
"${image}:${tag}" \
--amend "${image}:${tag}-amd64" \
--amend "${image}:${tag}-arm64"
docker manifest push --insecure "${image}:${tag}"
# Because the bill of materials is created based on local docker images this is necessary in order to have
# identical records in BOM files as previously, before multi-arch changes
docker rmi "${image}:${tag}-amd64"
docker rmi "${image}:${tag}-arm64"
docker pull "${image}:${tag}"
}