fastlane-plugin-yalantis_ci 0.2.6 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_add_to_remote.rb +1 -1
- data/lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb +1 -1
- data/lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb +1 -1
- data/lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb +58 -0
- data/lib/fastlane/plugin/yalantis_ci/actions/build_number_sync.rb +138 -0
- data/lib/fastlane/plugin/yalantis_ci/helper/git_helper.rb +4 -5
- data/lib/fastlane/plugin/yalantis_ci/version.rb +1 -1
- metadata +10 -9
- data/lib/fastlane/plugin/yalantis_ci/helper/ci_helper.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a76195cf47d39933d3288a1d51eae9597a5e2a98f1a6ee28284a62a41da3dda
|
4
|
+
data.tar.gz: 361e997bfbf1332476db89be5751ae8f38431f86e73c2f2a442aeb02cec505da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe50ecb431e1a75235381a36d77cac736a31d90bb9f7e65e6335521f911d5b860d012906cc157815d8c4f77bee040bc30e516a67e73e157d6819265dca918576
|
7
|
+
data.tar.gz: 56fbd9cbdbc74bc81a424b067246a2bc98fa103f1d90751b53a7da053062d527d3ce5d3d127c54c0fe0ba2ff0fd594b2b1003774873c6f5cd970d46c172cd244
|
@@ -17,7 +17,7 @@ module Fastlane
|
|
17
17
|
UI.user_error!(":key_content or :key_filepath is required")
|
18
18
|
end
|
19
19
|
|
20
|
-
Helper::GitHelper.clone_repo_in_tmp(git_repo_url, git_repo_branch, true) do |dir|
|
20
|
+
Helper::GitHelper.clone_repo_in_tmp(repo_url: git_repo_url, branch: git_repo_branch, create_branch: true) do |dir|
|
21
21
|
target_filename = "#{key_id}.p8"
|
22
22
|
target_filepath = File.join(dir, target_filename)
|
23
23
|
|
data/lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb
CHANGED
@@ -10,7 +10,7 @@ module Fastlane
|
|
10
10
|
git_repo_branch = options[:git_repo_branch]
|
11
11
|
key_id = options[:key_id]
|
12
12
|
|
13
|
-
Helper::GitHelper.clone_repo_in_tmp(git_repo_url, git_repo_branch
|
13
|
+
Helper::GitHelper.clone_repo_in_tmp(repo_url: git_repo_url, branch: git_repo_branch) do |dir|
|
14
14
|
target_filename = "#{key_id}.p8"
|
15
15
|
target_filepath = File.join(dir, target_filename)
|
16
16
|
|
@@ -12,7 +12,7 @@ module Fastlane
|
|
12
12
|
issuer_id = options[:issuer_id]
|
13
13
|
in_house = options[:in_house]
|
14
14
|
|
15
|
-
Helper::GitHelper.clone_repo_in_tmp(git_repo_url, git_repo_branch) do |dir|
|
15
|
+
Helper::GitHelper.clone_repo_in_tmp(repo_url: git_repo_url, branch: git_repo_branch) do |dir|
|
16
16
|
target_filename = "#{key_id}.p8"
|
17
17
|
target_filepath = Pathname.new File.join(dir, target_filename)
|
18
18
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Actions
|
5
|
+
class BuildNumberSetToXcconfigAction < Action
|
6
|
+
def self.run(options)
|
7
|
+
build_number = options[:build_number]
|
8
|
+
path = options[:xcconfig_path]
|
9
|
+
|
10
|
+
File.open(path, 'r+') do |file|
|
11
|
+
contents = file.read
|
12
|
+
unless contents.nil?
|
13
|
+
contents.gsub!(/(?<=\bCURRENT_PROJECT_VERSION\s=\s)([\d]+)/, build_number.to_s)
|
14
|
+
|
15
|
+
file.truncate(0)
|
16
|
+
file.write(contents)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.description
|
22
|
+
"Stores a specified Build Number in the passed xcconfig"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.available_options
|
26
|
+
[
|
27
|
+
FastlaneCore::ConfigItem.new(
|
28
|
+
key: :build_number,
|
29
|
+
env_name: "BUILD_NUMBER",
|
30
|
+
description: "Build number to be set to the .xcconfig",
|
31
|
+
type: Integer
|
32
|
+
),
|
33
|
+
FastlaneCore::ConfigItem.new(
|
34
|
+
key: :xcconfig_path,
|
35
|
+
env_name: "BUILD_NUMBER_XCCONFIG_PATH",
|
36
|
+
description: "Path to the xcconfig file with Build Number",
|
37
|
+
type: String,
|
38
|
+
verify_block: proc do |value|
|
39
|
+
UI.user_error!("Couldn't find .xcconfig file at path '#{value}'") unless File.exist?(File.expand_path(value))
|
40
|
+
end
|
41
|
+
)
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.output
|
46
|
+
[]
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.authors
|
50
|
+
["Dima Vorona", "Yalantis"]
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.is_supported?(platform)
|
54
|
+
[:ios, :mac].include?(platform)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require_relative '../helper/git_helper'
|
3
|
+
require 'json'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
module Fastlane
|
7
|
+
module Actions
|
8
|
+
class BuildNumberSyncAction < Action
|
9
|
+
def self.run(options)
|
10
|
+
build_number = read_from_remote(
|
11
|
+
git_repo_url: options[:git_repo_url],
|
12
|
+
git_repo_branch: options[:git_repo_branch],
|
13
|
+
payload_filepath: options[:git_filepath],
|
14
|
+
mutation_callback: options[:mutation_callback]
|
15
|
+
)
|
16
|
+
unless build_number.nil?
|
17
|
+
ENV['BUILD_NUMBER'] = build_number.to_s
|
18
|
+
Actions.lane_context[SharedValues::BUILD_NUMBER] = build_number
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.read_from_remote(git_repo_url:, git_repo_branch:, payload_filepath:, mutation_callback: nil)
|
23
|
+
build_number = nil
|
24
|
+
attempts = 0
|
25
|
+
total_attempts = 5
|
26
|
+
|
27
|
+
pwd = ENV['PWD']
|
28
|
+
pwd_managed_by_git = system("git -C \"#{pwd}\" rev-parse") == true
|
29
|
+
pwd_git_username = pwd_managed_by_git ? `git config --local --get user.name`.strip : nil
|
30
|
+
pwd_git_email = pwd_managed_by_git ? `git config --local --get user.email`.strip : nil
|
31
|
+
|
32
|
+
while build_number.nil? && attempts < total_attempts
|
33
|
+
Helper::GitHelper.clone_repo_in_tmp(repo_url: git_repo_url, branch: git_repo_branch, create_branch: true) do |dir|
|
34
|
+
attempts += 1
|
35
|
+
|
36
|
+
UI.message("Attempt #{attempts} out of #{total_attempts} to get build number")
|
37
|
+
|
38
|
+
filepath = File.join(dir, payload_filepath)
|
39
|
+
if File.exist?(filepath)
|
40
|
+
begin
|
41
|
+
remote_build_number = JSON.parse(File.read(filepath))['build_number']
|
42
|
+
rescue
|
43
|
+
remote_build_number = 1
|
44
|
+
end
|
45
|
+
else
|
46
|
+
remote_build_number = 1
|
47
|
+
end
|
48
|
+
|
49
|
+
build_number = mutation_callback != nil ? mutation_callback.call(remote_build_number) : remote_build_number
|
50
|
+
|
51
|
+
if build_number.kind_of?(Integer) && build_number > remote_build_number
|
52
|
+
payload_contents = JSON.pretty_generate({ 'build_number' => build_number, 'generation' => SecureRandom.uuid })
|
53
|
+
File.open(filepath, 'w+') { |file| file.write(payload_contents) }
|
54
|
+
|
55
|
+
add_user_config_if_needed(pwd_git_username: pwd_git_username, pwd_git_email: pwd_git_email)
|
56
|
+
|
57
|
+
Actions.sh("git add #{filepath} && git commit -m '[Build Number] Update Build Number to: #{build_number}'")
|
58
|
+
Actions.sh("git push #{git_repo_url} #{git_repo_branch}", error_callback: ->(result) { build_number = nil })
|
59
|
+
elsif build_number.kind_of?(Integer) && build_number < remote_build_number
|
60
|
+
UI.user_error!("It is unexpected to return build number less than a proposed one: #{build_number} vs #{remote_build_number}")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
build_number
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.add_user_config_if_needed(pwd_git_username:, pwd_git_email:)
|
69
|
+
variables = {'email' => pwd_git_email, 'name' => pwd_git_username }
|
70
|
+
variables.each do |key, value|
|
71
|
+
if `git config --local --get user.#{key}`.strip.empty?
|
72
|
+
`git config --local user.#{key} #{value}` unless value.empty?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
#####################################################
|
78
|
+
# @!group Documentation
|
79
|
+
#####################################################
|
80
|
+
|
81
|
+
def self.description
|
82
|
+
"Read and increment version stored in a specified repo"
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.available_options
|
86
|
+
[
|
87
|
+
FastlaneCore::ConfigItem.new(
|
88
|
+
key: :git_repo_url,
|
89
|
+
env_name: "BUILD_NUMBER_GIT_REPO_URL",
|
90
|
+
description: "Git repo URL where Build Number is being stored",
|
91
|
+
type: String
|
92
|
+
),
|
93
|
+
FastlaneCore::ConfigItem.new(
|
94
|
+
key: :git_repo_branch,
|
95
|
+
env_name: "BUILD_NUMBER_GIT_REPO_BRANCH",
|
96
|
+
description: "Git repo branch where Build Number is being stored",
|
97
|
+
type: String,
|
98
|
+
default_value: 'main'
|
99
|
+
),
|
100
|
+
FastlaneCore::ConfigItem.new(
|
101
|
+
key: :increment,
|
102
|
+
description: 'Whether value from remote should be incremented or not',
|
103
|
+
default_value: true,
|
104
|
+
verify_block: proc do |value|
|
105
|
+
UI.user_error!("Only `true` and `false` are allowed") unless value == true || value == false
|
106
|
+
end
|
107
|
+
),
|
108
|
+
FastlaneCore::ConfigItem.new(
|
109
|
+
key: :git_filepath,
|
110
|
+
env_name: "BUILD_NUMBER_GIT_FILEPATH",
|
111
|
+
description: "Relative filepath to the file that contains build number",
|
112
|
+
type: String,
|
113
|
+
default_value: 'payload.json'
|
114
|
+
),
|
115
|
+
FastlaneCore::ConfigItem.new(
|
116
|
+
key: :mutation_callback,
|
117
|
+
description: 'A callback invoked with the build number from remote and expected build number to be returned',
|
118
|
+
optional: true,
|
119
|
+
type: Proc,
|
120
|
+
default_value: nil
|
121
|
+
)
|
122
|
+
]
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.output
|
126
|
+
['BUILD_NUMBER', 'The new build number']
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.authors
|
130
|
+
["Dima Vorona", "Yalantis"]
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.is_supported?(platform)
|
134
|
+
[:ios, :mac].include?(platform)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -5,16 +5,15 @@ module Fastlane
|
|
5
5
|
|
6
6
|
module Helper
|
7
7
|
class GitHelper
|
8
|
-
|
9
|
-
def self.clone_repo_in_tmp(repo_url, branch = 'master', create_branch_if_needed = false)
|
8
|
+
def self.clone_repo_in_tmp(repo_url:, branch: 'master', create_branch: false)
|
10
9
|
temp_directory = `mktemp -d`.tr("\n", "")
|
11
10
|
|
12
11
|
begin
|
13
12
|
Dir.chdir(temp_directory) do
|
14
13
|
Actions.sh("git clone -b #{branch} #{repo_url} #{Dir.pwd}") do |status, result, cmd|
|
15
|
-
if status.success? != true &&
|
16
|
-
Actions.sh("git clone #{repo_url} #{Dir.pwd} && git checkout -b #{branch}") do |status, result, cmd
|
17
|
-
if status.success? != true
|
14
|
+
if status.success? != true && create_branch
|
15
|
+
Actions.sh("git clone #{repo_url} #{Dir.pwd} && git checkout -b #{branch}") do |status, result, cmd|
|
16
|
+
if status.success? != true
|
18
17
|
raise StandardError.new result
|
19
18
|
end
|
20
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-yalantis_ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dima Vorona
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane-plugin-firebase_app_distribution
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '2.0'
|
153
|
-
description:
|
153
|
+
description:
|
154
154
|
email: dmytro.vorona@yalantis.net
|
155
155
|
executables: []
|
156
156
|
extensions: []
|
@@ -162,18 +162,19 @@ files:
|
|
162
162
|
- lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_add_to_remote.rb
|
163
163
|
- lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb
|
164
164
|
- lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb
|
165
|
+
- lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb
|
166
|
+
- lib/fastlane/plugin/yalantis_ci/actions/build_number_sync.rb
|
165
167
|
- lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb
|
166
168
|
- lib/fastlane/plugin/yalantis_ci/actions/ci_teardown.rb
|
167
169
|
- lib/fastlane/plugin/yalantis_ci/actions/firebase_distribution_setup.rb
|
168
170
|
- lib/fastlane/plugin/yalantis_ci/actions/install_brew_dependencies.rb
|
169
|
-
- lib/fastlane/plugin/yalantis_ci/helper/ci_helper.rb
|
170
171
|
- lib/fastlane/plugin/yalantis_ci/helper/git_helper.rb
|
171
172
|
- lib/fastlane/plugin/yalantis_ci/version.rb
|
172
|
-
homepage:
|
173
|
+
homepage:
|
173
174
|
licenses:
|
174
175
|
- MIT
|
175
176
|
metadata: {}
|
176
|
-
post_install_message:
|
177
|
+
post_install_message:
|
177
178
|
rdoc_options: []
|
178
179
|
require_paths:
|
179
180
|
- lib
|
@@ -188,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
189
|
- !ruby/object:Gem::Version
|
189
190
|
version: '0'
|
190
191
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
-
signing_key:
|
192
|
+
rubygems_version: 3.1.6
|
193
|
+
signing_key:
|
193
194
|
specification_version: 4
|
194
195
|
summary: Set of utilities and useful actions to help setup CI for Yalantis projects
|
195
196
|
test_files: []
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'fastlane_core/ui/ui'
|
2
|
-
|
3
|
-
module Fastlane
|
4
|
-
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
5
|
-
|
6
|
-
module Helper
|
7
|
-
class CiHelper
|
8
|
-
|
9
|
-
# class methods that you define here become available in your action
|
10
|
-
# as `Helper::CiHelper.your_method`
|
11
|
-
#
|
12
|
-
def self.show_message
|
13
|
-
UI.message("Hello from the yalantis_ci plugin helper!")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|