Skip to content

Commit 02946dc

Browse files
committed
chore: add manual release script and Artifactory init.gradle
1 parent 7ab459a commit 02946dc

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

init.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
settingsEvaluated { settings ->
2+
settings.pluginManagement {
3+
repositories {
4+
clear()
5+
maven { url 'https://maven.artifacts.twilio.com/artifactory/virtual-maven-thirdparty/' }
6+
}
7+
}
8+
settings.dependencyResolutionManagement {
9+
repositories {
10+
clear()
11+
maven { url 'https://maven.artifacts.twilio.com/artifactory/virtual-maven-thirdparty/' }
12+
maven { url 'https://maven.artifacts.twilio.com/artifactory/remote-maven-google/' }
13+
}
14+
}
15+
}
16+

scripts/release.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Manual release script for Android/Kotlin SDKs.
5+
# Resolves dependencies from internal Artifactory (curated inputs), builds,
6+
# signs with GPG, and publishes to Maven Central via the nexus-publish plugin.
7+
#
8+
# Usage:
9+
# export SIGNING_KEY_ID=<8-char GPG key ID>
10+
# export SIGNING_KEY_PASSWORD=<GPG key passphrase>
11+
# export SIGNING_PRIVATE_KEY_BASE64=<base64-encoded ASCII-armored private key>
12+
# export ORG_GRADLE_PROJECT_sonatypeUsername=<Central Portal token username>
13+
# export ORG_GRADLE_PROJECT_sonatypePassword=<Central Portal token password>
14+
# ./scripts/release.sh
15+
16+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
18+
cd "$PROJECT_ROOT"
19+
20+
# --- Preflight checks ---
21+
22+
echo "==> Preflight checks"
23+
24+
missing=()
25+
[[ -z "${SIGNING_KEY_ID:-}" ]] && missing+=("SIGNING_KEY_ID")
26+
[[ -z "${SIGNING_KEY_PASSWORD:-}" ]] && missing+=("SIGNING_KEY_PASSWORD")
27+
[[ -z "${SIGNING_PRIVATE_KEY_BASE64:-}" ]] && missing+=("SIGNING_PRIVATE_KEY_BASE64")
28+
[[ -z "${ORG_GRADLE_PROJECT_sonatypeUsername:-}" ]] && missing+=("ORG_GRADLE_PROJECT_sonatypeUsername")
29+
[[ -z "${ORG_GRADLE_PROJECT_sonatypePassword:-}" ]] && missing+=("ORG_GRADLE_PROJECT_sonatypePassword")
30+
31+
if [[ ${#missing[@]} -gt 0 ]]; then
32+
echo "ERROR: Missing required environment variables:"
33+
printf ' - %s\n' "${missing[@]}"
34+
exit 1
35+
fi
36+
37+
if [[ ! -f "gradle.properties" ]]; then
38+
echo "ERROR: gradle.properties not found. Run from project root."
39+
exit 1
40+
fi
41+
42+
if [[ ! -f "init.gradle" ]]; then
43+
echo "ERROR: init.gradle not found. See docs/manual-release-guide.md for setup."
44+
exit 1
45+
fi
46+
47+
# --- Extract project metadata ---
48+
49+
VERSION=$(grep "^VERSION_NAME=" gradle.properties | cut -d= -f2)
50+
GROUP=$(grep "^GROUP=" gradle.properties | cut -d= -f2)
51+
52+
if [[ -z "$VERSION" ]]; then
53+
echo "ERROR: VERSION_NAME not found in gradle.properties"
54+
exit 1
55+
fi
56+
57+
if [[ -z "$GROUP" ]]; then
58+
echo "ERROR: GROUP not found in gradle.properties"
59+
exit 1
60+
fi
61+
62+
echo " Version: $VERSION"
63+
echo " Group: $GROUP"
64+
echo ""
65+
66+
# --- Verify Artifactory reachability ---
67+
68+
echo "==> Verifying Artifactory reachability"
69+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://maven.artifacts.twilio.com/artifactory/virtual-maven-thirdparty/" 2>&1) || {
70+
echo "ERROR: curl failed to connect to Artifactory (exit code $?). Are you on the Twilio VPN?"
71+
exit 1
72+
}
73+
if [[ "$HTTP_CODE" != "200" ]]; then
74+
echo "ERROR: Cannot reach Artifactory (HTTP $HTTP_CODE). Are you on the Twilio network?"
75+
exit 1
76+
fi
77+
echo " Artifactory: OK"
78+
echo ""
79+
80+
# --- Confirm before proceeding ---
81+
82+
read -rp "Publish $GROUP:$VERSION to Maven Central? [y/N] " confirm
83+
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
84+
echo "Aborted."
85+
exit 0
86+
fi
87+
88+
# --- Build, sign, publish, and release ---
89+
90+
echo ""
91+
echo "==> Building, signing, and publishing to Maven Central"
92+
echo " (dependencies resolved from internal Artifactory)"
93+
echo ""
94+
95+
./gradlew --init-script init.gradle \
96+
clean build publish publishToSonatype closeAndReleaseSonatypeStagingRepository \
97+
-Prelease -x test
98+
99+
echo ""
100+
echo "==> Release complete!"
101+
echo ""
102+
echo "Next steps:"
103+
echo " git tag $VERSION"
104+
echo " git push origin $VERSION"
105+

0 commit comments

Comments
 (0)