fastlane-plugin-yalantis_ci 0.2.6 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ba1e6dc0a29a4250e05364a8b7f00cd51738e062f829aa71d99496b6e2bee8b
4
- data.tar.gz: d6a6be86add42155e6b9d1cb833250b79b123159003073c0354390baed66e462
3
+ metadata.gz: 4622dd6d9a13b4d67310b8cd8421bc00abcba72ddaa43ccc0765527f3d647699
4
+ data.tar.gz: 989f4db2393f9a5cd2401522b69a04f439d6f07f75fea35b29554887dff25b31
5
5
  SHA512:
6
- metadata.gz: 67f65a3e164ed66b62569b0874ad2c14c0b6b6d955c2fc32bccd4b8295e38309acdb24279032e1e687d044929de9dd1f3dd6674b528a07c0d271e7d26b3bc33e
7
- data.tar.gz: 22f3cdbff0c34efc462b7fa895aac4fa0f435234220ce139af46a5dc06e877ffc6b57a9004b0e95718f9a204781200a0bc4e44fdcc56798e115ad6b94ca76de7
6
+ metadata.gz: 2b0155b2f1ec999d5a2de687a0d9ad705865fe1333ece391dfd09d82fb78d3a21c7cb3b333c6f70911e523e7dc67ba721768d209ae05a50acbfa611d02b2e89f
7
+ data.tar.gz: cd2d555a42cfa1333b2ace48234e598cf4c705853a7550481df2b72e9515320140f586a801b7d508f4e448cc359882ac2e2042a158733de7cff01b102f18d78d
@@ -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
 
@@ -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, false) do |dir|
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,45 @@
1
+ require 'pathname'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class BuildNumberGetFromXcconfigAction < Action
6
+ def self.run(options)
7
+ path = options[:xcconfig_path]
8
+ contents = File.read(path)
9
+
10
+ match = /(?<=\bCURRENT_PROJECT_VERSION\s=\s)(?<value>[\d]+)/.match(contents)
11
+ return match[:value] unless match.nil?
12
+ end
13
+
14
+ def self.description
15
+ "Read Build Number from the passed xcconfig"
16
+ end
17
+
18
+ def self.available_options
19
+ [
20
+ FastlaneCore::ConfigItem.new(
21
+ key: :xcconfig_path,
22
+ env_name: "BUILD_NUMBER_XCCONFIG_PATH",
23
+ description: "Path to the xcconfig file with Build Number",
24
+ type: String,
25
+ verify_block: proc do |value|
26
+ UI.user_error!("Couldn't find .xcconfig file at path '#{value}'") unless File.exist?(File.expand_path(value))
27
+ end
28
+ )
29
+ ]
30
+ end
31
+
32
+ def self.output
33
+ []
34
+ end
35
+
36
+ def self.authors
37
+ ["Dima Vorona", "Yalantis"]
38
+ end
39
+
40
+ def self.is_supported?(platform)
41
+ [:ios, :mac].include?(platform)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,56 @@
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] || Actions.lane_context[SharedValues::BUILD_NUMBER]
8
+ path = options[:xcconfig_path]
9
+
10
+ if build_number.nil?
11
+ UI.error("build_number can't be nil")
12
+ else
13
+ contents = File.readlines(path).join.gsub!(/(?<=\bCURRENT_PROJECT_VERSION\s=\s)([\d]+)/, build_number.to_s)
14
+ File.write(path, contents) unless contents.nil?
15
+ end
16
+ end
17
+
18
+ def self.description
19
+ "Stores a specified Build Number in the passed xcconfig"
20
+ end
21
+
22
+ def self.available_options
23
+ [
24
+ FastlaneCore::ConfigItem.new(
25
+ key: :build_number,
26
+ env_name: "BUILD_NUMBER",
27
+ description: "Build number to be set to the .xcconfig",
28
+ optional: true,
29
+ type: Integer
30
+ ),
31
+ FastlaneCore::ConfigItem.new(
32
+ key: :xcconfig_path,
33
+ env_name: "BUILD_NUMBER_XCCONFIG_PATH",
34
+ description: "Path to the xcconfig file with Build Number",
35
+ type: String,
36
+ verify_block: proc do |value|
37
+ UI.user_error!("Couldn't find .xcconfig file at path '#{value}'") unless File.exist?(File.expand_path(value))
38
+ end
39
+ )
40
+ ]
41
+ end
42
+
43
+ def self.output
44
+ []
45
+ end
46
+
47
+ def self.authors
48
+ ["Dima Vorona", "Yalantis"]
49
+ end
50
+
51
+ def self.is_supported?(platform)
52
+ [:ios, :mac].include?(platform)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,136 @@
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
+ Actions.lane_context[SharedValues::BUILD_NUMBER] = build_number unless build_number.nil?
17
+ return build_number
18
+ end
19
+
20
+ def self.read_from_remote(git_repo_url:, git_repo_branch:, payload_filepath:, mutation_callback: nil)
21
+ build_number = nil
22
+ attempts = 0
23
+ total_attempts = 5
24
+
25
+ pwd = ENV['PWD']
26
+ pwd_managed_by_git = system("git -C \"#{pwd}\" rev-parse") == true
27
+ pwd_git_username = pwd_managed_by_git ? `git config --local --get user.name`.strip : nil
28
+ pwd_git_email = pwd_managed_by_git ? `git config --local --get user.email`.strip : nil
29
+
30
+ while build_number.nil? && attempts < total_attempts
31
+ Helper::GitHelper.clone_repo_in_tmp(repo_url: git_repo_url, branch: git_repo_branch, create_branch: true) do |dir|
32
+ attempts += 1
33
+
34
+ UI.message("Attempt #{attempts} out of #{total_attempts} to get build number")
35
+
36
+ filepath = File.join(dir, payload_filepath)
37
+ if File.exist?(filepath)
38
+ begin
39
+ remote_build_number = JSON.parse(File.read(filepath))['build_number']
40
+ rescue
41
+ remote_build_number = 1
42
+ end
43
+ else
44
+ remote_build_number = 1
45
+ end
46
+
47
+ build_number = mutation_callback != nil ? mutation_callback.call(remote_build_number) : remote_build_number
48
+
49
+ if build_number.kind_of?(Integer) && build_number > remote_build_number
50
+ payload_contents = JSON.pretty_generate({ 'build_number' => build_number, 'generation' => SecureRandom.uuid })
51
+ File.open(filepath, 'w+') { |file| file.write(payload_contents) }
52
+
53
+ add_user_config_if_needed(pwd_git_username: pwd_git_username, pwd_git_email: pwd_git_email)
54
+
55
+ Actions.sh("git add #{filepath} && git commit -m '[Build Number] Update Build Number to: #{build_number}'")
56
+ Actions.sh("git push #{git_repo_url} #{git_repo_branch}", error_callback: ->(result) { build_number = nil })
57
+ elsif build_number.kind_of?(Integer) && build_number < remote_build_number
58
+ UI.user_error!("It is unexpected to return build number less than a proposed one: #{build_number} vs #{remote_build_number}")
59
+ end
60
+ end
61
+ end
62
+
63
+ build_number
64
+ end
65
+
66
+ def self.add_user_config_if_needed(pwd_git_username:, pwd_git_email:)
67
+ variables = {'email' => pwd_git_email, 'name' => pwd_git_username }
68
+ variables.each do |key, value|
69
+ if `git config --local --get user.#{key}`.strip.empty?
70
+ `git config --local user.#{key} #{value}` unless value.empty?
71
+ end
72
+ end
73
+ end
74
+
75
+ #####################################################
76
+ # @!group Documentation
77
+ #####################################################
78
+
79
+ def self.description
80
+ "Read and increment version stored in a specified repo"
81
+ end
82
+
83
+ def self.available_options
84
+ [
85
+ FastlaneCore::ConfigItem.new(
86
+ key: :git_repo_url,
87
+ env_name: "BUILD_NUMBER_GIT_REPO_URL",
88
+ description: "Git repo URL where Build Number is being stored",
89
+ type: String
90
+ ),
91
+ FastlaneCore::ConfigItem.new(
92
+ key: :git_repo_branch,
93
+ env_name: "BUILD_NUMBER_GIT_REPO_BRANCH",
94
+ description: "Git repo branch where Build Number is being stored",
95
+ type: String,
96
+ default_value: 'main'
97
+ ),
98
+ FastlaneCore::ConfigItem.new(
99
+ key: :increment,
100
+ description: 'Whether value from remote should be incremented or not',
101
+ default_value: true,
102
+ verify_block: proc do |value|
103
+ UI.user_error!("Only `true` and `false` are allowed") unless value == true || value == false
104
+ end
105
+ ),
106
+ FastlaneCore::ConfigItem.new(
107
+ key: :git_filepath,
108
+ env_name: "BUILD_NUMBER_GIT_FILEPATH",
109
+ description: "Relative filepath to the file that contains build number",
110
+ type: String,
111
+ default_value: 'payload.json'
112
+ ),
113
+ FastlaneCore::ConfigItem.new(
114
+ key: :mutation_callback,
115
+ description: 'A callback invoked with the build number from remote and expected build number to be returned',
116
+ optional: true,
117
+ type: Proc,
118
+ default_value: nil
119
+ )
120
+ ]
121
+ end
122
+
123
+ def self.output
124
+ ['BUILD_NUMBER', 'The new build number']
125
+ end
126
+
127
+ def self.authors
128
+ ["Dima Vorona", "Yalantis"]
129
+ end
130
+
131
+ def self.is_supported?(platform)
132
+ [:ios, :mac].include?(platform)
133
+ end
134
+ end
135
+ end
136
+ end
@@ -17,15 +17,15 @@ module Fastlane
17
17
  Actions.lane_context[SharedValues::CI_UNIQUE_PROJECT_ID] = id
18
18
  ENV['CI_UNIQUE_PROJECT_ID'] = id
19
19
 
20
- # We want to setup match repo regardless of the environment.
20
+ # We want to setup match repo regardless of the environment
21
21
  # On both local and remote machine this should be set to the same value
22
22
  self.setup_match_repo(id)
23
23
 
24
- if !Helper.ci?
24
+ unless Helper.ci?
25
25
  return
26
26
  end
27
27
 
28
- self.setup_temp_keychain(id)
28
+ self.setup_temp_keychain(params[:keychain_name] || id)
29
29
 
30
30
  # Set output directory
31
31
  if params[:output_directory]
@@ -39,9 +39,9 @@ module Fastlane
39
39
  if params[:archive_name]
40
40
  extension = "xcarchive"
41
41
  archive_name = File.basename(params[:archive_name], File.extname(params[:archive_name])) + extension
42
- archive_path = File.join(output_directory_path, params[:archive_name])
42
+ archive_path = File.join(output_directory_path, archive_name)
43
43
 
44
- UI.message("Setting archive path to: \"#{output_directory_path}\".")
44
+ UI.message("Setting archive path to: \"#{output_directory_path}\"")
45
45
  ENV['GYM_ARCHIVE_PATH'] = archive_path
46
46
  end
47
47
  end
@@ -80,9 +80,7 @@ module Fastlane
80
80
  end
81
81
 
82
82
  def self.setup_temp_keychain(id)
83
- job_id = ENV['CI_JOBENV_ID'] || ''
84
-
85
- name = "#{id}-#{job_id}-fastlane"
83
+ name = "#{id}-fastlane"
86
84
  password = "#{name}-password"
87
85
  path = File.expand_path("~/Library/Keychains/#{name}.keychain-db")
88
86
 
@@ -118,35 +116,44 @@ module Fastlane
118
116
  end
119
117
 
120
118
  def self.available_options
121
- # Define all options your action supports.
122
-
119
+ # Define all options your action supports
123
120
  # Below a few examples
124
121
  [
125
- FastlaneCore::ConfigItem.new(key: :derived_data_path,
126
- env_name: "CI_DERIVED_DATA_PATH",
127
- description: "Path to the derived data to be used",
128
- is_string: true,
129
- default_value: "./build/DerivedData"
130
- ),
131
- FastlaneCore::ConfigItem.new(key: :output_directory,
132
- env_name: "CI_OUTPUT_DIRECTORY",
133
- description: "The directory in which the ipa file should be stored in as well as .xcarchive",
134
- is_string: true,
135
- default_value: "./build"
136
- ),
137
- FastlaneCore::ConfigItem.new(key: :archive_name,
138
- env_name: "CI_ARCHIVE_NAME",
139
- description: "The name of the .xcarchive to be used. Valid only when :output_directory is passed",
140
- is_string: true,
141
- optional: true
142
- ),
143
- FastlaneCore::ConfigItem.new(key: :project,
144
- env_name: "XC_PROJECT",
145
- description: "Path to the .xcodeproj to be used or any project-related description. Used during CI_UNIQUE_PROJECT_ID generation",
146
- is_string: true,
147
- optional: false
148
- ),
149
-
122
+ FastlaneCore::ConfigItem.new(
123
+ key: :derived_data_path,
124
+ env_name: "CI_DERIVED_DATA_PATH",
125
+ description: "Path to the derived data to be used",
126
+ is_string: true,
127
+ default_value: "./build/DerivedData"
128
+ ),
129
+ FastlaneCore::ConfigItem.new(
130
+ key: :keychain_name,
131
+ env_name: "CI_KEYCHAIN_NAME",
132
+ description: "Keychain name to be used for a particular job",
133
+ optional: true,
134
+ type: String
135
+ ),
136
+ FastlaneCore::ConfigItem.new(
137
+ key: :output_directory,
138
+ env_name: "CI_OUTPUT_DIRECTORY",
139
+ description: "The directory in which the ipa file should be stored in as well as .xcarchive",
140
+ is_string: true,
141
+ default_value: "./build"
142
+ ),
143
+ FastlaneCore::ConfigItem.new(
144
+ key: :archive_name,
145
+ env_name: "CI_ARCHIVE_NAME",
146
+ description: "The name of the .xcarchive to be used. Valid only when :output_directory is passed",
147
+ is_string: true,
148
+ optional: true
149
+ ),
150
+ FastlaneCore::ConfigItem.new(
151
+ key: :project,
152
+ env_name: "XC_PROJECT",
153
+ description: "Path to the .xcodeproj to be used or any project-related description. Used during CI_UNIQUE_PROJECT_ID generation",
154
+ is_string: true,
155
+ optional: false
156
+ ),
150
157
  ]
151
158
  end
152
159
 
@@ -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 && create_branch_if_needed
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
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module YalantisCi
3
- VERSION = "0.2.6"
3
+ VERSION = "0.3.9"
4
4
  end
5
5
  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.2.6
4
+ version: 0.3.9
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-25 00:00:00.000000000 Z
11
+ date: 2021-12-16 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,20 @@ 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_get_from_xcconfig.rb
166
+ - lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb
167
+ - lib/fastlane/plugin/yalantis_ci/actions/build_number_sync.rb
165
168
  - lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb
166
169
  - lib/fastlane/plugin/yalantis_ci/actions/ci_teardown.rb
167
170
  - lib/fastlane/plugin/yalantis_ci/actions/firebase_distribution_setup.rb
168
171
  - lib/fastlane/plugin/yalantis_ci/actions/install_brew_dependencies.rb
169
- - lib/fastlane/plugin/yalantis_ci/helper/ci_helper.rb
170
172
  - lib/fastlane/plugin/yalantis_ci/helper/git_helper.rb
171
173
  - lib/fastlane/plugin/yalantis_ci/version.rb
172
- homepage:
174
+ homepage:
173
175
  licenses:
174
176
  - MIT
175
177
  metadata: {}
176
- post_install_message:
178
+ post_install_message:
177
179
  rdoc_options: []
178
180
  require_paths:
179
181
  - lib
@@ -188,8 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
190
  - !ruby/object:Gem::Version
189
191
  version: '0'
190
192
  requirements: []
191
- rubygems_version: 3.2.0
192
- signing_key:
193
+ rubygems_version: 3.1.6
194
+ signing_key:
193
195
  specification_version: 4
194
196
  summary: Set of utilities and useful actions to help setup CI for Yalantis projects
195
197
  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