Skip to content

Commit 7bab28f

Browse files
committed
Fix allowed schemes and add more tests
1 parent c68ba53 commit 7bab28f

File tree

4 files changed

+75
-17
lines changed

4 files changed

+75
-17
lines changed

android/ddg-url-predictor/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ mavenPublishing {
2222
// publishing to CentralPortal (https://repo.maven.apache.org/maven2/com/duckduckgo/urlpredictor/url-predictor-android/)
2323
publishToMavenCentral()
2424

25-
signAllPublications()
25+
// Only sign when we *don't* explicitly opt out (e.g. for real Central releases)
26+
if (!project.hasProperty("skipSigning")) {
27+
signAllPublications()
28+
}
2629

2730
coordinates("com.duckduckgo.urlpredictor", "url-predictor-android", "${getVersionName}")
2831

android/ddg-url-predictor/src/main/java/com/duckduckgo/urlpredictor/DecisionJson.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ object DecisionJson {
4141
"about",
4242
"view-source",
4343
"duck",
44-
"edge",
45-
"chrome",
4644
),
4745
)
4846
}

android/ddg-url-predictor/src/test/java/UrlPredictorTest.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,22 @@ class UrlPredictorTests {
109109
val d = classify("-badlabel.com")
110110
assertTrue(d is Decision.Search)
111111
}
112+
113+
@Test
114+
fun `chrome scheme becomes search`() {
115+
val d = classify("chrome://flags")
116+
assertTrue(d is Decision.Search)
117+
}
118+
119+
@Test
120+
fun `edge scheme becomes search`() {
121+
val d = classify("edge://flags")
122+
assertTrue(d is Decision.Search)
123+
}
124+
125+
@Test
126+
fun `duck scheme navigates`() {
127+
val d = classify("duck://flags")
128+
assertTrue(d is Decision.Navigate)
129+
}
112130
}

android/release_android.sh

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2428
NEW_VERSION=""
2529
NEXT_SNAPSHOT=""
@@ -28,6 +32,9 @@ BUMP_KIND="patch" # patch|minor|major
2832
PUSH="true"
2933
DRY_RUN="false"
3034
TAG_PREFIX="${TAG_PREFIX:-}"
35+
MAVEN_LOCAL="false"
36+
MAVEN_LOCAL_CMD="${MAVEN_LOCAL_CMD:-./gradlew :ddg-url-predictor:publishToMavenLocal -PskipSigning}"
37+
3138

3239
die() { echo "Error: $*" >&2; exit 1; }
3340
run() { 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
5261
EOF
@@ -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";;
@@ -127,9 +141,15 @@ fi
127141

128142
# Ensure tag doesn't already exist
129143
TAG_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)"
133153
fi
134154

135155
echo "Current VERSION_NAME: ${CURRENT_VERSION}"
@@ -139,6 +159,10 @@ echo "Version file : ${VERSION_FILE}"
139159
echo "Tag name : ${TAG_NAME}"
140160
echo "Push to remote : ${PUSH}"
141161
echo "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
142166
echo
143167

144168
# --- Step 1: set release version ---
@@ -149,28 +173,43 @@ run "git add '$VERSION_FILE'"
149173
run "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 ---
155190
if [[ "$PUSH" == "true" ]]; then
156191
run "git push"
157192
run "git push --tags"
158193
else
159-
echo "[info] Skipping push (--no-push)"
194+
echo "[info] Skipping push (--no-push or --maven-local)"
160195
fi
161196

162-
# --- Step 5: bump to next snapshot ---
197+
# --- Step 6: bump to next snapshot ---
163198
set_version "$NEXT_SNAPSHOT"
164199

165-
# --- Step 6: commit snapshot ---
200+
# --- Step 7: commit snapshot ---
166201
run "git add '$VERSION_FILE'"
167202
run "git commit -m 'Prepare next development version.'"
168203

169-
# --- Step 7: push snapshot commit ---
204+
# --- Step 8: push snapshot commit ---
170205
if [[ "$PUSH" == 'true' ]]; then
171206
run "git push"
172207
else
173-
echo "[info] Skipping push (--no-push)"
208+
echo "[info] Skipping push of snapshot commit (--no-push or --maven-local)"
174209
fi
175210

176211
echo "✅ 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

Comments
 (0)