generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Fastfile
159 lines (135 loc) · 4.93 KB
/
Fastfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# 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
default_platform(:android)
platform :android do
desc "Runs tests"
lane :check do
gradle(task: "check")
end
desc "Apply build version information"
fastlane_require "time"
lane :setBuildVersionInfo do |options|
latestRelease = firebase_app_distribution_get_latest_release(
app: "1:867301491091:android:50b626dba42a361651e866",
service_credentials_file:options[:serviceCredentialsFile]
)
currentVersionName = latestRelease[:displayVersion]
# Gather current version information
versionParts = currentVersionName.split(".")
currentMajor = versionParts[0]
currentMinor = versionParts[1]
currentRevision = versionParts[2]
# Current date used to derive next version name.
currentDate = Time.new
major = currentDate.year.to_s
minor = currentDate.strftime "%m"
# Determine the next revision number to apply.
revision = 0
if currentMajor == major and currentMinor == minor
revision = currentRevision.to_i + 1
end
# Cache next version information
nextVersionName = major.to_s + "." + minor.to_s + "." + revision.to_s
nextVersionCode = latestRelease[:buildVersion].to_i + 1
# Read in app build config file.
buildConfigPath = "../app/build.gradle.kts"
buildConfigFile = File.open(buildConfigPath)
buildConfigText = buildConfigFile.read
buildConfigFile.close
# Replace version information.
puts "Setting version code to #{nextVersionCode}."
buildConfigText.gsub!("versionCode = 1", "versionCode = #{nextVersionCode}")
puts "Setting version name to #{nextVersionName}."
buildConfigText.gsub!("versionName = \"1.0\"", "versionName = \"#{nextVersionName}\"")
# Save changes
File.open(buildConfigPath, "w") { |buildConfigFile| buildConfigFile << buildConfigText }
end
desc "Assemble debug variants"
lane :buildDebug do
gradle(
task: "assemble",
build_type: "Debug",
print_command: false,
)
end
desc "Assemble and sign release APK"
lane :buildRelease do |options|
gradle(
task: "assemble",
build_type: "Release",
properties: {
"android.injected.signing.store.file" => options[:storeFile],
"android.injected.signing.store.password" => options[:storePassword],
"android.injected.signing.key.alias" => options[:keyAlias],
"android.injected.signing.key.password" => options[:keyPassword]
},
print_command: false,
)
end
desc "Bundle and sign release AAB"
lane :bundleRelease do |options|
gradle(
task: "bundle",
build_type: "Release",
properties: {
"android.injected.signing.store.file" => options[:storeFile],
"android.injected.signing.store.password" => options[:storePassword],
"android.injected.signing.key.alias" => options[:keyAlias],
"android.injected.signing.key.password" => options[:keyPassword]
},
print_command: false,
)
end
desc "Publish release to Firebase"
lane :distributeReleaseToFirebase do |options|
release_notes = changelog_from_git_commits(
commits_count: 1,
pretty: "- %s"
)
puts "Release notes #{release_notes}"
firebase_app_distribution(
app: "1:867301491091:android:50b626dba42a361651e866",
android_artifact_type: "APK",
android_artifact_path: "app/build/outputs/apk/release/com.bitwarden.authenticator-release.apk",
service_credentials_file: options[:serviceCredentialsFile],
groups: "internal-prod-group",
release_notes: release_notes,
)
end
desc "Publish release AAB to Firebase"
lane :distributeReleaseBundleToFirebase do |options|
release_notes = changelog_from_git_commits(
commits_count: 1,
pretty: "- %s"
)
puts "Release notes #{release_notes}"
firebase_app_distribution(
app: "1:867301491091:android:50b626dba42a361651e866",
android_artifact_type: "AAB",
android_artifact_path: "app/build/outputs/bundle/release/com.bitwarden.authenticator-release.aab",
service_credentials_file: options[:serviceCredentialsFile],
groups: "internal-prod-group",
release_notes: release_notes,
)
end
desc "Publish release to Google Play Store"
lane :publishReleaseToGooglePlayStore do |options|
upload_to_play_store(
json_key: options[:serviceCredentialsFile],
track: "internal",
aab: "app/build/outputs/bundle/release/com.bitwarden.authenticator-release.aab",
mapping: "app/build/outputs/mapping/release/mapping.txt",
)
end
end