diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 585b5181..d4cdb5c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,13 +8,6 @@ --header "JOB-TOKEN: $CI_JOB_TOKEN" \ "${CI_API_V4_URL}/projects/$CI_PROJECT_ID/secure_files/$KEYSTORE_SECFILEID/download" \ --output "$KEYSTORE" - - wget https://github.com/google/bundletool/releases/download/${BUNDLETOOL}/bundletool-all-${BUNDLETOOL}.jar -O /root/bin/bundletool.jar - - | - { - echo '#!/bin/bash' - echo 'exec java -jar /root/bin/bundletool.jar "$@"' - } > /root/bin/bundletool - - chmod +x /root/bin/bundletool variables: &build_variables PRODUCTION_BRANCH: main diff --git a/scripts/build.sh b/scripts/build.sh index 83ae2ce1..00d7c7cc 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -19,6 +19,10 @@ set -e +if [ -z "$1" ]; then + echo "Usage: $0 apk|bundle" >&1 + exit 1 +fi if [[ -n ${FDROID_BUILD+x} ]]; then source "$(dirname "$0")/env_fdroid.sh" @@ -117,5 +121,10 @@ popd # shellcheck disable=SC2154 pushd "$fenix" -gradle assembleRelease -popd +if [[ "$1" == "apk" ]]; then + gradle :app:assembleRelease +fi +if [[ "$1" == "bundle" ]]; then + gradle :app:bundleRelease -Paab +fi +popd \ No newline at end of file diff --git a/scripts/ci-build.sh b/scripts/ci-build.sh index a559f3ec..b69f0a20 100755 --- a/scripts/ci-build.sh +++ b/scripts/ci-build.sh @@ -16,7 +16,7 @@ case $(echo "$VERSION_CODE" | cut -c 7) in BUILD_ABI='arm64-v8a' ;; 2) - BUILD_TYPE='apkset' + BUILD_TYPE='bundle' ;; *) echo "Unknown target code in $VERSION_CODE." >&2 @@ -24,16 +24,6 @@ case $(echo "$VERSION_CODE" | cut -c 7) in ;; esac -export ARTIFACTS=$CI_PROJECT_DIR/artifacts -export APK_ARTIFACTS=$ARTIFACTS/apk -export APKS_ARTIFACTS=$ARTIFACTS/apks -export AAR_ARTIFACTS=$ARTIFACTS/aar - -mkdir -p "$APK_ARTIFACTS" -mkdir -p "$APKS_ARTIFACTS" -mkdir -p "$AAR_ARTIFACTS" - - # Setup environment variables. See Dockerfile. source "/opt/env_docker.sh" @@ -51,14 +41,14 @@ source "scripts/env_local.sh" bash -x ./scripts/prebuild.sh "$VERSION_NAME" "$VERSION_CODE" # If we're building an APK set, the following environment variables are required -if [[ "$BUILD_TYPE" == "apkset" ]]; then +if [[ "$BUILD_TYPE" == "bundle" ]]; then export MOZ_ANDROID_FAT_AAR_ARMEABI_V7A="$AAR_ARTIFACTS/geckoview-armeabi-v7a.aar" export MOZ_ANDROID_FAT_AAR_ARM64_V8A="$AAR_ARTIFACTS/geckoview-arm64-v8a.aar" export MOZ_ANDROID_FAT_AAR_ARCHITECTURES="armeabi-v7a,arm64-v8a" fi # Build -bash -x scripts/build.sh +bash -x scripts/build.sh "$BUILD_TYPE" if [[ "$BUILD_TYPE" == "apk" ]]; then # Copy geckoview AAR @@ -77,12 +67,7 @@ if [[ "$BUILD_TYPE" == "apk" ]]; then "$APK_IN" fi -if [[ "$BUILD_TYPE" == "apkset" ]]; then - # Build bundle - pushd "$fenix" - gradle :app:bundleRelease - popd - +if [[ "$BUILD_TYPE" == "bundle" ]]; then # Build signed APK set AAB_IN="$(ls "$fenix"/app/build/outputs/bundle/release/*.aab)" APKS_OUT="$APKS_ARTIFACTS/IronFox-v${VERSION_NAME}.apks" diff --git a/scripts/env_common.sh b/scripts/env_common.sh index 5c03c50d..0d475287 100644 --- a/scripts/env_common.sh +++ b/scripts/env_common.sh @@ -9,4 +9,13 @@ export MOZ_CHROME_MULTILOCALE export NSS_DIR="$application_services/libs/desktop/linux-x86-64/nss" export NSS_STATIC=1 +export ARTIFACTS="$rootdir/artifacts" +export APK_ARTIFACTS=$ARTIFACTS/apk +export APKS_ARTIFACTS=$ARTIFACTS/apks +export AAR_ARTIFACTS=$ARTIFACTS/aar + +mkdir -p "$APK_ARTIFACTS" +mkdir -p "$APKS_ARTIFACTS" +mkdir -p "$AAR_ARTIFACTS" + export env_source="true" \ No newline at end of file diff --git a/scripts/get_sources.sh b/scripts/get_sources.sh index c9b045a9..7adb593f 100755 --- a/scripts/get_sources.sh +++ b/scripts/get_sources.sh @@ -7,6 +7,7 @@ WASI_TAG="wasi-sdk-20" GLEAN_TAG="v62.0.0" GMSCORE_TAG="v0.3.6.244735" APPSERVICES_TAG="v134.0" +BUNDLETOOL_TAG="1.18.0" # Configuration ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" @@ -107,6 +108,23 @@ do_download() { mkdir -p "$BUILDDIR" +if ! [[ -f "$BUILDDIR/bundletool.jar" ]]; then + echo "Downloading bundletool..." + wget https://github.com/google/bundletool/releases/download/${BUNDLETOOL_TAG}/bundletool-all-${BUNDLETOOL_TAG}.jar \ + -O "$BUILDDIR/bundletool.jar" +fi + +if ! [[ -f "$BUILDDIR/bundletool" ]]; then + echo "Creating bundletool script..." + { + echo '#!/bin/bash' + echo "exec java -jar ${BUILDDIR}/bundletool.jar \"\$@\"" + } > "$BUILDDIR/bundletool" + chmod +x "$BUILDDIR/bundletool" +fi + +echo "'bundletool' is set up at $BUILDDIR/bundletool" + echo "Cloning glean..." git clone --branch "$GLEAN_TAG" --depth=1 "https://github.com/mozilla/glean" "$GLEANDIR"