fastlane-plugin-flint 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ee9d1210a7d63561378aefd6ba57e39d6746041c558a489f737b0783572bf2d6
4
+ data.tar.gz: d890be459284d4d591610b90dfad67b9493290de69d09bc23a42b3bad56cf93c
5
+ SHA512:
6
+ metadata.gz: b320f404a32b1a5662d6c1eded3da09ab9438e88e0f9877366cf3a22236549e25c7c94a972277dc7af5b058c99470199593d20bb072614cc544c4f9b1d46132c
7
+ data.tar.gz: beb33e33bff4da0d684e0726a2d17b8c2ed296371718eea70511cea040276e5a4d9b802df24795233bcde2dfa9527a59a9829531a111e0845c32c0888ae48b57
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Jyrno Ader <jyrno42@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # flint plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-flint)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-flint`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin flint
11
+ fastlane run flint_setup
12
+ $EDITOR Flintfile
13
+ fastlane run flint
14
+ ```
15
+
16
+ ## About flint
17
+
18
+ Easily sync your keystores across your team using git
19
+
20
+ **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
21
+
22
+ ## Example
23
+
24
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
25
+
26
+ **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
27
+
28
+ ## Run tests for this plugin
29
+
30
+ To run both the tests, and code style validation, run
31
+
32
+ ```
33
+ rake
34
+ ```
35
+
36
+ To automatically fix many of the styling issues, use
37
+ ```
38
+ rubocop -a
39
+ ```
40
+
41
+ ## Issues and Feedback
42
+
43
+ For any other issues and feedback about this plugin, please submit it to this repository.
44
+
45
+ ## Troubleshooting
46
+
47
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
48
+
49
+ ## Using _fastlane_ Plugins
50
+
51
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
52
+
53
+ ## About _fastlane_
54
+
55
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,15 @@
1
+ # For all available options run `fastlane flint --help`
2
+ # Remove the # in the beginning of the line to enable the other options
3
+
4
+ git_url("[[GIT_URL]]")
5
+
6
+ type("development") # The default type, can be: development or release
7
+
8
+ # app_identifier(["tools.fastlane.app", "tools.fastlane.app2"])
9
+
10
+ # Params for the generated keys
11
+ # full_name("Your name")
12
+ # orgization("")
13
+ # orgization_unit("")
14
+ # city("")
15
+ # country("") # 2 letter country code, e.g EE
@@ -0,0 +1,4 @@
1
+ storeFile=[[STORE_FILE]]
2
+ keyAlias=[[KEY_ALIAS]]
3
+ storePassword=[[PASSWORD]]
4
+ keyPassword=[[PASSWORD]]
@@ -0,0 +1,46 @@
1
+ ## [fastlane flint](https://docs.fastlane.tools/actions/flint/)
2
+
3
+ This repository contains all your keystores needed to build and sign your applications. They are encrypted using OpenSSL via a passphrase.
4
+
5
+ **Important:** Make sure this repository is set to private and only your team members have access to this repo.
6
+
7
+ Do not modify this file, as it gets overwritten every time you run _flint_.
8
+
9
+ ### Installation
10
+
11
+ Make sure you have the latest version of the Xcode command line tools installed:
12
+
13
+ ```
14
+ xcode-select --install
15
+ ```
16
+
17
+ Install _fastlane_ using
18
+
19
+ ```
20
+ [sudo] gem install fastlane -NV
21
+ ```
22
+
23
+ or alternatively using `brew cask install fastlane`
24
+
25
+ ### Usage
26
+
27
+ Navigate to your project folder and run
28
+
29
+ ```
30
+ fastlane flint development
31
+ ```
32
+ ```
33
+ fastlane flint release
34
+ ```
35
+
36
+ For more information open [fastlane flint git repo](https://docs.fastlane.tools/actions/flint/)
37
+
38
+ ### Content
39
+
40
+ #### certs
41
+
42
+ This directory contains all your keystores
43
+
44
+ ------------------------------------
45
+
46
+ For more information open [fastlane flint git repo](https://docs.fastlane.tools/actions/flint/)
@@ -0,0 +1,32 @@
1
+ require 'fastlane_core/helper'
2
+ require 'fastlane/plugin/flint/version'
3
+
4
+ module Fastlane
5
+ module Flint
6
+ Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore
7
+ UI = FastlaneCore::UI
8
+ ROOT = Pathname.new(File.expand_path('../../..', __FILE__))
9
+ DESCRIPTION = "Easily sync your keystores across your team using git"
10
+
11
+ # Return all .rb files inside the "actions" and "helper" directory
12
+ def self.all_classes
13
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
14
+ end
15
+
16
+ def self.environments
17
+ return %w(development release)
18
+ end
19
+
20
+ def self.cert_type_sym(type)
21
+ return :development if type == "development"
22
+ return :release if type == "release"
23
+ raise "Unknown cert type: '#{type}'"
24
+ end
25
+ end
26
+ end
27
+
28
+ # By default we want to import all available actions and helpers
29
+ # A plugin can contain any number of actions and plugins
30
+ Fastlane::Flint.all_classes.each do |current|
31
+ require current
32
+ end
@@ -0,0 +1,261 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane_core/configuration/config_item'
3
+ require_relative '../helper/flint_helper'
4
+ require_relative '../helper/git_helper'
5
+ require_relative '../helper/encrypt'
6
+
7
+ module Fastlane
8
+ module Actions
9
+ class FlintAction < Action
10
+ def self.description
11
+ Flint::DESCRIPTION
12
+ end
13
+
14
+ def self.authors
15
+ ['Jyrno Ader <jyrno@thorgate.eu>']
16
+ end
17
+
18
+ def self.details
19
+ "Easily sync your keystores across your team using git"
20
+ end
21
+
22
+ def self.run(params)
23
+ params.load_configuration_file('Flintfile')
24
+
25
+ FastlaneCore::PrintTable.print_values(config: params,
26
+ hide_keys: [:workspace],
27
+ title: "Summary for flint #{Fastlane::VERSION}")
28
+
29
+ encrypt = Flint::Encrypt.new
30
+ params[:workspace] = Flint::GitHelper.clone(params[:git_url],
31
+ params[:shallow_clone],
32
+ skip_docs: params[:skip_docs],
33
+ branch: params[:git_branch],
34
+ git_full_name: params[:git_full_name],
35
+ git_user_email: params[:git_user_email],
36
+ clone_branch_directly: params[:clone_branch_directly],
37
+ encrypt: encrypt)
38
+
39
+ if params[:app_identifier].kind_of?(Array)
40
+ app_identifiers = params[:app_identifier]
41
+ else
42
+ app_identifiers = params[:app_identifier].to_s.split(/\s*,\s*/).uniq
43
+ end
44
+
45
+ # sometimes we get an array with arrays, this is a bug. To unblock people using flint, I suggest we flatten!
46
+ # then in the future address the root cause of https://github.com/fastlane/fastlane/issues/11324
47
+ app_identifiers.flatten!
48
+
49
+ # Keystore
50
+ password = encrypt.password(params[:git_url])
51
+ keystore_name, files_to_commmit = fetch_keystore(params: params, app_identifier: app_identifiers[0], password: password)
52
+
53
+ # Done
54
+ if files_to_commmit.count > 0 && !params[:readonly]
55
+ message = Flint::GitHelper.generate_commit_message(params)
56
+ Flint::GitHelper.commit_changes(params[:workspace], message, params[:git_url], params[:git_branch], files_to_commmit, encrypt)
57
+ end
58
+
59
+ # Print a summary table for each app_identifier
60
+ app_identifiers.each do |app_identifier|
61
+ Flint::TablePrinter.print_summary(app_identifier: app_identifier, type: params[:type], keystore_name: keystore_name)
62
+ end
63
+
64
+ UI.success("All required keystores are installed 🙌".green)
65
+ ensure
66
+ Flint::GitHelper.clear_changes
67
+ end
68
+
69
+ def self.fetch_keystore(params: nil, app_identifier: nil, password: nil)
70
+ cert_type = Flint.cert_type_sym(params[:type])
71
+ files_to_commmit = []
72
+
73
+ app_identifier = app_identifier.gsub! '.', '_'
74
+
75
+ alias_name = "%s-%s" % [app_identifier, cert_type.to_s]
76
+
77
+ keystore_name = "%s.keystore" % [alias_name]
78
+ target_path = File.join(params[:target_dir], keystore_name)
79
+
80
+ certs = Dir[File.join(params[:workspace], "certs", keystore_name)]
81
+
82
+ if certs.count == 0
83
+ UI.important("Couldn't find a valid keystore in the git repo for #{cert_type}... creating one for you now")
84
+ UI.crash!("No code signing keystore found and can not create a new one because you enabled `readonly`") if params[:readonly]
85
+ cert_path = Flint::Generator.generate_keystore(params, keystore_name, alias_name, password)
86
+ files_to_commmit << cert_path
87
+
88
+ # install and activate the keystore
89
+ UI.verbose("Installing keystore '#{keystore_name}'")
90
+ Flint::Utils.import(cert_path, target_path, keystore_name, alias_name, password)
91
+ Flint::Utils.activate(keystore_name, alias_name, password, params[:keystore_properties_path])
92
+ else
93
+ cert_path = certs.last
94
+ UI.message("Installing keystore...")
95
+
96
+ if Flint::Utils.installed?(cert_path, target_path)
97
+ UI.verbose("Keystore '#{File.basename(cert_path)}' is already installed on this machine")
98
+ else
99
+ UI.verbose("Installing keystore '#{keystore_name}'")
100
+ Flint::Utils.import(cert_path, target_path, keystore_name, alias_name, password)
101
+ end
102
+
103
+ # Print keystore info
104
+ puts("")
105
+ puts(Flint::Utils.get_keystore_info(cert_path, password))
106
+ puts("")
107
+
108
+ # Activate the cert
109
+ Flint::Utils.activate(keystore_name, alias_name, password, params[:keystore_properties_path])
110
+ end
111
+
112
+ return File.basename(cert_path).gsub(".keystore", ""), files_to_commmit
113
+ end
114
+
115
+ def self.available_options
116
+ user = CredentialsManager::AppfileConfig.try_fetch_value(:apple_dev_portal_id)
117
+ user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
118
+
119
+ [
120
+ FastlaneCore::ConfigItem.new(key: :git_url,
121
+ env_name: "FLINT_GIT_URL",
122
+ description: "URL to the git repo containing all the keystores",
123
+ optional: false,
124
+ short_option: "-r"),
125
+ FastlaneCore::ConfigItem.new(key: :full_name,
126
+ env_name: "FLINT_FULL_NAME",
127
+ description: "Full name of the owner of the keystores",
128
+ optional: false,
129
+ is_string: true,
130
+ short_option: "-n"),
131
+ FastlaneCore::ConfigItem.new(key: :orgization,
132
+ env_name: "FLINT_ORGANIZATION",
133
+ description: "Organization of the owner of the keystores",
134
+ is_string: true,
135
+ short_option: "-o",
136
+ default_value: ""),
137
+ FastlaneCore::ConfigItem.new(key: :orgization_unit,
138
+ env_name: "FLINT_ORGANIZATION_UNIT",
139
+ description: "Organization unit of the owner of the keystores",
140
+ is_string: true,
141
+ short_option: "-u",
142
+ default_value: ""),
143
+ FastlaneCore::ConfigItem.new(key: :city,
144
+ env_name: "FLINT_CITY",
145
+ description: "City of the owner of the keystores",
146
+ optional: false,
147
+ is_string: true,
148
+ short_option: "-c"),
149
+ FastlaneCore::ConfigItem.new(key: :state,
150
+ env_name: "FLINT_STATE",
151
+ description: "State of the owner of the keystores",
152
+ optional: false,
153
+ is_string: true,
154
+ short_option: "-s"),
155
+ FastlaneCore::ConfigItem.new(key: :country,
156
+ env_name: "FLINT_COUNTRY",
157
+ description: "Country of the owner of the keystores (2 letters, e.g EE)",
158
+ optional: false,
159
+ is_string: true,
160
+ short_option: "-x"),
161
+ FastlaneCore::ConfigItem.new(key: :git_branch,
162
+ env_name: "FLINT_GIT_BRANCH",
163
+ description: "Specific git branch to use",
164
+ default_value: 'master'),
165
+ FastlaneCore::ConfigItem.new(key: :type,
166
+ env_name: "FLINT_TYPE",
167
+ description: "Define the profile type, can be #{Flint.environments.join(', ')}",
168
+ is_string: true,
169
+ short_option: "-y",
170
+ default_value: 'development',
171
+ verify_block: proc do |value|
172
+ unless Flint.environments.include?(value)
173
+ UI.user_error!("Unsupported environment #{value}, must be in #{Flint.environments.join(', ')}")
174
+ end
175
+ end),
176
+ FastlaneCore::ConfigItem.new(key: :app_identifier,
177
+ short_option: "-a",
178
+ env_name: "FLINT_APP_IDENTIFIER",
179
+ description: "The bundle identifier(s) of your app (comma-separated)",
180
+ is_string: false,
181
+ type: Array, # we actually allow String and Array here
182
+ skip_type_validation: true,
183
+ code_gen_sensitive: true,
184
+ default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
185
+ default_value_dynamic: true),
186
+ FastlaneCore::ConfigItem.new(key: :readonly,
187
+ env_name: "FLINT_READONLY",
188
+ description: "Only fetch existing keystores, don't generate new ones",
189
+ is_string: false,
190
+ default_value: false),
191
+ FastlaneCore::ConfigItem.new(key: :git_full_name,
192
+ env_name: "FLINT_GIT_FULL_NAME",
193
+ description: "git user full name to commit",
194
+ optional: true,
195
+ default_value: nil),
196
+ FastlaneCore::ConfigItem.new(key: :git_user_email,
197
+ env_name: "FLINT_GIT_USER_EMAIL",
198
+ description: "git user email to commit",
199
+ optional: true,
200
+ default_value: nil),
201
+ FastlaneCore::ConfigItem.new(key: :verbose,
202
+ env_name: "FLINT_VERBOSE",
203
+ description: "Print out extra information and all commands",
204
+ is_string: false,
205
+ default_value: false,
206
+ verify_block: proc do |value|
207
+ FastlaneCore::Globals.verbose = true if value
208
+ end),
209
+ FastlaneCore::ConfigItem.new(key: :keystore_properties_path,
210
+ env_name: "FLINT_KEYSTORE_PROPERTIES_PATH",
211
+ description: "Set target path for keystore.properties fie",
212
+ default_value: "../keystore.properties"),
213
+ FastlaneCore::ConfigItem.new(key: :target_dir,
214
+ env_name: "FLINT_TARGET_DIR",
215
+ description: "Set target dir for flint keystores",
216
+ default_value: "../app/"),
217
+ FastlaneCore::ConfigItem.new(key: :skip_confirmation,
218
+ env_name: "FLINT_SKIP_CONFIRMATION",
219
+ description: "Disables confirmation prompts during nuke, answering them with yes",
220
+ is_string: false,
221
+ default_value: false),
222
+ FastlaneCore::ConfigItem.new(key: :shallow_clone,
223
+ env_name: "FLINT_SHALLOW_CLONE",
224
+ description: "Make a shallow clone of the repository (truncate the history to 1 revision)",
225
+ is_string: false,
226
+ default_value: false),
227
+ FastlaneCore::ConfigItem.new(key: :clone_branch_directly,
228
+ env_name: "FLINT_CLONE_BRANCH_DIRECTLY",
229
+ description: "Clone just the branch specified, instead of the whole repo. This requires that the branch already exists. Otherwise the command will fail",
230
+ is_string: false,
231
+ default_value: false),
232
+ FastlaneCore::ConfigItem.new(key: :workspace,
233
+ description: nil,
234
+ verify_block: proc do |value|
235
+ unless Helper.test?
236
+ if value.start_with?("/var/folders") || value.include?("tmp/") || value.include?("temp/")
237
+ # that's fine
238
+ else
239
+ UI.user_error!("Specify the `git_url` instead of the `path`")
240
+ end
241
+ end
242
+ end,
243
+ optional: true),
244
+ FastlaneCore::ConfigItem.new(key: :skip_docs,
245
+ env_name: "FLINT_SKIP_DOCS",
246
+ description: "Skip generation of a README.md for the created git repository",
247
+ is_string: false,
248
+ default_value: false)
249
+ ]
250
+ end
251
+
252
+ def self.is_supported?(platform)
253
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
254
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
255
+ #
256
+ # [:ios, :mac, :android].include?(platform)
257
+ true
258
+ end
259
+ end
260
+ end
261
+ end