Skip to content

Commit

Permalink
chore(added fastlane fastfile and appfile)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Palmqvist <[email protected]>
  • Loading branch information
coolusername244 and PalmN72 committed Oct 19, 2023
1 parent 3a436dd commit 940bb7b
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/skolplattformen-app-new/android/fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Filename: android/fastlane/Appfile

json_key_file("key.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("com.projectname.app") # EDIT: The bundle identifier of your app
112 changes: 112 additions & 0 deletions apps/skolplattformen-app-new/android/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Filename: android/fastlane/Fastfile

default_platform(:android)

platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end

desc "Submit a new Beta Build to Play Store"
lane :beta do |options|

if ENV['ENVFILE'].nil?
puts "ENVFILE is not set. Please set ENVFILE to the path of your .env file. If unsure, look at .github/**/*android*yml"
exit(1)
end

store_password = ENV['SIGNING_STORE_PASSWORD'] || prompt(text: "Signing Store Password: ", secure_text: true)
key_password = ENV['ALIAS_KEY_PASSWORD'] || prompt(text: "Alias Key Password: ", secure_text: true)

# Fetch version_code from play store and bump it. Annoyingly, we always need
# to increment it, even if our version name changes.
internalVersionCode = google_play_track_version_codes(track: 'internal').max
ENV['VERSION_CODE'] = (internalVersionCode + 1).to_s

versionNameOverride = nil
# versionNameOverride = "1.9.0"
if versionNameOverride.nil?
releaseNameSemVerArr = google_play_track_release_names(track: 'internal').max.split('.')
releaseNameSemVerArr[2] = (releaseNameSemVerArr.last.to_i + 1).to_s
ENV['VERSION_NAME'] = releaseNameSemVerArr.join('.')
ENV['SUPPLY_VERSION_NAME'] = ENV['VERSION_NAME']
versionFile = File.join(Dir.pwd, '..', 'version', 'version.properties').to_s
commandargs = "-n \"VERSION=#{ENV['VERSION_NAME']}\" > #{versionFile}".to_s
puts "echo #{commandargs}"
system("echo", commandargs)
else
ENV['VERSION_NAME'] = versionNameOverride
end
puts "Compiling #{ENV['VERSION_NAME']} (#{ENV['VERSION_CODE']}) "


# Dir.pwd when running through Fastlane is app/android/fastlane
releaseFilePath = File.join(Dir.pwd, '..', 'app', "my-upload-key.keystore")
mappingFilePath = File.join(
Dir.pwd,
"..",
"app",
"build",
"outputs",
"mapping",
"release",
"mapping.txt"
)


gradle(task: 'clean')
gradle(
task: 'bundle',
build_type: 'Release',
print_command: false,
properties: {
"android.injected.signing.store.file" => releaseFilePath,
"android.injected.signing.store.password" => store_password,
"android.injected.signing.key.alias" => "my-key-alias",
"android.injected.signing.key.password" => key_password,
"android.injected.version.code" => ENV['VERSION_CODE'],
"android.injected.version.name" => ENV['VERSION_NAME'],
}
)

symbolsFilePath = File.join(
Dir.pwd,
"..",
"native_debug_symbols.zip"
)
symbolsFolderPath = File.join(
Dir.pwd,
"..",
"app",
"build",
"intermediates",
"merged_native_libs",
"release",
"out",
"lib"
)
system("cd #{symbolsFolderPath} && zip -r #{symbolsFilePath} .")
upload_to_play_store(
track: 'internal',
release_status: 'draft',
version_code: ENV['VERSION_CODE'],
version_name: ENV['VERSION_NAME'],
version_codes_to_retain: [],
mapping_paths: [mappingFilePath, symbolsFilePath]
)

system('git config user.email "[email protected]"')
system('git config user.name "Github Actions Android Pipeline"')

add_git_tag(
grouping: "builds",
includes_lane: true,
prefix: "v#{ENV['VERSION_NAME']}-",
build_number: ENV['VERSION_CODE'],
)
push_to_git_remote(
tags: true
)
end
end

0 comments on commit 940bb7b

Please sign in to comment.