Skip to content

Commit adc3b82

Browse files
jderegclaude
andcommitted
Add release helper scripts: preflight + perf-results extractor
scripts/preflight-release.sh: 7 pre-deploy checks (network/Sonatype reachable, working tree clean, on master, in sync with origin, pom.xml version, GPG key available, settings.xml has Sonatype credentials). Exits non-zero on any failure so subsequent steps abort. scripts/extract-perf-results.sh: pulls @EnabledIf perf-test summaries out of a deploy log so the numbers can be eyeballed at a glance after `mvn clean deploy -DperformRelease=true` runs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a7686af commit adc3b82

2 files changed

Lines changed: 159 additions & 0 deletions

File tree

scripts/extract-perf-results.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# Pull the @EnabledIf perf-test numbers out of a deploy log so they can be
3+
# eyeballed at a glance, especially during a release where you want to spot
4+
# any unusual numbers.
5+
#
6+
# Usage: scripts/extract-perf-results.sh path/to/deploy.log
7+
set -e
8+
9+
LOG="${1:-}"
10+
if [ -z "$LOG" ] || [ ! -f "$LOG" ]; then
11+
echo "Usage: $0 path/to/deploy.log" >&2
12+
exit 1
13+
fi
14+
15+
echo "=== Performance test summary from ${LOG} ==="
16+
echo
17+
18+
# 1. Find lines that look like perf test classes (heuristic: name contains
19+
# "Perf" or "Benchmark" or "Performance"), pull their Tests-run summaries
20+
# plus any "elapsed" time near them.
21+
echo "--- Perf-test class summaries ---"
22+
grep -E "(Perf|Benchmark|Performance).*Tests run:" "$LOG" | \
23+
sed -E 's/^\[INFO\] //' | \
24+
head -30
25+
echo
26+
27+
# 2. Pull any line that prints elapsed milliseconds with a clear context (heuristic).
28+
echo "--- Long-running test classes (>250ms elapsed) ---"
29+
awk '
30+
/Tests run:.*elapsed:/ {
31+
# extract elapsed time
32+
if (match($0, /elapsed: ([0-9.]+) s/, arr)) {
33+
secs = arr[1] + 0
34+
if (secs > 0.25) {
35+
printf " %6.2f s %s\n", secs, $0
36+
}
37+
}
38+
}
39+
' "$LOG" | sort -n | tail -20
40+
echo
41+
42+
# 3. Total wall time
43+
echo "--- Build totals ---"
44+
grep -E "Total time:|BUILD SUCCESS|BUILD FAILURE" "$LOG" | tail -3

scripts/preflight-release.sh

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/bin/bash
2+
# Pre-release checks for Maven Central deploy. Exits non-zero on any failure
3+
# so subsequent steps don't proceed if anything looks off.
4+
#
5+
# Usage: scripts/preflight-release.sh [expected-version]
6+
#
7+
# If expected-version is given, fails when pom.xml's version doesn't match.
8+
set -e
9+
10+
EXPECTED_VERSION="${1:-}"
11+
PROJECT_NAME=$(basename "$(pwd)")
12+
FAIL=0
13+
14+
red() { printf "\033[0;31m%s\033[0m\n" "$*"; }
15+
green() { printf "\033[0;32m%s\033[0m\n" "$*"; }
16+
yellow() { printf "\033[0;33m%s\033[0m\n" "$*"; }
17+
18+
echo "=== ${PROJECT_NAME} pre-release preflight ==="
19+
echo
20+
21+
# 1. Off corporate zscaler / network reaches Sonatype Central Portal
22+
echo "[1/7] Network connectivity to Sonatype Central Portal..."
23+
if curl -sS -o /dev/null -m 8 -w "%{http_code}" "https://central.sonatype.com/" 2>/dev/null | grep -qE "^(200|301|302)$"; then
24+
green " ✓ central.sonatype.com reachable"
25+
else
26+
red " ✗ central.sonatype.com NOT reachable (zscaler enabled? VPN?)"
27+
FAIL=$((FAIL + 1))
28+
fi
29+
30+
# 2. Working tree clean
31+
echo "[2/7] Working tree clean..."
32+
if [ -z "$(git status --porcelain)" ]; then
33+
green " ✓ no uncommitted changes"
34+
else
35+
red " ✗ uncommitted changes detected:"
36+
git status --porcelain | sed 's/^/ /'
37+
FAIL=$((FAIL + 1))
38+
fi
39+
40+
# 3. On master branch
41+
echo "[3/7] On master branch..."
42+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
43+
if [ "$BRANCH" = "master" ]; then
44+
green " ✓ on master"
45+
else
46+
red " ✗ on '${BRANCH}' (expected master)"
47+
FAIL=$((FAIL + 1))
48+
fi
49+
50+
# 4. In sync with origin (not behind; ahead is OK — those will get released)
51+
echo "[4/7] In sync with origin/master..."
52+
git fetch origin --quiet 2>/dev/null || true
53+
BEHIND=$(git rev-list HEAD..origin/master --count 2>/dev/null || echo 0)
54+
AHEAD=$(git rev-list origin/master..HEAD --count 2>/dev/null || echo 0)
55+
if [ "$BEHIND" -eq 0 ]; then
56+
if [ "$AHEAD" -eq 0 ]; then
57+
green " ✓ identical to origin/master"
58+
else
59+
green "${AHEAD} commit(s) ahead of origin/master (these will be in the release)"
60+
fi
61+
else
62+
red "${BEHIND} commit(s) behind origin/master — pull before releasing"
63+
FAIL=$((FAIL + 1))
64+
fi
65+
66+
# 5. Version in pom.xml
67+
echo "[5/7] Version check..."
68+
VERSION=$(grep -m1 '<version>' pom.xml | sed -E 's|.*<version>([^<]+)</version>.*|\1|')
69+
if [ -n "$EXPECTED_VERSION" ]; then
70+
if [ "$VERSION" = "$EXPECTED_VERSION" ]; then
71+
green " ✓ pom.xml version is ${VERSION}"
72+
else
73+
red " ✗ pom.xml version is ${VERSION} (expected ${EXPECTED_VERSION})"
74+
FAIL=$((FAIL + 1))
75+
fi
76+
else
77+
green " ✓ pom.xml version is ${VERSION} (no expected version supplied)"
78+
fi
79+
if echo "$VERSION" | grep -q "SNAPSHOT"; then
80+
red " ✗ pom.xml is a SNAPSHOT — release versions must not contain SNAPSHOT"
81+
FAIL=$((FAIL + 1))
82+
fi
83+
84+
# 6. GPG key available
85+
echo "[6/7] GPG key..."
86+
if gpg --list-secret-keys --keyid-format=long 2>/dev/null | grep -q '^sec'; then
87+
KEYID=$(gpg --list-secret-keys --keyid-format=long 2>/dev/null | grep '^sec' | head -1 | awk '{print $2}')
88+
green " ✓ GPG secret key available (${KEYID})"
89+
else
90+
red " ✗ no GPG secret key found — gpg signing will fail"
91+
FAIL=$((FAIL + 1))
92+
fi
93+
94+
# 7. Maven settings.xml has Sonatype credentials
95+
echo "[7/7] Maven settings.xml has Sonatype credentials..."
96+
SETTINGS_FILE="${HOME}/.m2/settings.xml"
97+
if [ -f "$SETTINGS_FILE" ]; then
98+
if grep -qE 'central|sonatype|ossrh' "$SETTINGS_FILE" 2>/dev/null; then
99+
green " ✓ settings.xml has central/sonatype/ossrh server entry"
100+
else
101+
yellow " ⚠ settings.xml exists but no central/sonatype/ossrh entry — verify credentials"
102+
fi
103+
else
104+
red " ✗ ~/.m2/settings.xml not found"
105+
FAIL=$((FAIL + 1))
106+
fi
107+
108+
echo
109+
if [ "$FAIL" -eq 0 ]; then
110+
green "=== preflight: PASS — ready to deploy ==="
111+
exit 0
112+
else
113+
red "=== preflight: ${FAIL} check(s) FAILED — fix before deploying ==="
114+
exit 1
115+
fi

0 commit comments

Comments
 (0)