Build script refactor to support AAB build for Google Play

This commit is contained in:
albexk 2024-09-17 20:55:51 +03:00
parent e2dd5109f9
commit 58d1178416
2 changed files with 19 additions and 11 deletions

View file

@ -403,13 +403,13 @@ jobs:
ANDROID_KEYSTORE_KEY_ALIAS: ${{ secrets.ANDROID_RELEASE_KEYSTORE_KEY_ALIAS }}
ANDROID_KEYSTORE_KEY_PASS: ${{ secrets.ANDROID_RELEASE_KEYSTORE_KEY_PASS }}
shell: bash
run: ./deploy/build_android.sh --aab --apk all --build-platform ${{ env.ANDROID_BUILD_PLATFORM }}
run: ./deploy/build_android.sh --aab --play --apk all --build-platform ${{ env.ANDROID_BUILD_PLATFORM }}
- name: 'Upload x86_64 apk'
uses: actions/upload-artifact@v4
with:
name: AmneziaVPN-android-x86_64
path: deploy/build/AmneziaVPN-x86_64-release.apk
path: deploy/build/AmneziaVPN-oss-x86_64-release.apk
compression-level: 0
retention-days: 7
@ -417,7 +417,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: AmneziaVPN-android-x86
path: deploy/build/AmneziaVPN-x86-release.apk
path: deploy/build/AmneziaVPN-oss-x86-release.apk
compression-level: 0
retention-days: 7
@ -425,7 +425,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: AmneziaVPN-android-arm64-v8a
path: deploy/build/AmneziaVPN-arm64-v8a-release.apk
path: deploy/build/AmneziaVPN-oss-arm64-v8a-release.apk
compression-level: 0
retention-days: 7
@ -433,7 +433,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: AmneziaVPN-android-armeabi-v7a
path: deploy/build/AmneziaVPN-armeabi-v7a-release.apk
path: deploy/build/AmneziaVPN-oss-armeabi-v7a-release.apk
compression-level: 0
retention-days: 7
@ -441,7 +441,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: AmneziaVPN-android
path: deploy/build/AmneziaVPN-release.aab
path: deploy/build/AmneziaVPN-play-release.aab
compression-level: 0
retention-days: 7

View file

@ -23,6 +23,7 @@ Options:
By default, the latest available platform is used
-m, --move Move the build result to the root of the build directory
-f, --fdroid Build for F-Droid
-p, --play Build AAB for Google Play
-h, --help Display this help
EOT
@ -30,7 +31,7 @@ EOT
BUILD_TYPE="release"
opts=$(getopt -l debug,aab,apk:,build-platform:,move,fdroid,help -o "dua:b:mfh" -- "$@")
opts=$(getopt -l debug,aab,apk:,build-platform:,move,fdroid,play,help -o "dua:b:mfph" -- "$@")
eval set -- "$opts"
while true; do
case "$1" in
@ -40,6 +41,7 @@ while true; do
-b | --build-platform) ANDROID_BUILD_PLATFORM=$2; shift 2;;
-m | --move) MOVE_RESULT=1; shift;;
-f | --fdroid) FDROID=1; shift;;
-p | --play) PLAY=1; shift;;
-h | --help) usage; exit 0;;
--) shift; break;;
esac
@ -149,11 +151,17 @@ if [ -v FDROID ]; then
BUILD_TYPE="fdroid"
fi
if [ -v PLAY ]; then
AAB_FLAVOR="play"
else
AAB_FLAVOR="oss"
fi
if [ -v AAB ]; then
gradle_opts+=(bundle"${BUILD_TYPE^}")
gradle_opts+=(bundle"${AAB_FLAVOR^}${BUILD_TYPE^}")
fi
if [ -v ABIS ]; then
gradle_opts+=(assemble"${BUILD_TYPE^}")
gradle_opts+=(assembleOss"${BUILD_TYPE^}")
fi
$OUT_APP_DIR/android-build/gradlew \
@ -164,7 +172,7 @@ $OUT_APP_DIR/android-build/gradlew \
if [[ -v CI || -v MOVE_RESULT ]]; then
echo "Moving APK/AAB..."
if [ -v AAB ]; then
mv -u $OUT_APP_DIR/android-build/build/outputs/bundle/$BUILD_TYPE/AmneziaVPN-$BUILD_TYPE.aab \
mv -u $OUT_APP_DIR/android-build/build/outputs/bundle/$AAB_FLAVOR"${BUILD_TYPE^}"/AmneziaVPN-$AAB_FLAVOR-$BUILD_TYPE.aab \
$PROJECT_DIR/deploy/build/
fi
@ -181,7 +189,7 @@ if [[ -v CI || -v MOVE_RESULT ]]; then
IFS=';' read -r -a abi_array <<< "$ABIS"
for ABI in "${abi_array[@]}"
do
mv -u $OUT_APP_DIR/android-build/build/outputs/apk/$BUILD_TYPE/AmneziaVPN-$ABI-$suffix.apk \
mv -u $OUT_APP_DIR/android-build/build/outputs/apk/oss/$BUILD_TYPE/AmneziaVPN-oss-$ABI-$suffix.apk \
$PROJECT_DIR/deploy/build/
done
fi