forked from onevcat/Kingfisher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fastfile
153 lines (123 loc) · 4.33 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
fastlane_version "1.37.0"
default_platform :ios
platform :ios do
desc "Runs all the tests"
lane :tests do
test(destination: "platform=macOS", swift_version: "5.0")
test(destination: "platform=iOS Simulator,name=iPhone 12", swift_version: "5.0")
test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "5.0")
build(destination: "platform=watchOS Simulator,name=Apple Watch Series 6 - 44mm", swift_version: "5.0")
end
lane :test_ci do
if ENV["DESTINATION"].include? "watchOS" then
build(destination: ENV["DESTINATION"], swift_version: ENV["SWIFT_VERSION"])
else
test(destination: ENV["DESTINATION"], swift_version: ENV["SWIFT_VERSION"])
end
end
lane :test do |options|
scan(
scheme: "Kingfisher",
clean: true,
xcargs: "SWIFT_VERSION=#{options[:swift_version]}",
destination: options[:destination]
)
end
lane :build do |options|
gym(
workspace: "Kingfisher.xcworkspace",
configuration: "Debug",
scheme: "Kingfisher",
xcargs: "SWIFT_VERSION=#{options[:swift_version]}",
destination: options[:destination]
)
end
desc "Lint"
lane :lint do
# carthage(command: "build", no_skip_current: true, platform: "iOS")
pod_lib_lint
spm
end
desc "Release new version"
lane :release do |options|
target_version = options[:version]
raise "The version is missed. Use `fastlane release version:{version_number}`.`" if target_version.nil?
ensure_git_branch
ensure_git_status_clean
skip_tests = options[:skip_tests]
tests unless skip_tests
lint
sync_build_number_to_git
increment_version_number(version_number: target_version)
version_bump_podspec(path: "Kingfisher.podspec", version_number: target_version)
log = extract_current_change_log(version: target_version)
release_log = update_change_log(log: log)
git_commit_all(message: "Bump version to #{target_version}")
Actions.sh("git tag -s #{target_version} -m ''")
push_to_git_remote
xcframework(version: target_version)
set_github_release(
repository_name: "onevcat/Kingfisher",
api_token: ENV['GITHUB_TOKEN'],
name: release_log[:title],
tag_name: target_version,
description: release_log[:text],
upload_assets: ["build/Kingfisher-#{target_version}.zip"]
)
pod_push
end
lane :podpush do
pod_push
end
lane :xcframework do |options|
target_version = "Kingfisher-#{options[:version]}"
supporting_root = "../build/#{target_version}/Supporting Files"
xcversion(version: "~> 12.0")
FileUtils.rm_rf '../build'
frameworks = []
["macosx",
"iphoneos",
"iphonesimulator",
"appletvos",
"appletvsimulator",
"watchos",
"watchsimulator"
].each do |sdk|
archive_path = "build/Kingfisher-#{sdk}.xcarchive"
xcodebuild(
archive: true,
archive_path: archive_path,
scheme: "Kingfisher",
sdk: sdk,
build_settings: {
"BUILD_LIBRARY_FOR_DISTRIBUTION" => "YES",
"SKIP_INSTALL" => "NO"
}
)
frameworks.push("#{archive_path}/Products/Library/Frameworks/Kingfisher.framework")
dSYM_path = "../#{archive_path}/dSYMs/Kingfisher.framework.dSYM"
FileUtils.mkdir_p("#{supporting_root}/#{sdk}/dSYMs/")
FileUtils.cp_r(dSYM_path, "#{supporting_root}/#{sdk}/dSYMs/Kingfisher.framework.dSYM")
bitcode_symbol_map_path = "../#{archive_path}/BCSymbolMaps/"
if Dir.exist?(bitcode_symbol_map_path)
FileUtils.mkdir_p("#{supporting_root}/#{sdk}/BCSymbolMaps/")
FileUtils.cp_r(bitcode_symbol_map_path, "#{supporting_root}/#{sdk}")
end
end
# `xcodebuild` action in fastlane does not support `-create-xcframework` arg yet.
# Change it back to use fastlane action later when it is prepared.
framework_args = frameworks.map { |framework_path| "-framework '#{framework_path}'"}
args = "-create-xcframework #{framework_args.join(" ")} -output 'build/#{target_version}/Kingfisher.xcframework'"
Dir.chdir("..") do
Action.sh "xcodebuild #{args}"
end
zip(
path: "build/#{target_version}",
output_path: "build/#{target_version}.zip"
)
end
after_all do |lane|
end
error do |lane, exception|
end
end