diff --git a/Gemfile.lock b/Gemfile.lock index 5bcc906b379f..fc9c0423ffbd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,8 +8,8 @@ GEM artifactory (3.0.17) atomos (0.1.3) aws-eventstream (1.4.1) - aws-partitions (1.1309.0) - aws-sdk-core (3.271.0) + aws-partitions (1.1301.0) + aws-sdk-core (3.264.0) aws-eventstream (~> 1, >= 1.4.1) aws-partitions (~> 1, >= 1.992.0) aws-sigv4 (~> 1.9) @@ -18,11 +18,11 @@ GEM jmespath (~> 1, >= 1.6.1) logger rexml (~> 3.4, >= 3.4.2) - aws-sdk-kms (1.145.0) - aws-sdk-core (~> 3, >= 3.270.0) + aws-sdk-kms (1.139.0) + aws-sdk-core (~> 3, >= 3.264.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.245.0) - aws-sdk-core (~> 3, >= 3.269.0) + aws-sdk-s3 (1.238.0) + aws-sdk-core (~> 3, >= 3.264.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) aws-sigv4 (1.12.1) @@ -41,11 +41,11 @@ GEM declarative (0.0.20) digest-crc (0.7.0) rake (>= 12.0.0, < 14.0.0) - domain_name (0.7.20261117) + domain_name (0.7.20261031) dotenv (2.8.1) emoji_regex (3.2.3) erb (6.0.7) - excon (1.12.0) + excon (1.10.0) faraday (2.15.1) faraday-net_http (>= 2.0, < 3.6) json @@ -62,7 +62,7 @@ GEM faraday-retry (2.4.0) faraday (~> 2.0) fastimage (2.4.3) - fastlane (2.242.0) + fastlane (2.241.2) CFPropertyList (>= 2.3, < 5.0.0) abbrev (~> 0.1) addressable (>= 2.9.0, < 3.0.0) @@ -107,7 +107,7 @@ GEM ostruct (>= 0.1.0) plist (>= 3.1.0, < 4.0.0) rubyzip (>= 3.4.0, < 4.0.0) - security (~> 0.4) + security (~> 0.3) simctl (~> 1.6.3) terminal-notifier (>= 3.1.0, < 4.0.0) terminal-table (~> 4) @@ -145,7 +145,7 @@ GEM base64 (~> 0.2) faraday (>= 1.0, < 3.a) google-cloud-errors (1.7.1) - google-cloud-storage (1.62.2) + google-cloud-storage (1.62.1) addressable (~> 2.8) digest-crc (~> 0.4) google-apis-core (>= 0.18, < 2) @@ -167,7 +167,7 @@ GEM http-cookie (1.1.6) domain_name (~> 0.5) io-console (0.9.5) - irb (1.19.0) + irb (1.18.0) pp (>= 0.6.0) prism (>= 1.3.0) rdoc (>= 4.0.0) @@ -183,7 +183,7 @@ GEM multipart-post (2.4.1) mutex_m (0.3.0) nanaimo (0.4.0) - naturally (2.4.0) + naturally (2.3.0) net-http (0.10.0) net-protocol (>= 0.3.0) uri (>= 0.11.1) diff --git a/fastlane/common.Fastfile b/fastlane/common.Fastfile index 1c8a35c1803c..2370440f9d03 100644 --- a/fastlane/common.Fastfile +++ b/fastlane/common.Fastfile @@ -20,6 +20,9 @@ MAJOR_MULTIPLIER = 10000000 MINOR_MULTIPLIER = 10000 PATCH_MULTIPLIER = 100 +FDROID_ABI_VERSION_CODES = { "armeabi-v7a" => 1, "arm64-v8a" => 2, "x86" => 3, "x86_64" => 4 }.freeze +FDROID_ABI_MULTIPLIER = 10 + TYPE_ALPHA = "alpha" TYPE_RC = "rc" TYPE_FINAL = "final" @@ -31,6 +34,23 @@ default_platform(:android) ENV['SUPPLY_UPLOAD_MAX_RETRIES']='10' platform :android do + # Usage: fastlane incrementVersion type:(major|minor|patch|rc|final) + # For major, minor, and patch: will increment that version number by 1 and set the smaller ones to 0 + # For rc, final: will set build number to first rc/first final or increment it by 1 + desc "Increment version code and version name" + lane :incrementVersion do |options| + versionInfo = getVersionInfo() + versionComponents = parseVersionCode(versionInfo) + newVersionComponents = incrementVersionComponents(versionComponents: versionComponents, type: options[:type]) + versionNameGenerated = generateVersionName(newVersionComponents) + versionCodeGenerated = generateVersionCode(newVersionComponents) + + promptYesNo(text: "Version code: #{versionInfo["versionCode"]} -> #{versionCodeGenerated}\n" + + "Version name: #{versionInfo["versionName"]} -> #{versionNameGenerated}" + ) + writeVersions(versionCode: versionCodeGenerated, versionName: versionNameGenerated) + end + desc "Run tests and build app" lane :releasePhase1 do sh("rm -rf ../release/ && mkdir -p ../release") @@ -45,6 +65,7 @@ platform :android do desc "Release phase 2: checks, tag, create GH release, upload to appstores" lane :releasePhase2 do + ensure_git_status_clean(show_uncommitted_changes: true) versionInfo = getVersionInfo() versionComponents = parseVersionCode(versionInfo) checkReleasable(versionComponents) @@ -60,6 +81,15 @@ platform :android do uploadToHuawei(versionCode: versionInfo["versionCode"], isPrerelease: isPrerelease) end + desc "Build ABI APKs for F-Droid in app/build/fdroid/" + lane :buildFdroid do + gradle( + task: ":app:assembleGenericRelease", + flags: "--init-script fastlane/fdroid.init.gradle", + properties: { "fdroidAbiSplit" => true } + ) + end + desc "Print version info" lane :printVersionInfo do versionInfo = getVersionInfo() @@ -70,23 +100,9 @@ platform :android do print "Minor: #{versionComponents["minor"]}\n" print "Patch: #{versionComponents["patch"]}\n" print "Build: #{versionComponents["build"]}\n" - end - - # Usage: fastlane incrementVersion type:(major|minor|patch|rc|final) - # For major, minor, and patch: will increment that version number by 1 and set the smaller ones to 0 - # For rc, final: will set build number to first rc/first final or increment it by 1 - desc "Increment version code and version name" - lane :incrementVersion do |options| - versionInfo = getVersionInfo() - versionComponents = parseVersionCode(versionInfo) - newVersionComponents = incrementVersionComponents(versionComponents: versionComponents, type: options[:type]) - versionNameGenerated = generateVersionName(newVersionComponents) - versionCodeGenerated = generateVersionCode(newVersionComponents) - - promptYesNo(text: "Version code: #{versionInfo["versionCode"]} -> #{versionCodeGenerated}\n" + - "Version name: #{versionInfo["versionName"]} -> #{versionNameGenerated}" - ) - writeVersions(versionCode: versionCodeGenerated, versionName: versionNameGenerated) + fdroidAbiVersionCodes(versionCode: versionInfo["versionCode"]).each do |abi, versionCode| + print "F-Droid #{abi} version code: #{versionCode}\n" + end end desc "Upload Alpha version to play store" @@ -141,6 +157,13 @@ platform :android do test end + desc "Generate F-Droid versionCode per ABI, must match fdroid.init.gradle" + private_lane :fdroidAbiVersionCodes do |options| + versionCode = options[:versionCode] + base = (versionCode / MAJOR_MULTIPLIER) * MAJOR_MULTIPLIER + (versionCode % MAJOR_MULTIPLIER) * FDROID_ABI_MULTIPLIER + FDROID_ABI_VERSION_CODES.transform_values { |abiCode| base + abiCode } + end + desc "Compute version name from version code" private_lane :generateVersionName do |versionComponents| suffix = "" diff --git a/fastlane/fdroid.init.gradle b/fastlane/fdroid.init.gradle new file mode 100644 index 000000000000..9b15457147a2 --- /dev/null +++ b/fastlane/fdroid.init.gradle @@ -0,0 +1,46 @@ +gradle.beforeProject { project -> + if (project.path != ':app' || !project.providers.gradleProperty('fdroidAbiSplit').isPresent()) { + return + } + if (project.extensions.extraProperties.has('nextcloudFdroidConfigured')) { + return + } + project.extensions.extraProperties.set('nextcloudFdroidConfigured', true) + + project.pluginManager.withPlugin('com.android.application') { + def abiVersionCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4] + def majorMultiplier = 10000000 + def abiMultiplier = 10 + def androidComponents = project.extensions.getByName('androidComponents') + + def buildDirectory = project.layout.buildDirectory.get() + project.layout.buildDirectory.set(buildDirectory.dir('fdroid')) + + androidComponents.finalizeDsl { android -> + ([android.defaultConfig] + android.buildTypes.toList() + android.productFlavors.toList()).each { config -> + config.ndk.abiFilters.clear() + } + android.splits.abi.enable = true + android.splits.abi.reset() + android.splits.abi.include(*abiVersionCodes.keySet().toArray(new String[0])) + android.splits.abi.universalApk = false + } + + androidComponents.beforeVariants(androidComponents.selector().all()) { variant -> + variant.enable = variant.name == 'genericRelease' + } + + androidComponents.onVariants(androidComponents.selector().withName('genericRelease')) { variant -> + variant.outputs.each { output -> + def abi = output.filters.find { it.filterType.name() == 'ABI' }?.identifier + if (!abiVersionCodes.containsKey(abi)) { + throw new GradleException("Unexpected F-Droid APK ABI: ${abi}") + } + def versionCode = output.versionCode.get() + def base = versionCode.intdiv(majorMultiplier) * majorMultiplier + + (versionCode % majorMultiplier) * abiMultiplier + output.versionCode.set(base + abiVersionCodes[abi]) + } + } + } +} diff --git a/fastlane/fdroid.init.gradle.license b/fastlane/fdroid.init.gradle.license new file mode 100644 index 000000000000..b6fc7379fab8 --- /dev/null +++ b/fastlane/fdroid.init.gradle.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors +SPDX-License-Identifier: GPL-3.0-or-later