Skip to content

Commit 3132318

Browse files
committed
Added build/release tools. Updated MAINTAINER_NOTES.md
1 parent 1696208 commit 3132318

File tree

4 files changed

+292
-19
lines changed

4 files changed

+292
-19
lines changed

MAINTAINER_NOTES.md

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,83 @@
11
# Maintainer Notes
22

3-
## Update Dependency Versions
3+
Shell scripts to build and release are located int the `tools` directory.
44

5-
Use the [Versions Maven Plugin](https://www.mojohaus.org/versions-maven-plugin/index.html). Rules are configured in `version-rules.xml`.
5+
## Build a pre-release
6+
___
67

8+
**Pre-release builds are not source controlled (no branch, no tag)**
9+
10+
Command
11+
12+
```shell
13+
./tools/build-and-copy.sh <version> <destination directory>
714
```
8-
./mvnw versions:use-next-releases
15+
16+
Example
17+
18+
```shell
19+
./tools/build-and-copy.sh 0.20.0-ALPHA-1 "/tmp/"
920
```
1021

11-
## Release
22+
The jars will be located in `/tmp`
23+
24+
## Build and stage
25+
___
26+
27+
Release builds are source controlled.
1228

29+
- Creates a `release-<version>` branch
30+
- Creates a `<version>` tag
31+
- Pushes the branch and tag to GitHub
32+
- Stages the release to Maven Central
33+
34+
### Step 1
35+
36+
Command
37+
38+
```shell
39+
./tools/build-and-stage.sh <version>
1340
```
14-
./mvnw release:prepare -DreleaseVersion=0.18.0 -DdevelopmentVersion=0.18.1-SNAPSHOT
15-
./mvnw release:perform -DreleaseVersion=0.18.0 -DdevelopmentVersion=0.18.1-SNAPSHOT
41+
42+
Example
43+
44+
```shell
45+
./tools/build-and-stage.sh 0.20.0
1646
```
1747

18-
`release:prepare` does Github tags and commits, while `release:perform` signs the artifacts and uploads them to the staging repositoring on [https://oss.sonatype.org](https://oss.sonatype.org).
48+
### Step 2
1949

20-
Download the artifacts from the staging repository [https://oss.sonatype.org/#stagingRepositories](https://oss.sonatype.org/#stagingRepositories) and verify them manually:
50+
Download the staged artifacts from Maven Central and run the integration test suite.
2151

22-
```sh
23-
# agent
24-
/usr/lib/jvm/java-8-openjdk/bin/java -javaagent:/home/fabian/Downloads/jmx_prometheus_javaagent-0.18.0.jar=12345:./integration_tests/smoke_tests/src/request/resources/config.yml -jar integration_tests/jmx_example_application/target/jmx_example_application.jar
25-
/usr/lib/jvm/java-11-openjdk/bin/java -javaagent:/home/fabian/Downloads/jmx_prometheus_javaagent-0.18.0.jar=12345:./integration_tests/smoke_tests/src/request/resources/config.yml -jar integration_tests/jmx_example_application/target/jmx_example_application.jar
26-
/usr/lib/jvm/java-17-openjdk/bin/java -javaagent:/home/fabian/Downloads/jmx_prometheus_javaagent-0.18.0.jar=12345:./integration_tests/smoke_tests/src/request/resources/config.yml -jar integration_tests/jmx_example_application/target/jmx_example_application.jar
52+
Example
2753

28-
# standalone
29-
java -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar integration_tests/jmx_example_application/target/jmx_example_application.jar
54+
```shell
55+
/home/dhoard/Downloads/jmx_prometheus_javaagent-0.20.0.jar
56+
/home/dhoard/Downloads/jmx_prometheus_httpserver-0.20.0.jar
57+
```
58+
59+
Command
60+
61+
```shell
62+
./tools/patch-and-run-integration-test-suite.sh <javaagent.jar> <httpserver.jar>
63+
```
64+
65+
Example
3066

31-
/usr/lib/jvm/java-8-openjdk/bin/java -jar ~/Downloads/jmx_prometheus_httpserver-0.18.0.jar 9000 ./integration_tests/smoke_tests/src/request/resources/config-httpserver.yml
32-
/usr/lib/jvm/java-11-openjdk/bin/java -jar ~/Downloads/jmx_prometheus_httpserver-0.18.0.jar 9000 ./integration_tests/smoke_tests/src/request/resources/config-httpserver.yml
33-
/usr/lib/jvm/java-17-openjdk/bin/java -jar ~/Downloads/jmx_prometheus_httpserver-0.18.0.jar 9000 ./integration_tests/smoke_tests/src/request/resources/config-httpserver.yml
67+
```shell
68+
./tools/patch-and-run-integration-test-suite.sh /home/dhoard/Downloads/jmx_prometheus_javaagent-0.20.0.jar /home/dhoard/Downloads/jmx_prometheus_httpserver-0.20.0.jar
3469
```
3570

36-
If everything looks good, click `Close` to trigger Sonatype's verification, then click `Release`.
71+
### Step 3
72+
73+
If the integration test suite in Step 2 passes, on Maven Central...
74+
75+
- Click `Close` to trigger Sonatype's verification
76+
- Once closed, click `Release`
77+
78+
79+
### Step 4
80+
81+
Verify the files are available via Maven Central (Maven)
82+
83+
Create a GitHub release

tools/build-and-copy.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (C) 2023 The AntuBLUE test-engine project authors
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
# Function to check exit code
20+
function check_exit_code () {
21+
if [ ! $? -eq 0 ];
22+
then
23+
echo "------------------------------------------------------------------------"
24+
echo "${1}"
25+
echo "------------------------------------------------------------------------"
26+
exit 1
27+
fi
28+
}
29+
30+
# Usage
31+
if [ "$#" -ne 2 ];
32+
then
33+
echo "Usage: ${0} <version> <destination directory>"
34+
exit 1
35+
fi
36+
37+
PROJECT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
38+
39+
# Change to the project root directory
40+
cd "${PROJECT_ROOT_DIRECTORY}"
41+
check_exit_code "Failed to change to project root directory"
42+
43+
# Get the current version
44+
CURRENT_VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
45+
BUILD_VERSION="${1}"
46+
DESTINATION_DIRECTORY="${2}"
47+
48+
# Check / create the destination directory
49+
if [ ! -d "${DESTINATION_DIRECTORY}" ];
50+
then
51+
mkdir -p "${DESTINATION_DIRECTORY}"
52+
check_exit_code "Creating destination directory [${DESTINATION_DIRECTORY}] failed"
53+
fi
54+
55+
# Update the versions
56+
./mvnw versions:set -DnewVersion="${BUILD_VERSION}" -DprocessAllModules >> /dev/null
57+
check_exit_code "Maven update versions [${BUILD_VERSION}] failed"
58+
rm -Rf $(find . -name "*versionsBackup")
59+
60+
# Build and package the exporter jars
61+
./mvnw clean package
62+
BUILD_EXIT_CODE="$?"
63+
64+
# Copy the exporter jars to the destination directory
65+
if [ "${BUILD_EXIT_CODE}" == "0" ];
66+
then
67+
cp "jmx_prometheus_javaagent/target/jmx_prometheus_javaagent-${BUILD_VERSION}.jar" "${DESTINATION_DIRECTORY}"
68+
cp "jmx_prometheus_httpserver/target/jmx_prometheus_httpserver-${BUILD_VERSION}.jar" "${DESTINATION_DIRECTORY}"
69+
fi
70+
71+
# Revert the versions
72+
./mvnw versions:set -DnewVersion="${CURRENT_VERSION}" -DprocessAllModules >> /dev/null
73+
check_exit_code "Maven update versions [${CURRENT_VERSION}] failed"
74+
rm -Rf $(find . -name "*versionsBackup")
75+
76+
echo "------------------------------------------------------------------------"
77+
if [ "${BUILD_EXIT_CODE}" == "0" ];
78+
then
79+
echo "SUCCESS"
80+
else
81+
echo "FAILURE"
82+
fi
83+
echo "------------------------------------------------------------------------"

tools/build-and-stage.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
3+
# Function to check exit code
4+
function check_exit_code () {
5+
if [ ! $? ];
6+
then
7+
echo "${1}"
8+
exit 1
9+
fi
10+
}
11+
12+
# Function to emit an error message and exit
13+
function emit_error () {
14+
echo "${1}"
15+
exit 1;
16+
}
17+
18+
# Usage
19+
if [ "$#" -ne 1 ];
20+
then
21+
echo "Usage: ${0} <version>"
22+
exit 1
23+
fi
24+
25+
VERSION="${1}"
26+
PROJECT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
27+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
28+
29+
cd "${PROJECT_ROOT_DIRECTORY}"
30+
check_exit_code "Failed to change to project root directory"
31+
32+
# Check for uncommitted changes
33+
git diff --quiet HEAD
34+
if [ ! $? -eq 0 ];
35+
then
36+
echo "------------------------------------------------------------------------"
37+
echo "UNCOMMITTED CHANGES"
38+
echo "------------------------------------------------------------------------"
39+
echo ""
40+
git status
41+
exit 1
42+
fi
43+
44+
if [ "${CURRENT_BRANCH}" != "main" ];
45+
then
46+
emit_error "Release should always be from [main] branch not [${CURRENT_BRANCH}] branch"
47+
fi
48+
49+
# Pull smoke test Docker images
50+
./integration_test_suite/docker-pull-images.smoke-test.sh
51+
check_exit_code "Failed to update smoke test Docker images"
52+
53+
# Verify the code builds
54+
./mvnw -P release clean verify
55+
check_exit_code "Maven build failed"
56+
57+
# Checkout a release branch
58+
git checkout -b "release-${VERSION}"
59+
check_exit_code "Git checkout [${VERSION}] failed"
60+
61+
# Update the build versions
62+
./mvnw versions:set -DnewVersion="${VERSION}" -DprocessAllModules
63+
check_exit_code "Maven update versions [${VERSION}] failed"
64+
rm -Rf $(find . -name "*versionsBackup")
65+
66+
# Add changed files
67+
git add -u
68+
check_exit_code "Git add failed"
69+
70+
# Commit the changed files
71+
git commit -m "${VERSION}"
72+
check_exit_code "Git commit failed"
73+
74+
# Build and deploy
75+
./mvnw -P release clean deploy
76+
check_exit_code "Maven deploy [${VERSION}] failed"
77+
78+
# Push the branch
79+
git push --set-upstream origin release-"${VERSION}"
80+
check_exit_code "Git push [${VERSION}] failed"
81+
82+
# Tag the version
83+
git tag "${VERSION}"
84+
check_exit_code "Git tag [${VERSION}] failed"
85+
86+
# Push the tag
87+
git push origin "${VERSION}"
88+
check_exit_code "Git tag [${VERSION}] push failed"
89+
90+
# Checkout the current branch
91+
git checkout "${CURRENT_BRANCH}"
92+
check_exit_code "Git checkout branch [${CURRENT_BRANCH}] failed"
93+
94+
echo "------------------------------------------------------------------------"
95+
echo "SUCCESS"
96+
echo "------------------------------------------------------------------------"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Function to check exit code
4+
function check_exit_code () {
5+
if [ ! $? -eq 0 ];
6+
then
7+
echo "${1}"
8+
exit 1
9+
fi
10+
}
11+
12+
JAVA_AGENT_JAR="${1}"
13+
HTTPSERVER_JAR="${2}"
14+
PROJECT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
15+
16+
if [ "$#" -ne 2 ];
17+
then
18+
echo "Usage: ${0} <javaagent.jar> <httpserver.jar>"
19+
exit 1
20+
fi
21+
22+
# Change to the project root directory
23+
cd "${PROJECT_ROOT_DIRECTORY}"
24+
check_exit_code "Failed to change to project root directory"
25+
26+
# Remove current exporter jars
27+
rm -Rf ./integration_test_suite/integration_tests/src/test/resources/common/* > /dev/null 2>&1
28+
29+
# Copy the Java agent exporter jar into the integration test suite
30+
cp "${JAVA_AGENT_JAR}" ./integration_test_suite/integration_tests/src/test/resources/common/jmx_prometheus_javaagent.jar
31+
check_exit_code "Failed to patch the integration test suite [${JAVA_AGENT_JAR}]"
32+
33+
# Copy the Java HTTP server exporter jar into the integration test suite
34+
cp "${HTTPSERVER_JAR}" ./integration_test_suite/integration_tests/src/test/resources/common/jmx_prometheus_httpserver.jar
35+
check_exit_code "Failed to patch the integration test suite [${HTTPSERVER_JAR}]"
36+
37+
# Pull smoke test Docker images
38+
./integration_test_suite/docker-pull-images.smoke-test.sh
39+
check_exit_code "Failed to update smoke test Docker images"
40+
41+
./mvnw clean verify
42+
check_exit_code "Integration test suite failed"
43+
44+
echo "------------------------------------------------------------------------"
45+
echo "SUCCESS"
46+
echo "------------------------------------------------------------------------"
47+

0 commit comments

Comments
 (0)