Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ Pushing a version tag runs the GitHub release workflow, builds and verifies ever
the artifacts to a GitHub Release. The tag must match `versionName` exactly:

```shell
git tag v0.0.1
git push origin v0.0.1
git tag v0.0.3
git push origin v0.0.3
```

## Contributing
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ android {
applicationId = "net.megaproxy487"
minSdk = 26
targetSdk = 35
versionCode = 1
versionName = "0.0.1"
versionCode = 3
versionName = "0.0.3"
buildConfigField("String", "GIT_COMMIT_HASH", "\"$gitCommitHash\"")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
62 changes: 44 additions & 18 deletions scripts/build-release-apks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ echo "Running native tests"
go test ./...
)

echo "Running Android unit tests"
(
cd "$project_dir"
./gradlew testReleaseUnitTest
)

# gomobile architecture names and their corresponding Android ABI names.
targets=(
"arm64:arm64-v8a"
Expand All @@ -105,27 +99,59 @@ targets=(
"386:x86"
)

# A clean checkout has no app/libs/megaproxy.aar. Gradle resolves local AAR
# dependencies while configuring Android unit tests, so build the first ABI
# before invoking Gradle and reuse it for the first release APK below.
first_target="${targets[0]}"
first_go_arch="${first_target%%:*}"
first_android_abi="${first_target##*:}"
echo "Building initial native AAR for $first_android_abi"
(
cd "$project_dir/native"
gomobile bind \
-target="android/$first_go_arch" \
-androidapi 26 \
-trimpath \
-ldflags="-s -w -buildid=" \
-o ../app/libs/megaproxy.aar \
./mobile
)

echo "Running Android unit tests"
(
cd "$project_dir"
./gradlew testReleaseUnitTest
)

for target in "${targets[@]}"; do
go_arch="${target%%:*}"
android_abi="${target##*:}"
output_apk="$MEGAPROXY_RELEASE_DIR/mega-proxy-v${version_name}-${android_abi}.apk"

echo "Building optimized native AAR for $android_abi"
(
cd "$project_dir/native"
gomobile bind \
-target="android/$go_arch" \
-androidapi 26 \
-trimpath \
-ldflags="-s -w -buildid=" \
-o ../app/libs/megaproxy.aar \
./mobile
)
if [[ "$android_abi" == "$first_android_abi" ]]; then
echo "Reusing initial native AAR for $android_abi"
else
echo "Building optimized native AAR for $android_abi"
(
cd "$project_dir/native"
gomobile bind \
-target="android/$go_arch" \
-androidapi 26 \
-trimpath \
-ldflags="-s -w -buildid=" \
-o ../app/libs/megaproxy.aar \
./mobile
)
fi

echo "Building and signing $android_abi APK"
(
cd "$project_dir"
./gradlew clean assembleRelease
# Keep clean and assemble in separate Gradle invocations. When both are
# requested in one task graph, Gradle does not guarantee that clean has
# finished before every generated-resource task starts.
./gradlew clean
./gradlew assembleRelease
)
built_apk="$project_dir/app/build/outputs/apk/release/app-release.apk"
if [[ ! -f "$built_apk" ]]; then
Expand Down