Skip to content

Commit 97a145d

Browse files
committed
HHH-17239 Automate maintenance releases
1 parent 313c75d commit 97a145d

14 files changed

+719
-36
lines changed

deploy.sh

+15-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,23 @@ if [ -z "$PROJECT" ]; then
1212
exit 1
1313
fi
1414

15-
if [ "$PROJECT" == "ogm" ]; then
16-
ADDITIONAL_OPTIONS="-DmongodbProvider=external -DskipITs"
15+
if [ "$PROJECT" == "orm" ]; then
16+
./gradlew ciRelease closeAndReleaseSonatypeStagingRepository -x test --no-scan \
17+
-PreleaseVersion=$RELEASE_VERSION -PdevelopmentVersion=$DEVELOPMENT_VERSION -PgitRemote=origin -PgitBranch=$VERSION_FAMILY \
18+
-PSONATYPE_OSSRH_USER=$OSSRH_USER -PSONATYPE_OSSRH_PASSWORD=$OSSRH_PASSWORD \
19+
-Pgradle.publish.key=$PLUGIN_PORTAL_USERNAME -Pgradle.publish.secret=$PLUGIN_PORTAL_PASSWORD \
20+
-PhibernatePublishUsername=$OSSRH_USER -PhibernatePublishPassword=$OSSRH_PASSWORD \
21+
-DsigningPassword=$SIGNING_PASS -DsigningKeyFile=$SIGNING_KEYRING
1722
else
18-
ADDITIONAL_OPTIONS=""
19-
fi
23+
if [ "$PROJECT" == "ogm" ]; then
24+
ADDITIONAL_OPTIONS="-DmongodbProvider=external -DskipITs"
25+
else
26+
ADDITIONAL_OPTIONS=""
27+
fi
2028

21-
source "$SCRIPTS_DIR/mvn-setup.sh"
29+
source "$SCRIPTS_DIR/mvn-setup.sh"
2230

23-
./mvnw -Pdocbook,documentation-pdf,dist,perf,relocation,release clean deploy -DskipTests=true -Dcheckstyle.skip=true -DperformRelease=true -Dmaven.compiler.useIncrementalCompilation=false $ADDITIONAL_OPTIONS
31+
./mvnw -Pdocbook,documentation-pdf,dist,perf,relocation,release clean deploy -DskipTests=true -Dcheckstyle.skip=true -DperformRelease=true -Dmaven.compiler.useIncrementalCompilation=false $ADDITIONAL_OPTIONS
32+
fi
2433

2534
popd

determine-current-version.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env -S bash -e
2+
3+
SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)"
4+
5+
PROJECT=$1
6+
WORKSPACE=${WORKSPACE:-'.'}
7+
8+
if [ -z "$PROJECT" ]; then
9+
echo "ERROR: Project not supplied"
10+
exit 1
11+
fi
12+
13+
if [ "$PROJECT" == "orm" ]; then
14+
grep hibernateVersion $WORKSPACE/gradle/version.properties|cut -d'=' -f2
15+
else
16+
mvn -f $WORKSPACE/pom.xml org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -q -DforceStdout
17+
fi

determine-development-version.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env -S bash -e
2+
3+
SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)"
4+
5+
RELEASE_VERSION=$1
6+
WORKSPACE=${WORKSPACE:-'.'}
7+
8+
if [ -z "$RELEASE_VERSION" ]; then
9+
echo "ERROR: Release version not supplied"
10+
exit 1
11+
fi
12+
13+
RELEASE_VERSION_FAMILY=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
14+
NEXT_MINOR=$(echo "$RELEASE_VERSION" | sed -E 's/^[0-9]+\.[0-9]+\.([0-9]+).*/\1/' | awk '{print $0+1}')
15+
echo "${RELEASE_VERSION_FAMILY}.${NEXT_MINOR}-SNAPSHOT"

determine-jira-version-id.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env -S bash -e
2+
3+
SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)"
4+
5+
JIRA_KEY=$1
6+
JIRA_VERSION=$2
7+
WORKSPACE=${WORKSPACE:-'.'}
8+
9+
if [ -z "$JIRA_KEY" ]; then
10+
echo "ERROR: Jira key not supplied"
11+
exit 1
12+
fi
13+
14+
if [ -z "$JIRA_VERSION" ]; then
15+
echo "ERROR: Jira version not supplied"
16+
exit 1
17+
fi
18+
19+
JSON_RESPONSE=$(curl -sL "https://hibernate.atlassian.net/rest/api/2/project/${JIRA_KEY}/version?status=unreleased")
20+
JIRA_VERSION_ID=$(echo "$JSON_RESPONSE" | sed -E "s/^.+,\"id\":\"([0-9]+)\",\"name\":\"${JIRA_VERSION//./\.}\".*/\1/")
21+
22+
if [ -z "$JIRA_VERSION_ID" ]; then
23+
echo "ERROR: Jira version id not found"
24+
exit 1
25+
fi
26+
echo $JIRA_VERSION_ID

determine-release-version.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env -S bash -e
2+
3+
SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)"
4+
5+
CURRENT_VERSION=$1
6+
WORKSPACE=${WORKSPACE:-'.'}
7+
8+
if [ -z "$CURRENT_VERSION" ]; then
9+
echo "ERROR: Current version not supplied"
10+
exit 1
11+
fi
12+
13+
RELEASE_VERSION=$(echo "$CURRENT_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
14+
echo "$RELEASE_VERSION.Final"

determine-version-basis.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env -S bash -e
2+
3+
SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)"
4+
5+
VERSION=$1
6+
WORKSPACE=${WORKSPACE:-'.'}
7+
8+
if [ -z "$VERSION" ]; then
9+
echo "ERROR: Version not supplied"
10+
exit 1
11+
fi
12+
13+
echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/'

determine-version-family.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env -S bash -e
2+
3+
SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)"
4+
5+
RELEASE_VERSION=$1
6+
WORKSPACE=${WORKSPACE:-'.'}
7+
8+
if [ -z "$RELEASE_VERSION" ]; then
9+
echo "ERROR: Release version not supplied"
10+
exit 1
11+
fi
12+
13+
echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/'

github-release.sh

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#!/usr/bin/env -S bash -e
2+
3+
4+
function usage() {
5+
echo "Usage:"
6+
echo
7+
echo " $0 [options] <project> <release_version>"
8+
echo
9+
echo " <project> One of [search,validator,ogm,orm]"
10+
echo " <release_version> The version to release (e.g. 6.0.1)"
11+
echo
12+
echo " Options"
13+
echo
14+
echo " -h Show this help and exit."
15+
echo " -d Dry run; do not push, deploy or publish anything."
16+
}
17+
18+
#--------------------------------------------
19+
# Option parsing
20+
21+
function exec_or_dry_run() {
22+
"${@}"
23+
}
24+
PUSH_CHANGES=true
25+
26+
while getopts 'dhb:' opt; do
27+
case "$opt" in
28+
h)
29+
usage
30+
exit 0
31+
;;
32+
d)
33+
# Dry run
34+
echo "DRY RUN: will not push/deploy/publish anything."
35+
PUSH_CHANGES=false
36+
function exec_or_dry_run() {
37+
echo "DRY RUN; would have executed:" "${@}"
38+
}
39+
;;
40+
\?)
41+
usage
42+
exit 1
43+
;;
44+
esac
45+
done
46+
47+
shift $((OPTIND - 1))
48+
49+
SCRIPTS_DIR="$(readlink -f ${BASH_SOURCE[0]} | xargs dirname)"
50+
51+
PROJECT=$1
52+
RELEASE_VERSION=$2
53+
WORKSPACE=${WORKSPACE:-'.'}
54+
55+
if [ -z "$PROJECT" ]; then
56+
echo "ERROR: Project not supplied"
57+
exit 1
58+
fi
59+
if [ -z "$RELEASE_VERSION" ]; then
60+
echo "ERROR: Release version argument not supplied"
61+
exit 1
62+
fi
63+
64+
if [ "$PROJECT" == "search" ]; then
65+
JIRA_KEY="HSEARCH"
66+
PROJECT_NAME="Search"
67+
elif [ "$PROJECT" == "validator" ]; then
68+
JIRA_KEY="HV"
69+
PROJECT_NAME="Validator"
70+
elif [ "$PROJECT" == "ogm" ]; then
71+
JIRA_KEY="OGM"
72+
PROJECT_NAME="OGM"
73+
elif [ "$PROJECT" == "orm" ]; then
74+
JIRA_KEY="HHH"
75+
PROJECT_NAME="ORM"
76+
elif [ "$PROJECT" == "reactive" ]; then
77+
JIRA_KEY="HREACT"
78+
PROJECT_NAME="Reactive"
79+
else
80+
echo "ERROR: Unknown project name $PROJECT"
81+
usage
82+
exit 1
83+
fi
84+
85+
RELEASE_VERSION_FAMILY=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
86+
RELEASE_VERSION_BASIS=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
87+
88+
if [ "$PUSH_CHANGES" == 'true' ] && [ -z "$GITHUB_API_TOKEN" ]; then
89+
echo "ERROR: Environment variable GITHUB_API_TOKEN must not be empty"
90+
exit 1
91+
fi
92+
93+
docsUrl="https://docs.jboss.org/hibernate/orm/${RELEASE_VERSION_FAMILY}"
94+
javadocsUrl="${docsUrl}/javadocs"
95+
migrationGuideUrl="${docsUrl}/migration-guide/migration-guide.html"
96+
introGuideUrl="${docsUrl}/introduction/html_single/Hibernate_Introduction.html"
97+
userGuideUrl="${docsUrl}/userguide/html_single/Hibernate_User_Guide.html"
98+
99+
releaseName="Hibernate ${PROJECT_NAME} ${RELEASE_VERSION}"
100+
releaseBody="""\
101+
# Hibernate ${PROJECT_NAME} ${RELEASE_VERSION} released
102+
103+
Today, we published a new maintenance release of Hibernate ${PROJECT_NAME} ${RELEASE_VERSION_FAMILY}: ${RELEASE_VERSION}.
104+
105+
## What's new
106+
107+
This release introduces a few minor improvements as well as bug fixes.
108+
109+
You can find the full list of ${RELEASE_VERSION} changes [here](https://hibernate.atlassian.net/issues/?jql=project%20%3D%20${JIRA_KEY}%20AND%20fixVersion%20%3D%20${RELEASE_VERSION_BASIS}).
110+
111+
## Conclusion
112+
113+
For additional details, see:
114+
115+
- the [release page](https://hibernate.org/orm/releases/${RELEASE_VERSION_FAMILY}/)
116+
- the [Migration Guide](${migrationGuideUrl})
117+
- the [Introduction Guide](${introGuideUrl})
118+
- the [User Guide](${userGuideUrl})
119+
120+
See also the following resources related to supported APIs:
121+
122+
- the [compatibility policy](https://hibernate.org/community/compatibility-policy/)
123+
- the [incubating API report](${docsUrl}/incubating/incubating.txt) (\`@Incubating\`)
124+
- the [deprecated API report](${docsUrl}/deprecated/deprecated.txt) (\`@Deprecated\` + \`@Remove\`)
125+
- the [internal API report](${docsUrl}/internals/internal.txt) (internal packages, \`@Internal\`)
126+
127+
Visit the [website](https://hibernate.org/community/) for details on getting in touch with us."""
128+
129+
response=$(exec_or_dry_run curl -L -s -w "\n%{http_code}" -X POST \
130+
-H 'Accept: application/vnd.github+json' \
131+
-H 'X-GitHub-Api-Version: 2022-11-28' \
132+
-H "Authorization: Bearer \$GITHUB_API_TOKEN" \
133+
-d '{"tag_name":"'${RELEASE_VERSION}'","name":"'${releaseName}'","make_latest":"legacy","body":"'${releaseBody}'"}' \
134+
'https://api.github.com/repos/hibernate/hibernate-orm/releases')
135+
136+
if [ "$PUSH_CHANGES" == true ]; then
137+
githubCreateReleaseResponseCode=$(tail -n1 <<< "$response") # get the last line
138+
githubCreateReleaseResponse=$(sed '$ d' <<< "$response") # get all but the last line which contains the status code
139+
140+
if [ "$githubCreateReleaseResponseCode" != 201 ]; then
141+
echo "$githubCreateReleaseResponse"
142+
echo "ERROR: Release failed because GitHub release could not be created"
143+
exit 1
144+
fi
145+
else
146+
echo $response
147+
fi

0 commit comments

Comments
 (0)