-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathFastfile
More file actions
153 lines (125 loc) · 4.26 KB
/
Fastfile
File metadata and controls
153 lines (125 loc) · 4.26 KB
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
# frozen_string_literal: true
require 'dotenv'
default_platform(:ios)
UI.user_error!('Please run fastlane via `bundle exec`') unless FastlaneCore::Helper.bundler?
PROJECT_ROOT_FOLDER = File.dirname(File.expand_path(__dir__))
APP_FOLDER = File.join(PROJECT_ROOT_FOLDER, 'ios', 'App')
BUNDLE_IDENTIFIER = 'com.ellavandurpe.blocknotes'
APP_NAME_IOS = 'blocknotes-ios'
APP_NAME_MAC_CATALYST = 'blocknotes-mac-catalyst'
# Note that we cannot make this a subfolder of APP_FOLDER, or 'npx cap sync' will fail with:
#
# ✔ Updating iOS plugins in 1.60ms
# ✖ Updating iOS native dependencies with bundle exec pod install - failed!
# ✖ update ios - failed!
# [error] Command line invocation:
# /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project
# App.xcodeproj clean
# User defaults from command line:
# IDEPackageSupportUseBuiltinSCM = YES
# error: Could not delete `<APP_FOLDER>/build`
# because it was not created by the build system.
OUTPUT_FOLDER = File.join(PROJECT_ROOT_FOLDER, 'build')
ENV_FILE_NAME = 'blocknotes.env'
USER_ENV_FILE_PATH = File.join(Dir.home, '.a8c-apps', ENV_FILE_NAME)
# Notice this import currently needs to be after the USER_ENV_FILE_PATH definition because the const is used by the helpers.
import 'lib/helpers.rb'
before_all do
setup_ci if runner.current_platform == :ios
Dotenv.load(USER_ENV_FILE_PATH)
end
platform :ios do
desc 'Builds and uploads Blocknotes to TestFlight'
lane :build_and_upload_to_testflight do
require_env_vars!(*ASC_API_KEY_ENV_VARS)
api_key = app_store_connect_api_key
bump_build_number
build_for_app_store
upload_to_testflight(
api_key: api_key,
app_platform: 'ios',
ipa: File.join(OUTPUT_FOLDER, "#{APP_NAME_IOS}.ipa")
)
upload_to_testflight(
api_key: api_key,
app_platform: 'osx',
pkg: File.join(OUTPUT_FOLDER, "#{APP_NAME_MAC_CATALYST}.pkg")
)
end
desc 'Builds the app for iOS and Mac Catalyst App Store distribution'
lane :build_for_app_store do |options|
set_up_code_signing_app_store unless options[:skip_code_signing_setup]
shared_options = {
scheme: 'Blocknotes',
workspace: File.join(APP_FOLDER, 'App.xcworkspace'),
output_directory: OUTPUT_FOLDER
}
build_app(
output_name: APP_NAME_IOS,
export_options: {
method: 'app-store',
provisioningProfiles: {
BUNDLE_IDENTIFIER => "match AppStore #{BUNDLE_IDENTIFIER}"
}
},
**shared_options
)
build_app(
output_name: APP_NAME_MAC_CATALYST,
catalyst_platform: 'macos',
destination: 'platform=macOS,arch=x86_64,variant=Mac Catalyst',
clean: true,
export_options: {
method: 'app-store',
provisioningProfiles: {
BUNDLE_IDENTIFIER => "match AppStore #{BUNDLE_IDENTIFIER} catalyst"
}
},
**shared_options
)
end
lane :set_up_code_signing do |readonly: true|
set_up_code_signing_app_store(readonly: readonly)
end
lane :set_up_code_signing_app_store do |readonly: true|
set_up_code_signing(type: 'appstore', readonly: readonly)
end
end
def bump_build_number
latest_build_number = latest_testflight_build_number(
app_identifier: BUNDLE_IDENTIFIER,
api_key: app_store_connect_api_key
)
increment_build_number(
xcodeproj: File.join(APP_FOLDER, 'App.xcodeproj'),
build_number: latest_build_number + 1
)
end
def set_up_code_signing(type:, readonly: true)
require_env_vars!(*MATCH_ENV_VARS)
unless readonly
require_env_vars!(*ASC_API_KEY_ENV_VARS)
api_key = app_store_connect_api_key
end
shared_options = {
type: type,
app_identifier: BUNDLE_IDENTIFIER,
team_id: 'PZYM8XX95Q',
storage_mode: 's3',
s3_region: 'us-east-2',
s3_bucket: 'a8c-fastlane-match',
readonly: readonly,
api_key: api_key
}
sync_code_signing(
platform: 'ios',
**shared_options
)
sync_code_signing(
platform: 'catalyst',
# Without this, we'll get:
# error: exportArchive: Provisioning profile "match AppStore com.ellavandurpe.blocknotes catalyst" doesn't include signing certificate "3rd Party Mac Developer Installer: Automattic, Inc. (PZYM8XX95Q)".
additional_cert_types: 'mac_installer_distribution',
**shared_options
)
end