-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpublish.sh
executable file
·103 lines (86 loc) · 2.71 KB
/
publish.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
#!/usr/bin/env -S bash -e
function usage() {
echo "Usage:"
echo
echo " $0 [options] <project> <release_version> <development_version> <branch>"
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 " <branch> The branch we want to release"
echo
echo " Options"
echo
echo " -h Show this help and exit."
echo " -d Dry run; do not push, deploy or publish anything."
}
#--------------------------------------------
# Option parsing
function exec_or_dry_run() {
"${@}"
}
PUSH_CHANGES=true
DRY_RUN=false
while getopts 'dhb:' opt; do
case "$opt" in
h)
usage
exit 0
;;
d)
# Dry run
echo "DRY RUN: will not push/deploy/publish anything."
DRY_RUN=true
PUSH_CHANGES=false
function exec_or_dry_run() {
echo "DRY RUN; would have executed:" "${@}"
}
;;
\?)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)"
PROJECT=$1
RELEASE_VERSION=$2
DEVELOPMENT_VERSION=$3
BRANCH=$4
WORKSPACE=${WORKSPACE:-'.'}
pushd ${WORKSPACE}
if [ -z "$PROJECT" ]; then
echo "ERROR: Project not supplied"
exit 1
fi
if [ -z "$RELEASE_VERSION" ]; then
echo "ERROR: Release version not supplied"
exit 1
fi
if [ -z "$DEVELOPMENT_VERSION" ]; then
echo "ERROR: Development version not supplied"
exit 1
fi
RELEASE_VERSION_FAMILY=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
if [ "$PROJECT" == "orm" ] || [ "$PROJECT" == "reactive" ]; then
git config user.email [email protected]
git config user.name Hibernate-CI
EXTRA_ARGS=""
if [ "$DRY_RUN" == "true" ]; then
EXTRA_ARGS=" --dry-run"
fi
./gradlew releasePerform closeAndReleaseSonatypeStagingRepository -x test \
--no-scan --no-daemon --no-build-cache --stacktrace $EXTRA_ARGS \
-PreleaseVersion=$RELEASE_VERSION -PdevelopmentVersion=$DEVELOPMENT_VERSION \
-PdocPublishBranch=production -PgitRemote=origin -PgitBranch=$BRANCH
else
bash -xe "$SCRIPTS_DIR/deploy.sh" "$PROJECT"
if [[ "$PROJECT" != "tools" && "$PROJECT" != "hcann" && ! $PROJECT =~ ^infra-.+ ]]; then
exec_or_dry_run bash -xe "$SCRIPTS_DIR/upload-distribution.sh" "$PROJECT" "$RELEASE_VERSION"
exec_or_dry_run bash -xe "$SCRIPTS_DIR/upload-documentation.sh" "$PROJECT" "$RELEASE_VERSION" "$RELEASE_VERSION_FAMILY"
fi
bash -xe "$SCRIPTS_DIR/update-version.sh" "$PROJECT" "$DEVELOPMENT_VERSION"
bash -xe "$SCRIPTS_DIR/push-upstream.sh" "$PROJECT" "$RELEASE_VERSION" "$BRANCH" "$PUSH_CHANGES"
fi
popd