fastlane-plugin-yalantis_ci 0.1.0 → 0.2.0
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 +4 -4
- data/lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_add_to_remote.rb +108 -0
- data/lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb +62 -0
- data/lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb +84 -0
- data/lib/fastlane/plugin/yalantis_ci/actions/yalantis_ci_action.rb +1 -1
- data/lib/fastlane/plugin/yalantis_ci/helper/{yalantis_ci_helper.rb → ci_helper.rb} +3 -2
- data/lib/fastlane/plugin/yalantis_ci/helper/git_helper.rb +37 -0
- data/lib/fastlane/plugin/yalantis_ci/version.rb +1 -1
- metadata +13 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b102acbcb869c25f9ac8e1bf0daaf14eaa0869cfea5f35722cd809c43db93e5
|
4
|
+
data.tar.gz: 5ed1edd600a0786ec984bf2fb4ed559879c94238bedcbe677c3b4cf0cd39402f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efc286c041bcac212cda5c7d4231b139e4793bbfd234f65ac8daca6bd1a8b9ecc95112fba98775f274f584d92dd3f8fdf38a839b1a79cba9014f3a8aa639fdca
|
7
|
+
data.tar.gz: 61db0ee63e3d0acbe9a0b716196c7707d518ee950c87145858ddf80a71ed0e6ebf33a36160bbb27aaa98159bbf4aaaf37d63981119c3f2dce7f80ba01e0db300
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'base64'
|
3
|
+
require_relative '../helper/git_helper'
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
module Actions
|
7
|
+
class AppStoreConnectApiKeyAddToRemoteAction < Action
|
8
|
+
def self.run(options)
|
9
|
+
git_repo_url = options[:git_repo_url]
|
10
|
+
git_repo_branch = 'master'
|
11
|
+
key_filepath = options[:key_filepath]
|
12
|
+
key_id = options[:key_id]
|
13
|
+
key_content = options[:key_content]
|
14
|
+
is_key_content_base64 = options[:is_key_content_base64]
|
15
|
+
|
16
|
+
if key_content.nil? && key_filepath.nil?
|
17
|
+
UI.user_error!(":key_content or :key_filepath is required")
|
18
|
+
end
|
19
|
+
|
20
|
+
Helper::GitHelper.clone_repo_in_tmp(git_repo_url, git_repo_branch, true) do |dir|
|
21
|
+
target_filename = "#{key_id}.p8"
|
22
|
+
target_filepath = File.join(dir, target_filename)
|
23
|
+
|
24
|
+
if key_filepath.nil? == false
|
25
|
+
FileUtils.cp(File.expand(key_filepath), target_filepath)
|
26
|
+
else
|
27
|
+
File.open(target_filepath, 'w') do |file|
|
28
|
+
if is_key_content_base64
|
29
|
+
file.write(Base64.decode64(key_content))
|
30
|
+
else
|
31
|
+
file.write(key_content)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
repo_status = Actions.sh("git status --porcelain")
|
37
|
+
repo_clean = repo_status.empty?
|
38
|
+
|
39
|
+
if repo_clean
|
40
|
+
UI.message("Skipping key #{key_id} update since it contents remains the same")
|
41
|
+
else
|
42
|
+
UI.message("Adding / updating #{key_id}")
|
43
|
+
|
44
|
+
Actions.sh("git add #{target_filename} && git commit -m '[AppStore Connect API Key] Add/Update #{target_filename} key'")
|
45
|
+
Actions.sh("git push -f #{git_repo_url} #{git_repo_branch}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#####################################################
|
51
|
+
# @!group Documentation
|
52
|
+
#####################################################
|
53
|
+
|
54
|
+
def self.description
|
55
|
+
"Add/Update AppStore Connect API Key to the remote git repo"
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.available_options
|
59
|
+
[
|
60
|
+
FastlaneCore::ConfigItem.new(
|
61
|
+
key: :git_repo_url,
|
62
|
+
env_name: "APP_STORE_CONNECT_API_KEY_GIT_REPO_URL",
|
63
|
+
description: "Git repo URL where AppStore Connect's Api Key should be stored in",
|
64
|
+
type: String
|
65
|
+
),
|
66
|
+
FastlaneCore::ConfigItem.new(
|
67
|
+
key: :key_filepath,
|
68
|
+
env_name: "APP_STORE_CONNECT_API_KEY_KEY_FILEPATH",
|
69
|
+
description: "The path to the key p8 file",
|
70
|
+
optional: true,
|
71
|
+
conflicting_options: [:key_content],
|
72
|
+
verify_block: proc do |value|
|
73
|
+
UI.user_error!("Couldn't find key p8 file at path '#{value}'") unless File.exist?(File.expand_path(value))
|
74
|
+
end
|
75
|
+
),
|
76
|
+
FastlaneCore::ConfigItem.new(
|
77
|
+
key: :key_id,
|
78
|
+
env_name: "APP_STORE_CONNECT_API_KEY_KEY_ID",
|
79
|
+
description: "The key ID",
|
80
|
+
),
|
81
|
+
FastlaneCore::ConfigItem.new(
|
82
|
+
key: :key_content,
|
83
|
+
env_name: "APP_STORE_CONNECT_API_KEY_KEY",
|
84
|
+
description: "The content of the key p8 file",
|
85
|
+
sensitive: true,
|
86
|
+
optional: true,
|
87
|
+
conflicting_options: [:key_filepath]
|
88
|
+
),
|
89
|
+
FastlaneCore::ConfigItem.new(
|
90
|
+
key: :is_key_content_base64,
|
91
|
+
env_name: "APP_STORE_CONNECT_API_KEY_IS_KEY_CONTENT_BASE64",
|
92
|
+
description: "Whether :key_content is Base64 encoded or not",
|
93
|
+
type: Boolean,
|
94
|
+
default_value: false
|
95
|
+
)
|
96
|
+
]
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.authors
|
100
|
+
["Dima Vorona", "Yalantis"]
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.is_supported?(platform)
|
104
|
+
[:ios, :mac].include?(platform)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'base64'
|
3
|
+
require_relative '../helper/git_helper'
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
module Actions
|
7
|
+
class AppStoreConnectApiKeyRemoveFromRemoteAction < Action
|
8
|
+
def self.run(options)
|
9
|
+
git_repo_url = options[:git_repo_url]
|
10
|
+
git_repo_branch = 'master'
|
11
|
+
key_id = options[:key_id]
|
12
|
+
|
13
|
+
Helper::GitHelper.clone_repo_in_tmp(git_repo_url, git_repo_branch, false) do |dir|
|
14
|
+
target_filename = "#{key_id}.p8"
|
15
|
+
target_filepath = File.join(dir, target_filename)
|
16
|
+
|
17
|
+
if File.exist?(target_filepath)
|
18
|
+
UI.message("Removing '#{key_id}.p8' at #{git_repo_url}")
|
19
|
+
FileUtils.rm(target_filepath)
|
20
|
+
|
21
|
+
Actions.sh("git rm #{target_filename} && git commit -m '[AppStore Connect API Key] Remove '#{key_id}.p8' key'")
|
22
|
+
Actions.sh("git push -f #{git_repo_url} #{git_repo_branch}")
|
23
|
+
else
|
24
|
+
UI.message("Skipping remove of '#{key_id}.p8' as no file has been found at #{git_repo_url}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#####################################################
|
30
|
+
# @!group Documentation
|
31
|
+
#####################################################
|
32
|
+
|
33
|
+
def self.description
|
34
|
+
"Remove AppStore Connect API Key from the remote git repo"
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.available_options
|
38
|
+
[
|
39
|
+
FastlaneCore::ConfigItem.new(
|
40
|
+
key: :git_repo_url,
|
41
|
+
env_name: "APP_STORE_CONNECT_API_KEY_GIT_REPO_URL",
|
42
|
+
description: "Git repo URL where AppStore Connect's Api Key should be stored in",
|
43
|
+
type: String
|
44
|
+
),
|
45
|
+
FastlaneCore::ConfigItem.new(
|
46
|
+
key: :key_id,
|
47
|
+
env_name: "APP_STORE_CONNECT_API_KEY_KEY_ID",
|
48
|
+
description: "The key ID",
|
49
|
+
)
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.authors
|
54
|
+
["Dima Vorona", "Yalantis"]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.is_supported?(platform)
|
58
|
+
[:ios, :mac].include?(platform)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require_relative '../helper/git_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class AppStoreConnectApiKeySetFromRemoteAction < Action
|
7
|
+
def self.run(options)
|
8
|
+
git_repo_url = options[:git_repo_url]
|
9
|
+
git_repo_branch = 'master'
|
10
|
+
|
11
|
+
key_id = options[:key_id]
|
12
|
+
issuer_id = options[:issuer_id]
|
13
|
+
in_house = options[:in_house]
|
14
|
+
|
15
|
+
Helper::GitHelper.clone_repo_in_tmp(git_repo_url, git_repo_branch) do |dir|
|
16
|
+
target_filename = "#{key_id}.p8"
|
17
|
+
target_filepath = Pathname.new File.join(dir, target_filename)
|
18
|
+
|
19
|
+
if target_filepath.exist?
|
20
|
+
UI.message("Setting contents of #{target_filename} as a API Key")
|
21
|
+
|
22
|
+
Fastlane::Actions::AppStoreConnectApiKeyAction.run(
|
23
|
+
key_id: key_id,
|
24
|
+
issuer_id: issuer_id,
|
25
|
+
key_content: Base64.encode64(target_filepath.read),
|
26
|
+
is_key_content_base64: true,
|
27
|
+
in_house: in_house
|
28
|
+
)
|
29
|
+
else
|
30
|
+
UI.user_error!("No #{target_filename} has been found at #{git_repo_url}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#####################################################
|
36
|
+
# @!group Documentation
|
37
|
+
#####################################################
|
38
|
+
|
39
|
+
def self.description
|
40
|
+
"Add/Update AppStore Connect API Key to the remote git repo"
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.available_options
|
44
|
+
[
|
45
|
+
FastlaneCore::ConfigItem.new(
|
46
|
+
key: :git_repo_url,
|
47
|
+
env_name: "APP_STORE_CONNECT_API_KEY_GIT_REPO_URL",
|
48
|
+
description: "Git repo URL where AppStore Connect's Api Key should be stored in",
|
49
|
+
type: String
|
50
|
+
),
|
51
|
+
FastlaneCore::ConfigItem.new(
|
52
|
+
key: :key_id,
|
53
|
+
env_name: "APP_STORE_CONNECT_API_KEY_KEY_ID",
|
54
|
+
description: "The key ID",
|
55
|
+
),
|
56
|
+
FastlaneCore::ConfigItem.new(
|
57
|
+
key: :issuer_id,
|
58
|
+
env_name: "APP_STORE_CONNECT_API_KEY_ISSUER_ID",
|
59
|
+
description: "The issuer ID"
|
60
|
+
),
|
61
|
+
FastlaneCore::ConfigItem.new(
|
62
|
+
key: :in_house,
|
63
|
+
env_name: "APP_STORE_CONNECT_API_KEY_IN_HOUSE",
|
64
|
+
description: "Is App Store or Enterprise (in house) team? App Store Connect API cannot determine this on its own (yet)",
|
65
|
+
type: Boolean,
|
66
|
+
default_value: false
|
67
|
+
)
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.output
|
72
|
+
Fastlane::Actions::AppStoreConnectApiKeyAction.output
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.authors
|
76
|
+
["Dima Vorona", "Yalantis"]
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.is_supported?(platform)
|
80
|
+
[:ios, :mac].include?(platform)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -4,9 +4,10 @@ module Fastlane
|
|
4
4
|
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
5
5
|
|
6
6
|
module Helper
|
7
|
-
class
|
7
|
+
class CiHelper
|
8
|
+
|
8
9
|
# class methods that you define here become available in your action
|
9
|
-
# as `Helper::
|
10
|
+
# as `Helper::CiHelper.your_method`
|
10
11
|
#
|
11
12
|
def self.show_message
|
12
13
|
UI.message("Hello from the yalantis_ci plugin helper!")
|
@@ -0,0 +1,37 @@
|
|
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 GitHelper
|
8
|
+
|
9
|
+
def self.clone_repo_in_tmp(repo_url, branch = 'master', create_branch_if_needed = false)
|
10
|
+
temp_directory = `mktemp -d`.tr("\n", "")
|
11
|
+
|
12
|
+
begin
|
13
|
+
Dir.chdir(temp_directory) do
|
14
|
+
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
|
18
|
+
raise StandardError.new result
|
19
|
+
end
|
20
|
+
end
|
21
|
+
elsif status.success? != true
|
22
|
+
raise StandardError.new result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
yield(Dir.pwd)
|
26
|
+
end
|
27
|
+
ensure
|
28
|
+
Actions.sh("rm -rf #{temp_directory}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.show_message
|
33
|
+
UI.message("Hello from the yalantis_ci plugin helper!")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
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.2.0
|
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-06-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: []
|
@@ -159,18 +159,22 @@ files:
|
|
159
159
|
- LICENSE
|
160
160
|
- README.md
|
161
161
|
- lib/fastlane/plugin/yalantis_ci.rb
|
162
|
+
- lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_add_to_remote.rb
|
163
|
+
- lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_remove_from_remote.rb
|
164
|
+
- lib/fastlane/plugin/yalantis_ci/actions/app_store_connect_api_key_set_from_remote.rb
|
162
165
|
- lib/fastlane/plugin/yalantis_ci/actions/ci_setup.rb
|
163
166
|
- lib/fastlane/plugin/yalantis_ci/actions/ci_teardown.rb
|
164
167
|
- lib/fastlane/plugin/yalantis_ci/actions/firebase_distribution_setup.rb
|
165
168
|
- lib/fastlane/plugin/yalantis_ci/actions/install_brew_dependencies.rb
|
166
169
|
- lib/fastlane/plugin/yalantis_ci/actions/yalantis_ci_action.rb
|
167
|
-
- lib/fastlane/plugin/yalantis_ci/helper/
|
170
|
+
- lib/fastlane/plugin/yalantis_ci/helper/ci_helper.rb
|
171
|
+
- lib/fastlane/plugin/yalantis_ci/helper/git_helper.rb
|
168
172
|
- lib/fastlane/plugin/yalantis_ci/version.rb
|
169
|
-
homepage:
|
173
|
+
homepage:
|
170
174
|
licenses:
|
171
175
|
- MIT
|
172
176
|
metadata: {}
|
173
|
-
post_install_message:
|
177
|
+
post_install_message:
|
174
178
|
rdoc_options: []
|
175
179
|
require_paths:
|
176
180
|
- lib
|
@@ -185,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
189
|
- !ruby/object:Gem::Version
|
186
190
|
version: '0'
|
187
191
|
requirements: []
|
188
|
-
rubygems_version: 3.0
|
189
|
-
signing_key:
|
192
|
+
rubygems_version: 3.2.0
|
193
|
+
signing_key:
|
190
194
|
specification_version: 4
|
191
195
|
summary: Set of utilities and useful actions to help setup CI for Yalantis projects
|
192
196
|
test_files: []
|