-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fastfile
executable file
·151 lines (124 loc) · 3.02 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
fastlane_require 'dotenv'
skip_docs
default_platform(:ios)
before_all do
Dotenv.overload('../.env.fastlane', '.env')
end
platform :ios do
def sources
return ENV['POD_SOURCES'].split(",")
end
desc 'Validate the project is ready for releasing'
lane :lint do
sh("cd .. && mint run realm/[email protected] swiftlint autocorrect --format || :")
pod_lib_lint(
allow_warnings: true,
sources: sources(),
private: true
)
end
desc 'Release a new version with a `patch` bump_type'
lane :patch do
release('patch')
end
desc 'Release a new version with a `minor` bump_type'
lane :minor do
release('minor')
end
desc 'Release a new version with a `major` bump_type'
lane :major do
release('major')
end
def release(type)
new_changes = sh("git log #{last_git_tag}..HEAD | wc -l").strip!
if new_changes == '0'
UI.user_error!("No changes since last release: #{last_git_tag}, please add new features and try again!")
end
podspec = ENV['PODSPEC']
podrepo = ENV['POD_REPO']
sources_paths = ENV['SOURCES_PATHS'].split(',')
git_path = [podspec] and sources_paths
version = version_bump_podspec(
path: podspec,
bump_type: type
)
git_add(
path: git_path,
shell_escape: false
)
git_commit(
path: git_path,
message: "release: v#{version}"
)
add_git_tag(
tag: "#{version}"
)
push_to_git_remote
skip_import_validation = is_ci
pod_push(
path: podspec,
repo: podrepo,
sources: sources(),
use_bundle_exec: true,
allow_warnings: true,
skip_import_validation: skip_import_validation
)
if is_ci
author = last_git_commit[:author]
repo_url = ENV['REPO_URL']
alert("*#{ENV['NAME']} v#{version} is here 🎉*", { :'Download URL' => repo_url, :Author => author })
end
end
desc "Runs all the unit and ui tests"
lane :test do
workspace = ENV['WORKSPACE']
scheme = ENV['SCHEME']
no_ci = !is_ci
cocoapods(
podfile: "./Example/Podfile",
repo_update: false
)
scan(
workspace: workspace,
scheme: scheme,
skip_slack: no_ci,
)
if no_ci
check_xcov
end
end
def check_xcov()
workspace = ENV['WORKSPACE']
scheme = ENV['SCHEME']
skip_slack = !is_ci
# Clear folder to solve error
sh("rm -rf ./xcov_report")
# Code coverage report
xcov(
workspace: workspace,
scheme: scheme,
minimum_coverage_percentage: ENV['MIN_COV'].to_f,
skip_slack: skip_slack
)
end
def alert(message, payload)
payload['Date'] = Time.new.to_s
if ENV['SLACK_URL']
slack(
message: message,
payload: payload,
default_payloads: []
)
end
teams_url = ENV['TEAMS_URL']
if teams_url
facts = payload.collect { |k, v| { :name => k, :value => v } }
teams(
title: message,
message: "",
facts: facts,
teams_url: teams_url
)
end
end
end