-
Notifications
You must be signed in to change notification settings - Fork 74
/
release.sh
executable file
·133 lines (127 loc) · 4.73 KB
/
release.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
IMAGE_DOMAIN=${IMAGE_DOMAIN:-docker.io}
IMAGE_NAMESPACE=${IMAGE_NAMESPACE:-rainbond}
DOMESTIC_BASE_NAME=${DOMESTIC_BASE_NAME:-'registry.cn-hangzhou.aliyuncs.com'}
DOMESTIC_NAMESPACE=${DOMESTIC_NAMESPACE:-'goodrain'}
ARCH=${BUILD_ARCH:-'amd64'}
TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST:-false}
# adaptor branch
ADAPTOR_BRANCH=${ADAPTOR_BRANCH:-${VERSION}}
# install version
INSTALL_VERSION=${VERSION/-arm64}
# Domestic packing acceleration
if [ "$PROXY" == "domestic" ]; then
GOPROXY="https://goproxy.cn"
GITPROXY="https://ghproxy.com/"
PYTHONPROXY="-i https://pypi.tuna.tsinghua.edu.cn/simple"
fi
if [ -z "$VERSION" ]; then
if [ -z "$TRAVIS_TAG" ]; then
VERSION=$TRAVIS_BRANCH-dev
else
VERSION=$TRAVIS_TAG
fi
fi
function release() {
git_commit=$(git log -n 1 --pretty --format=%h)
buildTime=$(date +%F-%H)
release_desc=${VERSION}-${git_commit}-${buildTime}
image_name="rainbond-console"
docker build --network=host --build-arg RELEASE_DESC="${release_desc}" -t "${IMAGE_DOMAIN}/${IMAGE_NAMESPACE}/${image_name}:${VERSION}" -f Dockerfile .
if [ $? -ne 0 ]; then
exit 1
fi
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
docker login "${IMAGE_DOMAIN}" -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
docker push "${IMAGE_DOMAIN}/${IMAGE_NAMESPACE}/${image_name}:${VERSION}"
if [ ${DOMESTIC_BASE_NAME} ]; then
docker tag "${IMAGE_DOMAIN}/${IMAGE_NAMESPACE}/${image_name}:${VERSION}" "${DOMESTIC_BASE_NAME}/${DOMESTIC_NAMESPACE}/${image_name}:${VERSION}"
docker login -u "$DOMESTIC_DOCKER_USERNAME" -p "$DOMESTIC_DOCKER_PASSWORD" "${DOMESTIC_BASE_NAME}"
docker push "${DOMESTIC_BASE_NAME}/${DOMESTIC_NAMESPACE}/${image_name}:${VERSION}"
fi
fi
}
function release_allinone() {
git_commit=$(git log -n 1 --pretty --format=%h)
buildTime=$(date +%F-%H)
release_desc=${VERSION}-${git_commit}-${buildTime}-allinone
image_name="rainbond"
imageName=${IMAGE_DOMAIN}/${IMAGE_NAMESPACE}/${image_name}:${VERSION}
docker build --network=host --build-arg VERSION="${VERSION}" --build-arg INSTALL_VERSION="${INSTALL_VERSION}" \
--build-arg IMAGE_NAMESPACE="${IMAGE_NAMESPACE}" \
--build-arg ADAPTOR_BRANCH="${ADAPTOR_BRANCH}" \
--build-arg RELEASE_DESC="${release_desc}" \
--build-arg ARCH="${ARCH}" \
-t "${imageName}" -f Dockerfile.allinone .
if [ $? -ne 0 ]; then
exit 1
fi
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$DOCKER_USERNAME" ]; then
echo "$DOCKER_PASSWORD" | docker login ${IMAGE_DOMAIN} -u "$DOCKER_USERNAME" --password-stdin
docker tag "${imageName}" "${imageName}-allinone"
docker push "${imageName}"
docker push "${imageName}-allinone"
fi
if [ "${DOMESTIC_DOCKER_USERNAME}" ]; then
domestcName=$DOMESTIC_BASE_NAME/$DOMESTIC_NAMESPACE/rainbond:${VERSION}
docker tag "${imageName}" "${domestcName}"
docker tag "${imageName}" "${domestcName}-allinone"
echo "$DOMESTIC_DOCKER_PASSWORD"|docker login -u "$DOMESTIC_DOCKER_USERNAME" "${DOMESTIC_BASE_NAME}" --password-stdin
docker push "${domestcName}"
docker push "${domestcName}-allinone"
fi
fi
}
function release_dind() {
git_commit=$(git log -n 1 --pretty --format=%h)
buildTime=$(date +%F-%H)
release_desc=${VERSION/-release}-${git_commit}-${buildTime}-allinone
image_name="rainbond"
imageName=${IMAGE_DOMAIN}/${IMAGE_NAMESPACE}/${image_name}:${VERSION/-release}-dind-allinone
domestcName=${DOMESTIC_BASE_NAME}/${DOMESTIC_NAMESPACE}/rainbond:${VERSION/-release}-dind-allinone
docker build --network=host --build-arg VERSION="${VERSION}" --build-arg IMAGE_NAMESPACE="${IMAGE_NAMESPACE}" \
--build-arg INSTALL_VERSION="${INSTALL_VERSION}" \
--build-arg RELEASE_DESC="${release_desc}" \
--build-arg ARCH="${ARCH}" \
--build-arg ADAPTOR_BRANCH="${ADAPTOR_BRANCH}" \
--build-arg GOPROXY="${GOPROXY}" \
--build-arg GITPROXY="${GITPROXY}" \
--build-arg PYTHONPROXY="${PYTHONPROXY}" \
-t "${imageName}" -f Dockerfile.dind .
if [ $? -ne 0 ]; then
exit 1
fi
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$DOCKER_USERNAME" ]; then
echo "$DOCKER_PASSWORD" | docker login ${IMAGE_DOMAIN} -u "$DOCKER_USERNAME" --password-stdin
docker push "${imageName}"
fi
if [ "${DOMESTIC_DOCKER_USERNAME}" ]; then
docker tag ${imageName} ${domestcName}
docker login -u "$DOMESTIC_DOCKER_USERNAME" -p "$DOMESTIC_DOCKER_PASSWORD" "${DOMESTIC_BASE_NAME}"
docker push "${domestcName}"
fi
fi
}
function build_dind_package () {
IMAGE_DOMAIN=${IMAGE_DOMAIN} \
IMAGE_NAMESPACE=${IMAGE_NAMESPACE} \
VERSION=${VERSION} \
./build_dind_package.sh
if [ $? -ne 0 ]; then
exit 1
fi
}
case $1 in
allinone)
release_allinone
;;
dind)
build_dind_package
release_dind
;;
*)
release
;;
esac