Skip to content

Commit

Permalink
Merge pull request #59 from tonkeeper/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
polstianka authored Jul 27, 2024
2 parents 6830e19 + 079c376 commit 872f30a
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Android Mobile CD
name: Android APK build CD

on:
# Allows you to run this workflow manually from the Actions a tab
Expand Down
26 changes: 11 additions & 15 deletions apps/wallet/instance/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@ android {
versionName = "4.7.2-x"
}

signingConfigs {
getByName("release") {
storeFile file(project.property('android.injected.signing.store.file'))
storePassword project.property('android.injected.signing.store.password')
keyAlias project.property('android.injected.signing.key.alias')
keyPassword project.property('android.injected.signing.key.password')
}
getByName("debug") {
keyAlias = "androiddebugkey"
keyPassword = "android"
storeFile = file("debug.keystore")
storePassword = "android"
}
}

buildFeatures {
buildConfig = true
}
Expand All @@ -48,6 +33,17 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
postprocessing {
isObfuscate = true
isOptimizeCode = true
isRemoveUnusedCode = true
isRemoveUnusedResources = true
}
}
debug {
isMinifyEnabled = false
signingConfig = signingConfigs.getByName("debug")
}
}

Expand Down
30 changes: 30 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.android.build.gradle.AppExtension

plugins {
id("com.android.application") version "8.5.1" apply false
id("org.jetbrains.kotlin.android") version "2.0.0" apply false
Expand All @@ -9,3 +11,31 @@ plugins {
id("androidx.baselineprofile") version "1.2.4"
id("org.jetbrains.kotlin.jvm") version "1.9.0" apply false
}

allprojects {
pluginManager.withPlugin("android") {
configure<AppExtension> {
signingConfigs {
create("release") {
if (project.hasProperty("android.injected.signing.store.file")) {
storeFile = file(project.property("android.injected.signing.store.file").toString())
storePassword = project.property("android.injected.signing.store.password").toString()
keyAlias = project.property("android.injected.signing.key.alias").toString()
keyPassword = project.property("android.injected.signing.key.password").toString()
}
}

getByName("debug") {
storeFile = file("${project.rootDir.path}/${Signing.Debug.storeFile}")
storePassword = Signing.Debug.storePassword
keyAlias = Signing.Debug.keyAlias
keyPassword = Signing.Debug.keyPassword
}
}
}
}
}

tasks.register<Delete>("clean") {
delete(getLayout().buildDirectory)
}
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/Signing.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object Signing {

object Debug {
const val storeFile = "debug.keystore"
const val storePassword = "android"
const val keyAlias = "androiddebugkey"
const val keyPassword = "android"

}
}
File renamed without changes.
1 change: 1 addition & 0 deletions fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
app_identifier('com.ton_keeper')
117 changes: 117 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane


platform :android do
desc "Fetches the latest version code from the Play Console and increments it by 1"
lane :fetch_and_increment_build_number do
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)

internal_version_codes = google_play_track_version_codes(
package_name: app_identifier,
track: "internal",
json_key_data: ENV["ANDROID_PUBLISHER_CREDENTIALS"]
)

production_version_codes = google_play_track_version_codes(
package_name: app_identifier,
json_key_data: ENV["ANDROID_PUBLISHER_CREDENTIALS"]
)

max = internal_version_codes[0] > production_version_codes[0] ? internal_version_codes[0] : production_version_codes[0]
updated_version_code = max + 1

increment_version_code(
gradle_file_path: "./apps/wallet/instance/main/build.gradle.kts",
version_code: updated_version_code
)

sh("echo VERSION_CODE=#{updated_version_code} >> $GITHUB_ENV")
end

desc "Start android baselineprofile"
lane :baseline do
gradle(
tasks: [":baselineprofile:main:generateBaselineProfile"]
)
end

desc "Build the android aab for release"
lane :build_release do
gradle(
task: ":apps:wallet:instance:main:bundle",
build_type: "Release",
properties: {
"android.injected.signing.store.file" => ENV["KEYSTORE_FILE"],
"android.injected.signing.store.password" => ENV["KEYSTORE_PASSWORD"],
"android.injected.signing.key.alias" => ENV["KEY_ALIAS"],
"android.injected.signing.key.password" => ENV["KEY_PASSWORD"],
}
)

puts "Debug"
puts Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH]
puts Actions.lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS]
puts Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]
puts Actions.lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS]

sh("echo AAB_OUTPUT_PATH=#{Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH]} >> $GITHUB_ENV")
end

desc "Build the android apk"
lane :assemble_release do
gradle(
task: ":apps:wallet:instance:main:assemble",
build_type: "Release",
properties: {
"android.injected.signing.store.file" => ENV["KEYSTORE_FILE"],
"android.injected.signing.store.password" => ENV["KEYSTORE_PASSWORD"],
"android.injected.signing.key.alias" => ENV["KEY_ALIAS"],
"android.injected.signing.key.password" => ENV["KEY_PASSWORD"],
}
)

puts "Debug"
puts Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH]
puts Actions.lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS]
puts Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]
puts Actions.lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS]

sh("echo APK_OUTPUT_PATH=#{Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]} >> $GITHUB_ENV")
end

desc "Upload to GooglePlay"
lane :upload_release do
aab_path = lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH]
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)

upload_to_play_store(
track: "internal",
json_key_data: ENV["ANDROID_PUBLISHER_CREDENTIALS"],
aab: aab_path,
package_name: app_identifier,
)
end

desc "Build and upload to GooglePlay"
lane :beta do
fetch_and_increment_build_number
build_release
upload_release

assemble_release
end
end

0 comments on commit 872f30a

Please sign in to comment.