fastlane-plugin-yalantis_ci 0.2.3 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9003e20ea95dd616610c94a589ff702f7d6556044372ed98a57b810386b87a6a
4
- data.tar.gz: 6a3a2d1b5c30fc6175feedf43cf958cc9f2cd8d2c8e08854e4609b23a65609f3
3
+ metadata.gz: 7e71d3349153fab7a0926badc9f412249eb35729c33723998bd5baf497a41617
4
+ data.tar.gz: c951e30ec230b768c904b36d259b644560b33bace96130b5a1c2f565eb564ee7
5
5
  SHA512:
6
- metadata.gz: b0edfde9077ea31918befd8b4f08b0cfa4e7984554025e1c80ea2b56187e344fd24b826409660cac7ae3ab1b5d22800d6ec16c2d5a48d055e1f019b69173e744
7
- data.tar.gz: b7d5b0571f19d6a8dfe72a47ad6e2afbe20cf330004b9e69695fc74f78375ef716d2a1b23465c566622b5c8cd5a8d7e5e6bfe3a07f8a34294a14265428253e73
6
+ metadata.gz: 72dbadc3a903735a0cb6b0913f84e7af2700af3cc51d1f86bd451c61dee98383687194be17444ac7e8e366c6fa663150b846d78b5d47130d3dccf6824f6f9499
7
+ data.tar.gz: c13a7b734b8f48363d0d516357f85fa84b2687e1ee640d1c881d4fae520914e044930c2e64cca6d7be32a2aa2e872ccfa1e432c790a897a188befe46b7f830bf
@@ -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,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
@@ -80,7 +80,9 @@ module Fastlane
80
80
  end
81
81
 
82
82
  def self.setup_temp_keychain(id)
83
- name = "#{id}-fastlane"
83
+ job_id = ENV['CI_JOBENV_ID'] || ''
84
+
85
+ name = "#{id}-#{job_id}-fastlane"
84
86
  password = "#{name}-password"
85
87
  path = File.expand_path("~/Library/Keychains/#{name}.keychain-db")
86
88
 
@@ -98,7 +100,7 @@ module Fastlane
98
100
  end
99
101
 
100
102
  UI.message("Setting temporary keychain path to: \"#{path}\"")
101
- other_action.create_keychain(unlock: true, timeout: false, add_to_search_list: true)
103
+ other_action.create_keychain(unlock: true, timeout: 0, add_to_search_list: true)
102
104
  end
103
105
 
104
106
  #####################################################
@@ -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.3"
3
+ VERSION = "0.3.7"
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.3
4
+ version: 0.3.7
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-06-15 00:00:00.000000000 Z
11
+ date: 2021-12-15 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,19 +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/actions/yalantis_ci_action.rb
170
- - lib/fastlane/plugin/yalantis_ci/helper/ci_helper.rb
171
171
  - lib/fastlane/plugin/yalantis_ci/helper/git_helper.rb
172
172
  - lib/fastlane/plugin/yalantis_ci/version.rb
173
- homepage:
173
+ homepage:
174
174
  licenses:
175
175
  - MIT
176
176
  metadata: {}
177
- post_install_message:
177
+ post_install_message:
178
178
  rdoc_options: []
179
179
  require_paths:
180
180
  - lib
@@ -189,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubygems_version: 3.2.0
193
- signing_key:
192
+ rubygems_version: 3.1.6
193
+ signing_key:
194
194
  specification_version: 4
195
195
  summary: Set of utilities and useful actions to help setup CI for Yalantis projects
196
196
  test_files: []
@@ -1,47 +0,0 @@
1
- require 'fastlane/action'
2
- require_relative '../helper/ci_helper'
3
-
4
- module Fastlane
5
- module Actions
6
- class YalantisCiAction < Action
7
- def self.run(params)
8
- UI.message("The yalantis_ci plugin is working!")
9
- end
10
-
11
- def self.description
12
- "Set of utilities and useful actions to help setup CI for Yalantis projects"
13
- end
14
-
15
- def self.authors
16
- ["Dima Vorona"]
17
- end
18
-
19
- def self.return_value
20
- # If your method provides a return value, you can describe here what it does
21
- end
22
-
23
- def self.details
24
- # Optional:
25
- "This plugin provides tools that setup Firebase, setup proper match repo branch name based on the project Unique ID (based on Team ID and a project name), syncs AppStore Connect API keys, kbridges cocoapod keys plugin to sync and share keys, stored in an encrypted repo just as Match does"
26
- end
27
-
28
- def self.available_options
29
- [
30
- # FastlaneCore::ConfigItem.new(key: :your_option,
31
- # env_name: "YALANTIS_CI_YOUR_OPTION",
32
- # description: "A description of your option",
33
- # optional: false,
34
- # type: String)
35
- ]
36
- end
37
-
38
- def self.is_supported?(platform)
39
- # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
40
- # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
41
- #
42
- # [:ios, :mac, :android].include?(platform)
43
- true
44
- end
45
- end
46
- end
47
- end
@@ -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