From cf0f786e7cdb146754b1d4ea40b1916bf79ededd Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Sun, 18 May 2025 01:45:32 +0530 Subject: [PATCH] fix: disallow manual version specification Signed-off-by: Akash Yadav --- .gitlab-ci.yml | 9 ++++----- scripts/ci-build.sh | 20 +++++++++++--------- scripts/ci-publish-packages.sh | 12 +++++++----- scripts/ci-update-site.sh | 4 +++- scripts/prebuild.sh | 18 +++++++++--------- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eb7e3d5e..0a9f8285 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,6 @@ default: variables: &build_variables PRODUCTION_BRANCH: main - VERSION_NAME: "138.0.3" SB_GAPI_KEY_FILE: /opt/IronFox/sb-gapi.data KEYSTORE: /opt/IronFox/signing-key.jks GRADLE_USER_HOME: "$CI_PROJECT_DIR/.cache/gradle" @@ -126,7 +125,7 @@ build-apk: - saas-linux-xlarge-amd64 parallel: matrix: - - VERSION_CODE: ["31380300", "31380310", "31380320"] + - BUILD_VARIANT: ["arm", "arm64", "x86_64"] variables: <<: *build_variables <<: *build_setup_steps @@ -149,7 +148,7 @@ build-apk: - if: $CI_COMMIT_TAG when: never -build-apk-set: +build-bundle: image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG stage: build_ironfox timeout: 2h @@ -162,7 +161,7 @@ build-apk-set: tags: - saas-linux-xlarge-amd64 variables: - VERSION_CODE: "31380330" + BUILD_VARIANT: "bundle" <<: *build_variables <<: *build_setup_steps script: @@ -193,7 +192,7 @@ prepare-release: - job: "build-apk" artifacts: true optional: true - - job: "build-apk-set" + - job: "build-bundle" artifacts: true optional: true rules: diff --git a/scripts/ci-build.sh b/scripts/ci-build.sh index 9854f7e5..7b3be6cc 100755 --- a/scripts/ci-build.sh +++ b/scripts/ci-build.sh @@ -7,24 +7,26 @@ set -eu set -o pipefail set -o xtrace -case $(echo "$VERSION_CODE" | cut -c 7) in -0) +source "$(realpath $(dirname "$0"))/versions.sh" + +case "${BUILD_VARIANT+x}" in +"arm") BUILD_TYPE='apk' BUILD_ABI='armeabi-v7a' ;; -1) +"x86_64") BUILD_TYPE='apk' BUILD_ABI='x86_64' ;; -2) +"arm64") BUILD_TYPE='apk' BUILD_ABI='arm64-v8a' ;; -3) +"bundle") BUILD_TYPE='bundle' ;; *) - echo "Unknown target code in $VERSION_CODE." >&2 + echo "Unknown build variant: '$BUILD_VARIANT'." >&2 exit 1 ;; esac @@ -51,7 +53,7 @@ bash -x ./scripts/get_sources.sh source "scripts/env_local.sh" # Prepare sources -bash -x ./scripts/prebuild.sh "$VERSION_NAME" "$VERSION_CODE" +bash -x ./scripts/prebuild.sh "$BUILD_VARIANT" # If we're building an APK set, the following environment variables are required if [[ "$BUILD_TYPE" == "bundle" ]]; then @@ -75,7 +77,7 @@ if [[ "$BUILD_TYPE" == "apk" ]]; then # Sign APK APK_IN="$(ls "$fenix"/app/build/outputs/apk/fenix/release/*.apk)" - APK_OUT="$APK_ARTIFACTS/IronFox-v${VERSION_NAME}-${BUILD_ABI}.apk" + APK_OUT="$APK_ARTIFACTS/IronFox-v${FIREFOX_TAG}-${BUILD_ABI}.apk" "$ANDROID_HOME/build-tools/35.0.0/apksigner" sign \ --ks="$KEYSTORE" \ --ks-pass="pass:$KEYSTORE_PASS" \ @@ -88,7 +90,7 @@ fi if [[ "$BUILD_TYPE" == "bundle" ]]; then # Build signed APK set AAB_IN="$(ls "$fenix"/app/build/outputs/bundle/fenixRelease/*.aab)" - APKS_OUT="$APKS_ARTIFACTS/IronFox-v${VERSION_NAME}.apks" + APKS_OUT="$APKS_ARTIFACTS/IronFox-v${FIREFOX_TAG}.apks" "$builddir"/bundletool build-apks \ --bundle="$AAB_IN" \ --output="$APKS_OUT" \ diff --git a/scripts/ci-publish-packages.sh b/scripts/ci-publish-packages.sh index f28fdba9..1cabb99c 100755 --- a/scripts/ci-publish-packages.sh +++ b/scripts/ci-publish-packages.sh @@ -5,6 +5,8 @@ set -eu +source "$(realpath $(dirname "$0"))/versions.sh" + export GENERIC_PACKAGES_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic" upload_to_package_registry() { @@ -14,7 +16,7 @@ upload_to_package_registry() { local file_name="$(basename "$file")" curl --header "PRIVATE-TOKEN: $GITLAB_CI_API_TOKEN" \ --upload-file "$file" \ - "$GENERIC_PACKAGES_URL/${package_name}/${VERSION_NAME}/${file_name}" + "$GENERIC_PACKAGES_URL/${package_name}/${FIREFOX_TAG}/${file_name}" } export ARTIFACTS=$CI_PROJECT_DIR/artifacts @@ -39,7 +41,7 @@ upload_asset() { echo "$(sha256sum -b "$file" | cut -d ' ' -f 1) ${file_name}" >> "$CHECKSUMS_FILE" upload_to_package_registry "$file" "$package_name" - assets+=("{\"name\": \"$file_name\",\"url\": \"$GENERIC_PACKAGES_URL/${package_name}/${VERSION_NAME}/${file_name}\",\"link_type\": \"package\",\"direct_asset_path\": \"/${file_name}\"}") + assets+=("{\"name\": \"$file_name\",\"url\": \"$GENERIC_PACKAGES_URL/${package_name}/${FIREFOX_TAG}/${file_name}\",\"link_type\": \"package\",\"direct_asset_path\": \"/${file_name}\"}") } # Upload packages to package registry @@ -54,7 +56,7 @@ for apks in "$APKS_ARTIFACTS"/*.apks; do done { - changelog_file="$CI_PROJECT_DIR/changelogs/${VERSION_NAME}.md" + changelog_file="$CI_PROJECT_DIR/changelogs/${FIREFOX_TAG}.md" if [[ -f "$changelog_file" ]]; then cat "$changelog_file" fi @@ -73,8 +75,8 @@ done { echo "---" - echo "name: IronFox v${VERSION_NAME}" - echo "tag-name: v${VERSION_NAME}" + echo "name: IronFox v${FIREFOX_TAG}" + echo "tag-name: v${FIREFOX_TAG}" echo "description: |" awk '{print " " $0}' < "$RELEASE_NOTES_FILE" echo "assets-link:" diff --git a/scripts/ci-update-site.sh b/scripts/ci-update-site.sh index e7a98c15..d7f8f9dd 100644 --- a/scripts/ci-update-site.sh +++ b/scripts/ci-update-site.sh @@ -5,6 +5,8 @@ set -eu +source "$(realpath $(dirname "$0"))/versions.sh" + git clone "https://oauth2:$GITLAB_CI_PUSH_TOKEN@gitlab.com/$TARGET_REPO_PATH.git" target-repo cd target-repo || { echo "Unable to cd into target-repo"; exit 1; }; @@ -12,7 +14,7 @@ cd target-repo || { echo "Unable to cd into target-repo"; exit 1; }; ./scripts/gen_patch_pages.py ../scripts/patches.yaml # Update version name -sed -i "s/IRONFOX_VERSION = .*/IRONFOX_VERSION = \"${VERSION_NAME}\";/g" \ +sed -i "s/IRONFOX_VERSION = .*/IRONFOX_VERSION = \"${FIREFOX_TAG}\";/g" \ ./src/version.ts # Commit changes diff --git a/scripts/prebuild.sh b/scripts/prebuild.sh index 22bc2666..e7bc367d 100755 --- a/scripts/prebuild.sh +++ b/scripts/prebuild.sh @@ -40,8 +40,8 @@ function remove_glean_telemetry() { grep -rnlI "${dir}" -e "${telemetry_url}" | xargs -L1 sed -i -r -e "s|${telemetry_url}|localhost:70000|g" } -if [ -z "$1" ] || [ -z "$2" ]; then - echo "Usage: $0 versionName versionCode" >&1 +if [ -z "$1" ]; then + echo "Usage: $0 arm|arm64|x86_64|bundle" >&1 exit 1 fi @@ -129,7 +129,7 @@ sed -i \ -e 's|applicationId "org.mozilla"|applicationId "org.ironfoxoss"|' \ -e 's|applicationIdSuffix ".firefox"|applicationIdSuffix ".ironfox"|' \ -e 's|"sharedUserId": "org.mozilla.firefox.sharedID"|"sharedUserId": "org.ironfoxoss.ironfox.sharedID"|' \ - -e "s/Config.releaseVersionName(project)/'$1'/" \ + -e "s/Config.releaseVersionName(project)/'${FIREFOX_TAG}'/" \ app/build.gradle sed -i \ -e '/android:targetPackage/s/org.mozilla.firefox/org.ironfoxoss.ironfox/' \ @@ -196,29 +196,29 @@ rm app/src/main/assets/searchplugins/reddit.xml rm app/src/main/assets/searchplugins/youtube.xml # Set up target parameters -case $(echo "$2" | cut -c 7) in -0) +case "$1" in +"arm") # APK for armeabi-v7a abi='"armeabi-v7a"' target=arm-linux-androideabi llvmtarget="ARM" rusttarget=arm ;; -1) +"x86_64") # APK for x86_64 abi='"x86_64"' target=x86_64-linux-android llvmtarget="X86_64" rusttarget=x86_64 ;; -2) +"arm64") # APK for arm64-v8a abi='"arm64-v8a"' target=aarch64-linux-android llvmtarget="AArch64" rusttarget=arm64 ;; -3) +"bundle") # AAB for both armeabi-v7a and arm64-v8a abi='"arm64-v8a", "armeabi-v7a", "x86_64"' target='' @@ -226,7 +226,7 @@ case $(echo "$2" | cut -c 7) in rusttarget='arm64,arm,x86_64' ;; *) - echo "Unknown target code in $2." >&2 + echo "Unknown build variant: '$1'" >&2 exit 1 ;; esac