@@ -5,21 +5,25 @@ set -euo pipefail
55# 1) Set version.properties to a non-SNAPSHOT
66# 2) Commit "Release X.Y.Z"
77# 3) Tag "X.Y.Z" (annotated)
8- # 4) Push + push --tags
9- # 5) Bump to next -SNAPSHOT (defaults to patch+1)
10- # 6) Commit "Prepare next development version."
11- # 7) Push
8+ # 4) (Optional) Publish release version to Maven local
9+ # 5) Push + push --tags
10+ # 6) Bump to next -SNAPSHOT (defaults to patch+1)
11+ # 7) Commit "Prepare next development version."
12+ # 8) Push
1213#
1314# Usage examples:
1415# ./release_android.sh --new-version 1.2.3
1516# ./release_android.sh --new-version 1.2.3 --bump minor
1617# ./release_android.sh --new-version 1.2.3 --next-snapshot 1.3.0-SNAPSHOT
18+ # ./release_android.sh --new-version 1.2.3 --maven-local
1719#
1820# Optional:
1921# --version-file <path> default: version.properties
2022# --no-push do everything except pushing
2123# --dry-run print what would happen, don’t change anything
2224# --tag-prefix "" default: "" (set to "v" if you want tags like v1.2.3)
25+ # --maven-local Publish release version to Maven local and skip push
26+ # (runs MAVEN_LOCAL_CMD, default: "./gradlew publishToMavenLocal")
2327
2428NEW_VERSION=" "
2529NEXT_SNAPSHOT=" "
@@ -28,6 +32,9 @@ BUMP_KIND="patch" # patch|minor|major
2832PUSH=" true"
2933DRY_RUN=" false"
3034TAG_PREFIX=" ${TAG_PREFIX:- } "
35+ MAVEN_LOCAL=" false"
36+ MAVEN_LOCAL_CMD=" ${MAVEN_LOCAL_CMD:- ./ gradlew : ddg-url-predictor: publishToMavenLocal -PskipSigning} "
37+
3138
3239die () { echo " Error: $* " >&2 ; exit 1; }
3340run () { if [[ " $DRY_RUN " == " true" ]]; then echo " [dry-run] $* " ; else eval " $@ " ; fi ; }
@@ -47,6 +54,8 @@ Options:
4754 (default: ${VERSION_FILE} )
4855 --tag-prefix <prefix> Prefix for git tag (default: "${TAG_PREFIX} ")
4956 --no-push Do everything except pushing
57+ --maven-local Publish release version to Maven local and skip push
58+ (uses MAVEN_LOCAL_CMD: ${MAVEN_LOCAL_CMD} )
5059 --dry-run Show actions without changing anything
5160 -h | --help Show this help
5261EOF
@@ -61,6 +70,11 @@ while [[ $# -gt 0 ]]; do
6170 --version-file) VERSION_FILE=" ${2-} " ; shift 2;;
6271 --tag-prefix) TAG_PREFIX=" ${2-} " ; shift 2;;
6372 --no-push) PUSH=" false" ; shift ;;
73+ --maven-local)
74+ MAVEN_LOCAL=" true"
75+ PUSH=" false" # releasing to mavenLocal implies no push
76+ shift
77+ ;;
6478 --dry-run) DRY_RUN=" true" ; shift ;;
6579 -h|--help) usage; exit 0;;
6680 * ) die " Unknown option: $1 " ;;
127141
128142# Ensure tag doesn't already exist
129143TAG_NAME=" ${TAG_PREFIX}${NEW_VERSION} "
130- run " git fetch --tags"
131- if git rev-parse " $TAG_NAME " > /dev/null 2>&1 ; then
132- die " Tag already exists: $TAG_NAME "
144+
145+ if [[ " $MAVEN_LOCAL " != " true" ]]; then
146+ # Ensure tag doesn't already exist
147+ run " git fetch --tags"
148+ if git rev-parse " $TAG_NAME " > /dev/null 2>&1 ; then
149+ die " Tag already exists: $TAG_NAME "
150+ fi
151+ else
152+ echo " [info] Skipping tag existence check (--maven-local)"
133153fi
134154
135155echo " Current VERSION_NAME: ${CURRENT_VERSION} "
@@ -139,6 +159,10 @@ echo "Version file : ${VERSION_FILE}"
139159echo " Tag name : ${TAG_NAME} "
140160echo " Push to remote : ${PUSH} "
141161echo " Dry run : ${DRY_RUN} "
162+ echo " Maven local : ${MAVEN_LOCAL} "
163+ if [[ " $MAVEN_LOCAL " == " true" ]]; then
164+ echo " Maven local command : ${MAVEN_LOCAL_CMD} "
165+ fi
142166echo
143167
144168# --- Step 1: set release version ---
@@ -149,28 +173,43 @@ run "git add '$VERSION_FILE'"
149173run " git commit -m 'Release ${NEW_VERSION} '"
150174
151175# --- Step 3: tag release (annotated) ---
152- run " git tag -a '${TAG_NAME} ' -m '${NEW_VERSION} '"
176+ # # --- Step 3: tag release (annotated) ---
177+ if [[ " $MAVEN_LOCAL " != " true" ]]; then
178+ run " git tag -a '${TAG_NAME} ' -m '${NEW_VERSION} '"
179+ else
180+ echo " [info] Skipping tag creation (--maven-local)"
181+ fi
182+
183+ # --- Step 4 (optional): publish to Maven local ---
184+ if [[ " $MAVEN_LOCAL " == " true" ]]; then
185+ echo " Publishing release ${NEW_VERSION} to Maven local..."
186+ run " ${MAVEN_LOCAL_CMD} "
187+ fi
153188
154- # --- Step 4 : push commit + tags ---
189+ # --- Step 5 : push commit + tags ---
155190if [[ " $PUSH " == " true" ]]; then
156191 run " git push"
157192 run " git push --tags"
158193else
159- echo " [info] Skipping push (--no-push)"
194+ echo " [info] Skipping push (--no-push or --maven-local )"
160195fi
161196
162- # --- Step 5 : bump to next snapshot ---
197+ # --- Step 6 : bump to next snapshot ---
163198set_version " $NEXT_SNAPSHOT "
164199
165- # --- Step 6 : commit snapshot ---
200+ # --- Step 7 : commit snapshot ---
166201run " git add '$VERSION_FILE '"
167202run " git commit -m 'Prepare next development version.'"
168203
169- # --- Step 7 : push snapshot commit ---
204+ # --- Step 8 : push snapshot commit ---
170205if [[ " $PUSH " == ' true' ]]; then
171206 run " git push"
172207else
173- echo " [info] Skipping push (--no-push)"
208+ echo " [info] Skipping push of snapshot commit (--no-push or --maven-local )"
174209fi
175210
176211echo " ✅ Release ${NEW_VERSION} completed. Next development version: ${NEXT_SNAPSHOT} "
212+ if [[ " $MAVEN_LOCAL " == " true" ]]; then
213+ echo " 📦 Published ${NEW_VERSION} to Maven local (command: ${MAVEN_LOCAL_CMD} )"
214+ fi
215+
0 commit comments