-
Notifications
You must be signed in to change notification settings - Fork 8
/
release.sh
102 lines (77 loc) · 3.05 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
#!/usr/bin/env bash
RELEASE_VERSION="$1"
DOCKER_CMD=${DOCKER_CMD:-docker}
BINARIES="ko gh"
info() {
echo "INFO: $@"
}
err() {
echo "ERROR: $@"
}
getReleaseVersion() {
[[ -z ${RELEASE_VERSION} ]] && {
read -r -e -p "Enter a target release (i.e: v0.1.2): " RELEASE_VERSION
[[ -z ${RELEASE_VERSION} ]] && {
echo "no target release"
exit 1
}
}
[[ ${RELEASE_VERSION} =~ v[0-9]+\.[0-9]*\.[0-9]+ ]] || {
echo "invalid version provided, need to match v\d+\.\d+\.\d+"
exit 1
}
}
buildImageAndGenerateReleaseYaml() {
info Creating Manual Approval Gate Release Yaml for Kubernetes
echo "------------------------------------------"
ko resolve --platform=linux/amd64,linux/s390x,linux/ppc64le,linux/arm64 -f config/kubernetes -t ${RELEASE_VERSION} > release-kubernetes.yaml || {
err 'release build failed'
return 1
}
sed -i "s/version: \"devel\"/version: \"$RELEASE_VERSION\"/g" release-kubernetes.yaml
echo "============================================="
info Creating Manual Approval Gate Release Yaml for Openshift
echo "------------------------------------------"
ko resolve --platform=linux/amd64,linux/s390x,linux/ppc64le,linux/arm64 -f config/openshift -t ${RELEASE_VERSION} > release-openshift.yaml || {
err 'release build failed'
return 1
}
sed -i "s/version: \"devel\"/version: \"$RELEASE_VERSION\"/g" release-openshift.yaml
echo "------------------------------------------"
}
createNewPreRelease() {
echo; echo 'Creating New Manual Approval Gate Pre-Release :'
gh repo set-default [email protected]:openshift-pipelines/manual-approval-gate.git
gh release create ${RELEASE_VERSION} --title "Pre-release Version '${RELEASE_VERSION}'" --notes "Description of the prerelease" --draft --prerelease
gh release upload ${RELEASE_VERSION} release-kubernetes.yaml release-openshift.yaml
}
createNewBranchAndPush() {
git checkout -b release-${RELEASE_VERSION}
git push origin release-${RELEASE_VERSION}
}
main() {
# Check if all required command exists
for b in ${BINARIES};do
type -p ${b} >/dev/null || { echo "'${b}' need to be avail"; exit 1 ;}
done
# Ask the release version to build images
getReleaseVersion
# Build images for db-migration, api and ui
echo "********************************************"
info Build the Images for Manual Approval Gate
echo "********************************************"
buildImageAndGenerateReleaseYaml
# Create a new pre-release
echo "********************************************"
info Create New PreRelease
echo "********************************************"
createNewPreRelease
echo "********************************************"
info Create New Branch And Push
echo "********************************************"
createNewBranchAndPush
echo "************************************************************"
echo Release Created for Manual Approval Gate successfully
echo "************************************************************"
}
main $@