diff --git a/.github/workflows/build-authenticator.yml b/.github/workflows/build-authenticator.yml index fdc8861846..ab549df37d 100644 --- a/.github/workflows/build-authenticator.yml +++ b/.github/workflows/build-authenticator.yml @@ -219,12 +219,12 @@ jobs: run: | DEFAULT_VERSION_CODE=$GITHUB_RUN_NUMBER VERSION_CODE="${{ inputs.version-code || '$DEFAULT_VERSION_CODE' }}" - bundle exec fastlane setAuthenticatorBuildVersionInfo \ + bundle exec fastlane setBuildVersionInfo \ versionCode:$VERSION_CODE \ versionName:${{ inputs.version-name || '' }} - regex='versionName = "([^"]+)"' - if [[ "$(cat authenticator/build.gradle.kts)" =~ $regex ]]; then + regex='appVersionName = "([^"]+)"' + if [[ "$(cat gradle/libs.versions.toml)" =~ $regex ]]; then VERSION_NAME="${BASH_REMATCH[1]}" fi echo "Version Name: ${VERSION_NAME}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e1a5d0829..4e390974bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -525,8 +525,8 @@ jobs: versionCode:$VERSION_CODE \ versionName:${{ inputs.version-name || '' }} - regex='versionName = "([^"]+)"' - if [[ "$(cat app/build.gradle.kts)" =~ $regex ]]; then + regex='appVersionName = "([^"]+)"' + if [[ "$(cat gradle/libs.versions.toml)" =~ $regex ]]; then VERSION_NAME="${BASH_REMATCH[1]}" fi echo "Version Name: ${VERSION_NAME}" >> $GITHUB_STEP_SUMMARY diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4c148ce9ee..8a6911b8fb 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -55,8 +55,8 @@ android { applicationId = "com.x8bit.bitwarden" minSdk = libs.versions.minSdk.get().toInt() targetSdk = libs.versions.targetSdk.get().toInt() - versionCode = 1 - versionName = "2025.7.0" + versionCode = libs.versions.appVersionCode.get().toInt() + versionName = libs.versions.appVersionName.get() setProperty("archivesBaseName", "com.x8bit.bitwarden") diff --git a/authenticator/build.gradle.kts b/authenticator/build.gradle.kts index 5e9414714f..3d32a00ea2 100644 --- a/authenticator/build.gradle.kts +++ b/authenticator/build.gradle.kts @@ -30,8 +30,8 @@ android { applicationId = "com.bitwarden.authenticator" minSdk = libs.versions.minSdkBwa.get().toInt() targetSdk = libs.versions.targetSdk.get().toInt() - versionCode = 1 - versionName = "2025.7.0" + versionCode = libs.versions.appVersionCode.get().toInt() + versionName = libs.versions.appVersionName.get() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 803c0be24e..01a21d9e37 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -126,14 +126,14 @@ platform :android do fastlane_require "time" lane :setBuildVersionInfo do |options| - # Read-in app build config file. - buildConfigPath = "../app/build.gradle.kts" - buildConfigFile = File.open(buildConfigPath) - buildConfigText = buildConfigFile.read - buildConfigFile.close + # Read-in app toml file. + tomlLibraryPath = "../gradle/libs.versions.toml" + tomlLibraryFile = File.open(tomlLibraryPath) + tomlLibraryText = tomlLibraryFile.read + tomlLibraryFile.close - currentVersionCode = buildConfigText.match(/versionCode = (\d+)/).captures[0] - currentVersionName = buildConfigText.match(/versionName = "(.+)"/).captures[0] + currentVersionCode = tomlLibraryText.match(/appVersionCode = "(\d+)"/).captures[0] + currentVersionName = tomlLibraryText.match(/appVersionName = "(.+)"/).captures[0] if options[:versionName].nil? or options[:versionName].to_s.empty? puts "Fetching latest tags from origin..." @@ -164,12 +164,12 @@ platform :android do # Replace version information. puts "Setting version code to #{options[:versionCode]}." - buildConfigText.gsub!("versionCode = #{currentVersionCode}", "versionCode = #{options[:versionCode]}") + tomlLibraryText.gsub!("appVersionCode = \"#{currentVersionCode}\"", "appVersionCode = \"#{options[:versionCode]}\"") puts "Setting version name to #{nextVersionName}." - buildConfigText.gsub!("versionName = \"#{currentVersionName}\"", "versionName = \"#{nextVersionName}\"") + tomlLibraryText.gsub!("appVersionName = \"#{currentVersionName}\"", "appVersionName = \"#{nextVersionName}\"") # Save changes - File.open(buildConfigPath, "w") { |buildConfigFile| buildConfigFile << buildConfigText } + File.open(tomlLibraryPath, "w") { |tomlLibraryFile| tomlLibraryFile << tomlLibraryText } end desc "Generate artifacts for the given [build] signed with the provided [keystore] and credentials." @@ -302,57 +302,6 @@ platform :android do UI.message("version_number: #{latest_version_number}") end - # Authenticator - desc "Apply build version information" - fastlane_require "time" - lane :setAuthenticatorBuildVersionInfo do |options| - - # Read-in app build config file. - buildConfigPath = "../authenticator/build.gradle.kts" - buildConfigFile = File.open(buildConfigPath) - buildConfigText = buildConfigFile.read - buildConfigFile.close - - currentVersionCode = buildConfigText.match(/versionCode = (\d+)/).captures[0] - currentVersionName = buildConfigText.match(/versionName = "(.+)"/).captures[0] - - if options[:versionName].nil? or options[:versionName].to_s.empty? - puts "Fetching latest tags from origin..." - `git fetch --prune --no-recurse-submodules --filter=tree:0 --depth=1 --tags origin` - puts "Getting latest version name from previous git tag..." - latestTag = `git describe --tags $(git rev-list --tags --max-count=1)`.chomp() - puts "Using tag #{latestTag} to calculate version name..." - latestTag.slice!(0) - puts "Current version name resolved to #{latestTag}." - - versionParts = latestTag.split(".") - currentMajor = versionParts[0] - currentMinor = versionParts[1] - currentRevision = versionParts[2] - - currentDate = Time.new - major = currentDate.year.to_s - minor = currentDate.strftime "%-m" - - revision = 0 - if currentMajor == major and currentMinor == minor - revision = currentRevision.to_i + 1 - end - nextVersionName = "#{major}.#{minor}.#{revision}" - else - nextVersionName = options[:versionName].to_s - end - - # Replace version information. - puts "Setting version code to #{options[:versionCode]}." - buildConfigText.gsub!("versionCode = #{currentVersionCode}", "versionCode = #{options[:versionCode]}") - puts "Setting version name to #{nextVersionName}." - buildConfigText.gsub!("versionName = \"#{currentVersionName}\"", "versionName = \"#{nextVersionName}\"") - - # Save changes - File.open(buildConfigPath, "w") { |buildConfigFile| buildConfigFile << buildConfigText } - end - desc "Assemble debug variants" lane :buildAuthenticatorDebug do gradle( diff --git a/gradle.properties b/gradle.properties index 0f295fdcf2..ba4681f190 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,4 @@ android.experimental.enableTestFixturesKotlinSupport=true -android.nonTransitiveRClass=true android.useAndroidX=true kotlin.code.style=official diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6b5c605ba3..7493a3b4b8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,10 @@ # Please keep each version / library / plugin alphabetized within its own section and subsubsection. [versions] +# App version +appVersionCode = "1" +appVersionName = "2025.7.0" + # SDK Versions compileSdk = "36" targetSdk = "36"