-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastfile
More file actions
126 lines (105 loc) · 4.31 KB
/
Fastfile
File metadata and controls
126 lines (105 loc) · 4.31 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
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
default_platform(:ios)
require 'shellwords'
require 'fileutils'
# Проектные константы
UITESTS_SCHEME_FOR_SCREENSHOTS = "SwiftUI-DaysUITests"
SECRETS_REPO = "git@github.com:easydev991/ios-fastlane-secrets.git"
# Кеш-директория: хранение в постоянном месте, чтобы __FILE__ и autoload
# в fastlane_common.rb работали корректно.
SHARED_CACHE_DIR = File.expand_path("~/.cache/ios-fastlane-secrets")
def load_common_module
cache = SHARED_CACHE_DIR
FileUtils.mkdir_p(cache)
if File.directory?(File.join(cache, ".git"))
begin
sh("git -C #{Shellwords.escape(cache)} pull --ff-only")
rescue
UI.important("git pull failed, re-cloning ios-fastlane-secrets...")
FileUtils.rm_rf(cache)
sh("git clone --depth 1 #{SECRETS_REPO} #{Shellwords.escape(cache)}")
end
else
FileUtils.rm_rf(cache) if File.exist?(cache)
sh("git clone --depth 1 #{SECRETS_REPO} #{Shellwords.escape(cache)}")
end
common_path = File.join(cache, "fastlane_common.rb")
UI.user_error!("fastlane_common.rb не найден в ios-fastlane-secrets") unless File.exist?(common_path)
require common_path
end
load_common_module
platform :ios do
desc "Сгенерировать новые локализованные скриншоты"
lane :screenshots do
# Путь к файлу SwiftUI_DaysApp.swift
app_file_path = "../SwiftUI-Days/SwiftUI_DaysApp.swift"
# Проверяем, что файл существует
UI.user_error!("Файл #{app_file_path} не найден") unless File.exist?(app_file_path)
# Читаем содержимое файла
file_content = File.read(app_file_path)
# Проверяем, содержит ли файл строку "RootScreen()"
unless file_content.include?("RootScreen()")
UI.user_error!("Файл не содержит строку 'RootScreen()'")
end
# Создаем резервную копию
backup_path = "#{app_file_path}.backup"
File.write(backup_path, file_content)
UI.message("Создана резервная копия: #{backup_path}")
begin
# Заменяем "RootScreen()" на "RootScreen().tint(.accent)"
modified_content = file_content.gsub("RootScreen()", "RootScreen().tint(.accent)")
# Записываем измененный файл
File.write(app_file_path, modified_content)
UI.message("Обновили .tint для RootScreen на черный")
# Выполняем захват скриншотов
capture_screenshots(scheme: UITESTS_SCHEME_FOR_SCREENSHOTS)
ensure
# Восстанавливаем оригинальный файл из резервной копии
File.write(app_file_path, file_content)
File.delete(backup_path)
UI.message("Восстановлен оригинальный файл")
end
end
desc "Загрузить существующие скриншоты в App Store Connect"
lane :upload_screenshots do
upload_to_app_store(
skip_metadata: true,
skip_screenshots: false,
force: true,
submit_for_review: false,
reject_if_possible: false,
overwrite_screenshots: true,
run_precheck_before_submit: false,
skip_binary_upload: true,
api_key: asc_key
)
end
desc "Получить следующий номер сборки из TestFlight"
lane :get_next_build_number do
compute_next_build_number(
app_identifier: "com.oleg991.SwiftUI-Days",
xcodeproj: "SwiftUI-Days.xcodeproj"
)
end
desc "Собрать и отправить сборку в TestFlight"
lane :build_and_upload do
build_and_upload_app(
app_identifier: "com.oleg991.SwiftUI-Days",
scheme: "SwiftUI-Days",
xcodeproj: "SwiftUI-Days.xcodeproj",
xcodeproj_for_version: "SwiftUI-Days.xcodeproj",
gsp_path: File.expand_path("../SwiftUI-Days/GoogleService-Info.plist", __dir__),
output_name: "SwiftUI-Days"
)
end
end