-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathFastfile
193 lines (161 loc) · 5.67 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
default_platform(:ios)
platform :ios do
before_all do
begin
xcodes(version: "16.0", select_for_current_build_only: true)
rescue => ex
UI.error("Failed when switching to Xcode version: #{ex}")
end
end
desc "Switch to Beta environment"
lane :to_beta do
Action.sh("ruby ../script/to_beta.rb")
end
desc "Run tests."
lane :tests do
sdk_tests
end
lane :sdk_tests do
swift_version = ENV["SWIFT_VERSION"] || "4.2"
run_tests(
workspace: "LineSDK.xcworkspace",
devices: ["iPhone 16"],
scheme: "LineSDK",
xcargs: "SWIFT_VERSION=#{swift_version}"
)
run_tests(
workspace: "LineSDK.xcworkspace",
devices: ["iPhone 16"],
scheme: "LineSDKObjC",
xcargs: "SWIFT_VERSION=#{swift_version}"
)
end
lane :sample_tests do
run_tests(
workspace: "LineSDK.xcworkspace",
devices: ["iPhone 16"],
scheme: "LineSDKSample"
)
end
desc "Lint to check dependency manager compatibility."
lane :lint do
lint_spm
lint_pod
end
lane :lint_pod do
swift_version = ENV["SWIFT_VERSION"] || "4.2"
Action.sh("bundle exec pod lib lint ../LineSDKSwift.podspec --swift-version=#{swift_version}")
end
lane :lint_spm do
sdk_path = `xcrun --sdk iphonesimulator --show-sdk-path`.strip
swiftc_flags = [
"-sdk", sdk_path,
"-target", "arm64-apple-ios18.0-simulator"
].map { |flag| "-Xswiftc #{flag}" }
cc_flags = [
"-isysroot", sdk_path
].map { |flag| "-Xcc #{flag}" }
sh("swift build #{swiftc_flags.join(' ')} #{cc_flags.join(' ')}")
end
desc "Release a 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
tests
lint
increment_build_number(
build_number: number_of_commits,
xcodeproj: "LineSDK/LineSDK.xcodeproj"
)
increment_version_number(
version_number: target_version,
xcodeproj: "LineSDK/LineSDK.xcodeproj"
)
bump_constant_version(version: target_version)
bump_reference_top_version(version: target_version)
version_bump_podspec(path: "LineSDKSwift.podspec", version_number: target_version)
release_content = read_changelog(excluded_markdown_elements: [])
change_log(version: target_version)
git_commit_all(message: "Bump version to #{target_version}")
Actions.sh("git tag -u #{ENV["GPG_KEY_ID"]} #{target_version} -m ''")
binary_frameworks = xcframework(version: target_version)
push_to_git_remote
set_github_release(
repository_name: "line/line-sdk-ios-swift",
api_token: ENV["GITHUB_TOKEN"],
name: target_version,
tag_name: target_version,
upload_assets: binary_frameworks,
description: release_content
)
pod_push
end
desc "Generate documentation"
lane :doc do
copyright = "jazzy --copyright '© " + Time.new.year.to_s + " [LY Corporation.](https://line.me) All rights reserved.'"
Actions.sh(copyright)
end
desc "Generate documentation for internal usage"
lane :doc_internal do
jazzy(config: ".jazzy-internal.yaml")
end
lane :change_log do |options|
target_version = options[:version]
raise "The version is missed. You need to specify a version parameter." if target_version.nil?
stamp_changelog(section_identifier: target_version, git_tag: target_version, stamp_datetime_format: "%F")
end
lane :bump_constant_version do |options|
target_version = options[:version]
replacing = "public static let SDKVersion = \"#{target_version}\""
regex = "public static let SDKVersion = .*"
constant_file = "../LineSDK/LineSDK/Utils/Constant.swift"
Action.sh("sed -e 's/#{regex}/#{replacing}/g' #{constant_file} | tee #{constant_file}")
end
lane :bump_reference_top_version do |options|
target_version = options[:version]
target_version_to_minor = target_version.split(".")[0...-1].join(".")
lines = File.readlines("../REFERENCETOP.md")
lines[0] = "# LINE SDK v#{target_version_to_minor} for iOS Swift\n"
File.open("../REFERENCETOP.md", "w") { |f| f.write(lines.join) }
end
desc "Create binary frameworks with the `xcframework` format under the `build/` folder."
lane :xcframework do |options|
target_version = options[:version]
output_path = "build"
FileUtils.rm_rf "../#{output_path}"
artifact_paths = []
create_xcframework(
workspace: "LineSDK.xcworkspace",
scheme: "LineSDK",
destinations: ['iOS'],
enable_bitcode: false,
include_debug_symbols: true,
xcframework_output_directory: output_path
)
unless is_ci
Actions.sh("codesign --timestamp -v --sign 'Apple Distribution: LINE Corporation (VUTU7AKEUR)' ../#{output_path}/LineSDK.xcframework")
end
artifact_paths.push(ENV["XCFRAMEWORK_OUTPUT_PATH"])
create_xcframework(
workspace: "LineSDK.xcworkspace",
scheme: "LineSDKObjCBinary",
product_name: "LineSDKObjC",
destinations: ['iOS'],
enable_bitcode: false,
include_debug_symbols: true,
xcframework_output_directory: output_path
)
unless is_ci
Actions.sh("codesign --timestamp -v --sign 'Apple Distribution: LINE Corporation (VUTU7AKEUR)' ../#{output_path}/LineSDKObjC.xcframework")
end
artifact_paths.push(ENV["XCFRAMEWORK_OUTPUT_PATH"])
zipped_files = []
artifact_paths.each do |path|
basename = File.basename(path, ".xcframework")
zipped_files << zip(path: path, output_path: "#{output_path}/#{basename}-#{target_version}.zip")
end
zipped_files
end
end