forked from kubernetes/release
-
Notifications
You must be signed in to change notification settings - Fork 2
/
kirk-release-images.sh
executable file
·60 lines (50 loc) · 1.7 KB
/
kirk-release-images.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
56
57
58
59
60
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}") && pwd)
cd $ROOT
KUBE_DOCKER_REGISTRY=${KUBE_DOCKER_REGISTRY:-}
KUBE_DOCKER_USERNAME=${KUBE_DOCKER_USERNAME:-}
KUBE_DOCKER_PASSWORD=${KUBE_DOCKER_PASSWORD:-}
if [ -z "$KUBE_DOCKER_REGISTRY" ]; then
echo "error: KUBE_DOCKER_REGISTRY is missing"
exit 1
fi
# login docker
if [ -z "$KUBE_DOCKER_USERNAME" -o -z "$KUBE_DOCKER_PASSWORD" ]; then
echo "error: please provide KUBE_DOCKER_USERNAME and KUBE_DOCKER_PASSWORD for $KUBE_DOCKER_REGISTRY"
exit 1
else
docker login -u "${KUBE_DOCKER_USERNAME}" --password-stdin $(echo $KUBE_DOCKER_REGISTRY | cut -d '/' -f 1) <<< "$KUBE_DOCKER_PASSWORD"
fi
# build images
cd $GOPATH/src/k8s.io/kubernetes
source build/common.sh
export KUBE_DOCKER_IMAGE_TAG=$(./hack/print-workspace-status.sh | awk -F' ' '/^gitVersion/ {print $2}' | tr -s '+' '_')
if [[ "$KUBE_DOCKER_IMAGE_TAG" =~ -dirty$ ]]; then
echo "error: '-dirty' exists in image tag: $KUBE_DOCKER_IMAGE_TAG, please check"
exit 1
fi
echo "KUBE_DOCKER_IMAGE_TAG: $KUBE_DOCKER_IMAGE_TAG"
if [[ -n "${SKIP_BUILD:-}" ]]; then
echo "info: image build is skippped"
else
make quick-release
fi
# push images
function push_images() {
# NOTE: we only support amd64 for now
local binaries=($(kube::build::get_docker_wrapped_binaries amd64))
for wrappable in "${binaries[@]}"; do
local oldifs=$IFS
IFS=","
set $wrappable
IFS=$oldifs
local binary_name="$1"
local base_image="$2"
echo -n "Pushing $KUBE_DOCKER_REGISTRY/$binary_name-amd64:$KUBE_DOCKER_IMAGE_TAG"
docker push $KUBE_DOCKER_REGISTRY/$binary_name-amd64:$KUBE_DOCKER_IMAGE_TAG
done
}
push_images