1+ # For basics, see
2+ # https://github.com/osamaq/reactnative-fastlane-appcenter
3+
4+ # -------------Android Build & Deploy-------------#
5+ platform :android do
6+ # For android, you should setup signing for release builds.
7+ # Currently, the default debug keystore is used.
8+ desc 'Build the staging release APK.'
9+ private_lane :build_staging do
10+ gradle ( task : 'clean' , project_dir : 'android/' )
11+ sh ( "npm" , "run" , "make-apk:stagingRelease" )
12+ end
13+
14+ desc 'Build the production release APK.'
15+ private_lane :build_production do
16+ gradle ( task : 'clean' , project_dir : 'android/' )
17+ sh ( "npm" , "run" , "make-apk:productionRelease" )
18+ end
19+
20+ desc 'Upload the release APK to App Center.'
21+ private_lane :upload do |options |
22+ release_notes = options [ :notes ]
23+ appcenter_upload (
24+ api_token : ENV [ "APPCENTER_API_TOKEN" ] ,
25+ owner_name : ENV [ "APPCENTER_OWNER_NAME" ] ,
26+ app_name : ENV [ "APPCENTER_APP_NAME" ] ,
27+ apk : "./android/app/build/outputs/apk/release/app-release.apk" ,
28+ notify_testers : ENV [ "NOTIFY_TESTERS" ] ,
29+ destinations : ENV [ "DESTINATIONS" ] ,
30+ release_notes : release_notes
31+ )
32+ end
33+
34+ desc 'Build, deploy staging Android.'
35+ lane :deploy_staging do
36+ build_staging
37+ upload
38+ end
39+
40+ desc 'Build, deploy production Android.'
41+ lane :deploy_production do
42+ build_production
43+ upload
44+ end
45+
46+ desc 'Bump, badge, deploy staging Android.'
47+ lane :bump_badge_deploy_staging do
48+ bump_badge
49+ deploy_staging
50+ end
51+
52+ desc 'Bump, badge, deploy production Android.'
53+ lane :bump_badge_deploy_prod do
54+ bump_badge
55+ deploy_production
56+ end
57+ end
58+
59+ # -------------iOS Sign, Build & Deploy-------------#
60+ platform :ios do
61+ # You need to configure singing for iOS
62+ # https://github.com/osamaq/reactnative-fastlane-appcenter#signing
63+ desc 'Set up certs and profiles for iOS.'
64+ lane :certificates do
65+ register_devices (
66+ devices : {
67+ }
68+ )
69+ match (
70+ app_identifier : 'com.app.bundle' ,
71+ readonly : true ,
72+ force_for_new_devices : true ,
73+ )
74+ end
75+
76+ desc 'Build the staging release iOS application.'
77+ private_lane :build_staging do
78+ package = load_json ( json_path : "./package.json" )
79+ gym (
80+ scheme : "STAGING" ,
81+ workspace : './ios/' + package [ 'name' ] + '.xcworkspace' ,
82+ export_method : 'ad-hoc'
83+ )
84+ end
85+
86+ desc 'Build the production release iOS application.'
87+ private_lane :build_production do
88+ package = load_json ( json_path : "./package.json" )
89+ gym (
90+ scheme : "PRODUCTION" ,
91+ workspace : './ios/' + package [ 'name' ] + '.xcworkspace' ,
92+ export_method : 'ad-hoc'
93+ )
94+ end
95+
96+
97+ desc 'Upload the release IPA to App Center.'
98+ private_lane :upload do |options |
99+ release_notes = options [ :notes ]
100+ appcenter_upload (
101+ api_token : ENV [ "APPCENTER_API_TOKEN" ] ,
102+ owner_name : ENV [ "APPCENTER_OWNER_NAME" ] ,
103+ app_name : ENV [ "APPCENTER_APP_NAME" ] ,
104+ ipa : "./" + "Hello App Display Name" + ".ipa" ,
105+ notify_testers : ENV [ "NOTIFY_TESTERS" ] ,
106+ destinations : ENV [ "DESTINATIONS" ] ,
107+ release_notes : release_notes
108+ )
109+ end
110+
111+ desc 'Sign, build, deploy staging iOS.'
112+ lane :deploy_staging do
113+ certificates
114+ build_staging
115+ upload
116+ end
117+
118+ desc 'Sign, build, deploy production iOS.'
119+ lane :deploy_production do
120+ certificates
121+ build_production
122+ upload
123+ end
124+
125+ desc 'Bump, badge, sign, build, deploy staging iOS.'
126+ lane :bump_badge_deploy_staging do
127+ bump_badge
128+ deploy_staging
129+ end
130+
131+ desc 'Bump, badge, sign, build, deploy production iOS.'
132+ lane :bump_badge_deploy_prod do
133+ bump_badge
134+ deploy_production
135+ end
136+ end
137+
138+
139+ # -------------Icons & Versioning-------------#
140+ desc 'Android: Increment versionCode and set versionName to package.json version.'
141+ package = load_json ( json_path : "./package.json" )
142+ private_lane :inc_ver_and do
143+ increment_version_code (
144+ gradle_file_path : "./android/app/build.gradle" ,
145+ )
146+
147+ increment_version_name (
148+ gradle_file_path : "./android/app/build.gradle" ,
149+ version_name : package [ 'version' ]
150+ )
151+ end
152+
153+
154+ desc 'iOS: Increment build number and set the version to package.json version.'
155+ private_lane :inc_ver_ios do
156+ increment_build_number (
157+ xcodeproj : './ios/' + package [ 'name' ] + '.xcodeproj'
158+ )
159+ increment_version_number (
160+ xcodeproj : './ios/' + package [ 'name' ] + '.xcodeproj' ,
161+ version_number : package [ 'version' ]
162+ )
163+ end
164+
165+
166+ desc 'Bump build numbers, and set the display version to match the pacakage.json version.'
167+ private_lane :bump do
168+ inc_ver_ios
169+ inc_ver_and
170+ end
171+
172+
173+ # To prepare the original icon set, see:
174+ # https://developer.android.com/studio/write/image-asset-studio
175+ desc 'Android: Overwrite the current icon set with a badged version.'
176+ private_lane :make_badge_and do
177+ package = load_json ( json_path : "./package.json" )
178+ add_badge (
179+ shield : "DEV-" + package [ 'version' ] + "-orange" ,
180+ no_badge : true ,
181+ dark : true ,
182+ shield_scale : "0.55" ,
183+ shield_gravity : "Center" ,
184+ shield_geometry : "+0+30%" ,
185+ glob : "/android/app/src/main/res/mipmap-*/ic_launcher*.png" ,
186+ )
187+ end
188+
189+ # To prepare the original icon set, you can use:
190+ # https://appicon.co/
191+ desc 'iOS: Overwrite the current icon set with a badged version.'
192+ private_lane :make_badge_ios do
193+ package = load_json ( json_path : "./package.json" )
194+ add_badge (
195+ shield : "DEV-" + package [ 'version' ] + "-orange" ,
196+ no_badge : true ,
197+ dark : true ,
198+ shield_scale : "0.85" ,
199+ shield_gravity : "South" ,
200+ shield_geometry : "+0+5%" ,
201+ glob : "/ios/" + package [ 'name' ] + "/Images.xcassets/AppIcon.appiconset/*.png" ,
202+ )
203+ end
204+
205+ desc 'Make new versioned icon badges.'
206+ lane :make_badge do
207+ make_badge_ios
208+ make_badge_and
209+ end
210+
211+ desc 'Bump and badge iOS and Android.'
212+ lane :bump_badge do
213+ bump
214+ make_badge
215+ end
0 commit comments