-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrelease.sh
executable file
·137 lines (121 loc) · 3.49 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
134
135
136
137
#!/usr/bin/env -S bash -e
function usage() {
echo "Usage:"
echo
echo " $0 [options] <project> <release_version> <development_version>"
echo
echo " <project> One of [search,validator,ogm,orm,reactive,tools,hcann,infra-*]]"
echo " <release_version> The version to release (e.g. 6.0.1.Final)"
echo " <development_version> The new version after the release (e.g. 6.0.2-SNAPSHOT)"
echo
echo " Options"
echo
echo " -h Show this help and exit."
echo " -b <branch> The branch to push to (e.g. main or 6.0)."
echo " Defaults to the name of the current branch."
echo " -d Dry run; do not push, deploy or publish anything."
}
#--------------------------------------------
# Option parsing
function exec_or_dry_run() {
"${@}"
}
PUSH_CHANGES=true
# Default to a well-known CI environment variable
BRANCH="$BRANCH_NAME"
while getopts 'dhb:' opt; do
case "$opt" in
b)
BRANCH="$OPTARG"
;;
h)
usage
exit 0
;;
d)
# Dry run
echo "DRY RUN: will not push/deploy/publish anything."
PUSH_CHANGES=false
export JRELEASER_DRY_RUN=true
function exec_or_dry_run() {
echo "DRY RUN; would have executed:" "${@}"
}
;;
\?)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
WORKSPACE="${WORKSPACE:-'.'}"
SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)"
PROJECT="$1"
if [ -z "$PROJECT" ]; then
echo "ERROR: Project not supplied"
usage
exit 1
fi
shift
RELEASE_VERSION="$1"
if [ -z "$RELEASE_VERSION" ]; then
echo "ERROR: Release version not supplied"
usage
exit 1
fi
shift
DEVELOPMENT_VERSION="$1"
if [ -z "$DEVELOPMENT_VERSION" ]; then
echo "ERROR: Development version not supplied"
usage
exit 1
fi
shift
#--------------------------------------------
# Defaults / computed
if [ -z "$BRANCH" ]; then
BRANCH="$(git branch --show-current)"
echo "Inferred release branch: $BRANCH"
fi
if (( $# > 0 )); then
echo "ERROR: Extra arguments:" "${@}"
usage
exit 1
fi
RELEASE_VERSION_FAMILY=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
if [ "$RELEASE_VERSION" = "$RELEASE_VERSION_FAMILY" ]; then
echo "ERROR: Could not extract family from release version $RELEASE_VERSION"
usage
exit 1
else
echo "Inferred release version family: $RELEASE_VERSION_FAMILY"
fi
if [ "$PROJECT" == "search" ]; then
JIRA_PROJECT="HSEARCH"
elif [ "$PROJECT" == "validator" ]; then
JIRA_PROJECT="HV"
elif [ "$PROJECT" == "ogm" ]; then
JIRA_PROJECT="OGM"
elif [ "$PROJECT" == "orm" ]; then
JIRA_PROJECT="HHH"
elif [ "$PROJECT" == "reactive" ]; then
JIRA_PROJECT="HREACT"
elif [ "$PROJECT" == "tools" ]; then
JIRA_PROJECT="HBX"
elif [ "$PROJECT" == "models" ]; then
echo 'No JIRA project available'
elif [[ $PROJECT =~ ^infra-.+ ]]; then
echo 'No JIRA project available'
else
echo "ERROR: Unknown project name $PROJECT"
usage
exit 1
fi
RELEASE_VERSION_BASIS=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
NEXT_VERSION_BASIS=$(echo "$DEVELOPMENT_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
if [ "$PUSH_CHANGES" != "true" ]; then
ADDITIONAL_OPTIONS="-d"
fi
bash -xe "$SCRIPTS_DIR/prepare-release.sh" -b "$BRANCH" -d "$DEVELOPMENT_VERSION" "$PROJECT" "$RELEASE_VERSION"
#bash -xe "$SCRIPTS_DIR/jira-release.sh" $ADDITIONAL_OPTIONS "$JIRA_PROJECT" "$RELEASE_VERSION_BASIS" "$NEXT_VERSION_BASIS"
bash -xe "$SCRIPTS_DIR/publish.sh" $ADDITIONAL_OPTIONS "$PROJECT" "$RELEASE_VERSION" "$DEVELOPMENT_VERSION" "$BRANCH"