forked from tscharke/fastlaneInActions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFastfile
146 lines (126 loc) · 4.05 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
opt_out_usage
# Global variables to simplify the individual adjustment
PROJECT_NAME = "MyAwesomeProject"
XCODE_PROJECT = "./ios/#{PROJECT_NAME}.xcodeproj"
XCODE_WORKSPACE = "./ios/#{PROJECT_NAME}.xcworkspace"
OUTPUT_DIRECTORY = "./fastlane/builds/"
BUILD_FOR_DEVELOPMENT_ONLY = false # true = Build for Development | false = Build to create a release
BUILD_ONLY = false
platform :ios do
before_all do
ensure_git_status_clean
end
private_lane :pushChangesBack do | options |
if options[:running_on_ci]
repository_uri = sh("git remote show origin | awk 'NR==2{print $3}' | sed 's/git@//g' | sed 's#https://##g'", log: false)
push_uri = "https://x-access-token:#{options[:token]}@#{repository_uri.chomp}.git"
branches = "HEAD:#{options[:git_branch_name]}"
sh("git push #{push_uri} #{branches} --tags", log: false)
else
push_to_git_remote
end
end
private_lane :certificates do | options |
match_type = options[:match_type]
if options[:ci]
create_keychain(
name: ENV["CI_KEYCHAIN_NAME"],
password: ENV["CI_KEYCHAIN_PASSWORD"],
default_keychain: true,
unlock: true,
timeout: 3600,
lock_when_sleeps: false
)
match(
type: match_type,
keychain_name: ENV["CI_KEYCHAIN_NAME"],
keychain_password: ENV["CI_KEYCHAIN_PASSWORD"],
readonly: false,
shallow_clone: true,
verbose: false,
clone_branch_directly: true,
)
else
match(
type: match_type,
readonly: false,
shallow_clone: true,
verbose: false,
clone_branch_directly: true,
)
end
end
private_lane :build do | options |
build_for_development_only = options[:build_for_development_only]
configuration_name = build_for_development_only ? "Development" : "Release"
export_options_method = build_for_development_only ? "development" : "app-store"
match_type = build_for_development_only ? "development" : "appstore"
certificates(
ci: options[:running_on_ci],
match_type: match_type,
)
cocoapods(
repo_update: true,
podfile: "./ios/Podfile"
)
gym(
scheme: PROJECT_NAME,
workspace: XCODE_WORKSPACE,
silent: true,
clean: true,
configuration: configuration_name,
output_directory: OUTPUT_DIRECTORY,
output_name: "#{PROJECT_NAME}.ipa",
export_options: {
method: export_options_method,
provisioningProfiles: {
options[:app_identifier] => ENV["sigh_#{options[:app_identifier]}_#{match_type}_profile-name"],
}
},
)
match_type
end
private_lane :ship do | options |
pilot(
ipa: "#{OUTPUT_DIRECTORY}#{PROJECT_NAME}.ipa",
skip_waiting_for_build_processing: true,
verbose: false,
uses_non_exempt_encryption: true,
notify_external_testers: false,
username: "[email protected]",
team_id: options[:apple_team_id],
apple_id: options[:apple_app_id],
itc_provider: ENV["sigh_#{options[:app_identifier]}_#{options[:match_type]}_team-id"],
)
end
lane :buildAndShip do
running_on_ci = ENV["CI"] || false
options = {
:build_for_development_only => BUILD_FOR_DEVELOPMENT_ONLY,
:running_on_ci => running_on_ci,
:git_branch_name => running_on_ci ? "#{ENV['GIT_BRANCH_NAME']}" : sh("git", "rev-parse", "--abbrev-ref", "HEAD", log: false),
:app_identifier => ENV["APP_IDENTIFIER"],
:apple_id => ENV["APPLE_ID"],
:apple_team_id => ENV["APPLE_TEAM_ID"],
:apple_app_id => ENV["APPLE_APP_ID"],
:token => ENV["GITHUB_TOKEN"],
}
increment_build_number(
xcodeproj: XCODE_PROJECT,
)
match_type = build(options)
commit_version_bump(
xcodeproj: XCODE_PROJECT,
include: ["ios/Podfile.lock"],
)
pushChangesBack(options)
unless BUILD_ONLY
ship(
apple_id: options[:apple_id],
apple_team_id: options[:apple_team_id],
apple_app_id: options[:apple_app_id],
match_type: match_type,
)
end
end
end