fastlane-plugin-google_cloud_storage_update 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3f50a9e91b40690fdd34db9a164bc620990579d8570f17daf47a41cc00afcff7
4
+ data.tar.gz: 686030eba2ad0060634b425be7e3b11a1dde86a717c9bedac78caa5a3951d6cb
5
+ SHA512:
6
+ metadata.gz: 0b731dbf2e5b25020b4b71a30a98521a26708a8fb8b0d21f5dab577678ed4e22ba12e4364f44e370cef68bdc7c5fd1f8979b395d81840d32d02e52cca2255a94
7
+ data.tar.gz: 532d8d32bb7eb6ad2f24797f054b6ac791aa109744e69c0ed7927fe3447254e5c609630fe4ec2023e64f7fd0e984241b23bd7bc59ff31b7e2b9a85611b2146ce
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Fernando Saragoca <fsaragoca@me.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.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # google_cloud_storage plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-google_cloud_storage)
4
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
5
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)
6
+
7
+ [![Twitter: @fsaragoca](https://img.shields.io/badge/contact-@fsaragoca-blue.svg?style=flat)](https://twitter.com/fsaragoca)
8
+
9
+ [![CircleCI](https://circleci.com/gh/fsaragoca/fastlane-plugin-google_cloud_storage.svg?style=svg)](https://circleci.com/gh/fsaragoca/fastlane-plugin-google_cloud_storage)
10
+
11
+ ## Getting Started
12
+
13
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-google_cloud_storage`, add it to your project by running:
14
+
15
+ ```bash
16
+ fastlane add_plugin google_cloud_storage_update
17
+ ```
18
+
19
+ ## About google_cloud_storage
20
+
21
+ Download and upload files from Google Cloud Storage.
22
+
23
+ ## Example
24
+
25
+ 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`.
26
+
27
+ ## Run tests for this plugin
28
+
29
+ To run both the tests, and code style validation, run
30
+
31
+ ```
32
+ rake
33
+ ```
34
+
35
+ To automatically fix many of the styling issues, use
36
+ ```
37
+ rubocop -a
38
+ ```
39
+
40
+ ## Issues and Feedback
41
+
42
+ For any other issues and feedback about this plugin, please submit it to this repository.
43
+
44
+ ## Troubleshooting
45
+
46
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
47
+
48
+ ## Using `fastlane` Plugins
49
+
50
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
51
+
52
+ ## About `fastlane`
53
+
54
+ `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,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'google/cloud/storage'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ # Google cloud storage check file action.
8
+ # This verifies if a specific file exists in the specified bucket
9
+ # it returns true if the file exists, false if it does not.
10
+ class GoogleCloudStorageCheckFileAction < Action
11
+ def self.run(params)
12
+ Actions.verify_gem!('google-cloud-storage')
13
+
14
+ storage = Helper::GoogleCloudStorageHelper.setup_storage(
15
+ project: params[:project],
16
+ keyfile: params[:keyfile]
17
+ )
18
+
19
+ bucket = Helper::GoogleCloudStorageHelper.find_bucket(
20
+ storage: storage,
21
+ bucket_name: params[:bucket]
22
+ )
23
+
24
+ begin
25
+ Helper::GoogleCloudStorageHelper.find_file(
26
+ bucket: bucket,
27
+ file_name: params[:file_name]
28
+ )
29
+ true
30
+ rescue StandardError
31
+ false
32
+ end
33
+ end
34
+
35
+ def self.description
36
+ "Check if file exists in Google Cloud Storage"
37
+ end
38
+
39
+ def self.authors
40
+ ["Fernando Saragoca"]
41
+ end
42
+
43
+ def self.return_value
44
+ "Returns 'true' if object exists, 'false' if not"
45
+ end
46
+
47
+ def self.available_options
48
+ [
49
+ FastlaneCore::ConfigItem.new(key: :project,
50
+ env_name: "GOOGLE_CLOUD_STORAGE_PROJECT",
51
+ description: "Google Cloud Storage project identifier",
52
+ optional: false,
53
+ type: String),
54
+ FastlaneCore::ConfigItem.new(key: :keyfile,
55
+ env_name: "GOOGLE_CLOUD_STORAGE_KEYFILE",
56
+ description: "Google Cloud Storage keyfile",
57
+ optional: false,
58
+ type: String,
59
+ verify_block: proc do |value|
60
+ if value.nil? || value.empty?
61
+ UI.user_error!("No keyfile for Google Cloud Storage action
62
+ given, pass using `keyfile_path:
63
+ 'path/to/file.txt'`")
64
+ elsif !File.file?(value)
65
+ UI.user_error!("Keyfile '#{value}' not found")
66
+ end
67
+ end),
68
+ FastlaneCore::ConfigItem.new(key: :bucket,
69
+ env_name: "GOOGLE_CLOUD_STORAGE_BUCKET",
70
+ description: "Google Cloud Storage bucket",
71
+ optional: false,
72
+ type: String),
73
+ FastlaneCore::ConfigItem.new(key: :file_name,
74
+ env_name: "GOOGLE_CLOUD_STORAGE_DOWNLOAD_FILE_NAME",
75
+ description: "File name",
76
+ optional: false,
77
+ type: String)
78
+ ]
79
+ end
80
+
81
+ # def self.supported?(platform)
82
+ # true
83
+ # end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'google/cloud/storage'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ # Google Cloud Storage download action.
8
+ # This downloads the specified file from the specified google
9
+ # cloud storage bucket and stores it in the chosen destination.
10
+ class GoogleCloudStorageCheckFileAction < Action
11
+ def self.run(params)
12
+ Actions.verify_gem!('google-cloud-storage')
13
+
14
+ output_path = params[:output_path]
15
+ output_directory = File.dirname(output_path)
16
+ unless File.exist?(output_directory)
17
+ Actions.sh("mkdir #{output_directory}", log: $verbose)
18
+ end
19
+
20
+ storage = Helper::GoogleCloudStorageHelper.setup_storage(
21
+ project: params[:project],
22
+ keyfile: params[:keyfile]
23
+ )
24
+
25
+ bucket = Helper::GoogleCloudStorageHelper.find_bucket(
26
+ storage: storage,
27
+ bucket_name: params[:bucket]
28
+ )
29
+
30
+ file = Helper::GoogleCloudStorageHelper.find_file(
31
+ bucket: bucket,
32
+ file_name: params[:file_name]
33
+ )
34
+
35
+ file.download(output_path)
36
+ end
37
+
38
+ def self.description
39
+ "Download a file from Google Cloud Storage"
40
+ end
41
+
42
+ def self.authors
43
+ ["Fernando Saragoca"]
44
+ end
45
+
46
+ def self.available_options
47
+ [
48
+ FastlaneCore::ConfigItem.new(key: :project,
49
+ env_name: "GOOGLE_CLOUD_STORAGE_PROJECT",
50
+ description: "Google Cloud Storage project identifier",
51
+ optional: false,
52
+ type: String),
53
+ FastlaneCore::ConfigItem.new(key: :keyfile,
54
+ env_name: "GOOGLE_CLOUD_STORAGE_KEYFILE",
55
+ description: "Google Cloud Storage keyfile",
56
+ optional: false,
57
+ type: String,
58
+ verify_block: proc do |value|
59
+ if value.nil? || value.empty?
60
+ UI.user_error!("No keyfile for Google Cloud Storage action
61
+ given, pass using `keyfile_path:
62
+ 'path/to/file.txt'`")
63
+ elsif File.file?(value) == false
64
+ UI.user_error!("Keyfile '#{value}' not found")
65
+ end
66
+ end),
67
+ FastlaneCore::ConfigItem.new(key: :bucket,
68
+ env_name: "GOOGLE_CLOUD_STORAGE_BUCKET",
69
+ description: "Google Cloud Storage bucket",
70
+ optional: false,
71
+ type: String),
72
+ FastlaneCore::ConfigItem.new(key: :output_path,
73
+ env_name: "GOOGLE_CLOUD_STORAGE_DOWNLOAD_OUTPUT_PATH",
74
+ description: "Path to save downloaded file",
75
+ optional: false,
76
+ type: String),
77
+ FastlaneCore::ConfigItem.new(key: :file_name,
78
+ env_name: "GOOGLE_CLOUD_STORAGE_DOWNLOAD_FILE_NAME",
79
+ description: "File name",
80
+ optional: false,
81
+ type: String)
82
+ ]
83
+ end
84
+
85
+ # def self.supported?(platform)
86
+ # true
87
+ # end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'google/cloud/storage'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ # Google Cloud Storage upload action
8
+ # This uploads the specified file to the specified
9
+ # Google Cloud Storage bucket under the specified filePath.
10
+ class GoogleCloudStorageUploadAction < Action
11
+ def self.run(params)
12
+ Actions.verify_gem!('google-cloud-storage')
13
+
14
+ storage = Helper::GoogleCloudStorageHelper.setup_storage(
15
+ project: params[:project],
16
+ keyfile: params[:keyfile]
17
+ )
18
+
19
+ bucket = Helper::GoogleCloudStorageHelper.find_bucket(
20
+ storage: storage,
21
+ bucket_name: params[:bucket]
22
+ )
23
+
24
+ file_name = params[:name] || File.basename(params[:content_path])
25
+ bucket.create_file(params[:content_path], file_name)
26
+ end
27
+
28
+ def self.description
29
+ "Upload a file to Google Cloud Storage"
30
+ end
31
+
32
+ def self.authors
33
+ ["Fernando Saragoca"]
34
+ end
35
+
36
+ def self.available_options
37
+ [
38
+ FastlaneCore::ConfigItem.new(key: :project,
39
+ env_name: "GOOGLE_CLOUD_STORAGE_PROJECT",
40
+ description: "Google Cloud Storage project identifier",
41
+ optional: false,
42
+ type: String),
43
+ FastlaneCore::ConfigItem.new(key: :keyfile,
44
+ env_name: "GOOGLE_CLOUD_STORAGE_KEYFILE",
45
+ description: "Google Cloud Storage keyfile",
46
+ optional: false,
47
+ type: String,
48
+ verify_block: proc do |value|
49
+ if value.nil? || value.empty?
50
+ UI.user_error!("No keyfile for Google Cloud Storage action
51
+ given, pass using `keyfile_path:
52
+ 'path/to/file.txt'`")
53
+ elsif !File.file?(value)
54
+ UI.user_error!("Keyfile '#{value}' not found")
55
+ end
56
+ end),
57
+ FastlaneCore::ConfigItem.new(key: :bucket,
58
+ env_name: "GOOGLE_CLOUD_STORAGE_BUCKET",
59
+ description: "Google Cloud Storage bucket",
60
+ optional: false,
61
+ type: String),
62
+ FastlaneCore::ConfigItem.new(key: :content_path,
63
+ env_name: "GOOGLE_CLOUD_STORAGE_UPLOAD_CONTENT_PATH",
64
+ description: "Path for file to upload",
65
+ optional: false,
66
+ type: String,
67
+ verify_block: proc do |value|
68
+ if value.nil? || value.empty?
69
+ UI.user_error!("No content path for google_cloud_storage_upload
70
+ action given, pass using `content_path:
71
+ 'path/to/file.txt'`")
72
+ elsif !File.file?(value)
73
+ UI.user_error!("File for path '#{value}' not found")
74
+ end
75
+ end),
76
+ FastlaneCore::ConfigItem.new(key: :name,
77
+ env_name: "GOOGLE_CLOUD_STORAGE_UPLOAD_NAME",
78
+ description: "File name",
79
+ optional: true,
80
+ type: String)
81
+ ]
82
+ end
83
+
84
+ # def self.supported?(platform)
85
+ # true
86
+ # end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'google/cloud/storage'
4
+
5
+ module Fastlane
6
+ module Helper
7
+ # Google cloud storage helper class handling the setup of the storage
8
+ class GoogleCloudStorageHelper
9
+ def self.setup_storage(project: nil, keyfile: nil)
10
+ Google::Cloud::Storage.new(
11
+ project: project,
12
+ keyfile: keyfile
13
+ )
14
+ rescue StandardError
15
+ UI.user_error! "Invalid Google Cloud Storage credentials 🚫"
16
+ end
17
+
18
+ def self.find_bucket(storage: nil, bucket_name: nil)
19
+ bucket = storage.bucket(bucket_name)
20
+ if bucket.nil?
21
+ UI.user_error! "Bucket '#{bucket_name}' not found 🚫"
22
+ end
23
+ bucket
24
+ end
25
+
26
+ def self.find_file(bucket: nil, file_name: nil)
27
+ file = bucket.file(file_name)
28
+ if file.nil?
29
+ UI.user_error! "Object '#{file_name}' not found 🚫"
30
+ end
31
+ file
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fastlane
4
+ module GoogleCloudStorageUpdate
5
+ VERSION = "0.2.1"
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastlane/plugin/google_cloud_storage_update/version'
4
+
5
+ module Fastlane
6
+ # Module for integrating with google_cloud_storage_update
7
+ module GoogleCloudStorageUpdate
8
+ # Return all .rb files inside the "actions" and "helper" directory
9
+ def self.all_classes
10
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
11
+ end
12
+ end
13
+ end
14
+
15
+ # By default we want to import all available actions and helpers
16
+ # A plugin can contain any number of actions and plugins
17
+ Fastlane::GoogleCloudStorageUpdate.all_classes.each do |current|
18
+ require current
19
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-google_cloud_storage_update
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Jeroen Stoker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: google-cloud-storage
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fastlane
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.0.5
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.0.5
111
+ description:
112
+ email: verelias@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - LICENSE
118
+ - README.md
119
+ - lib/fastlane/plugin/google_cloud_storage_update.rb
120
+ - lib/fastlane/plugin/google_cloud_storage_update/actions/google_cloud_storage_update_check_file_action.rb
121
+ - lib/fastlane/plugin/google_cloud_storage_update/actions/google_cloud_storage_update_download_action.rb
122
+ - lib/fastlane/plugin/google_cloud_storage_update/actions/google_cloud_storage_update_upload_action.rb
123
+ - lib/fastlane/plugin/google_cloud_storage_update/helper/google_cloud_storage_update_helper.rb
124
+ - lib/fastlane/plugin/google_cloud_storage_update/version.rb
125
+ homepage: https://github.com/verelias/fastlane-plugin-google_cloud_storage_update
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubygems_version: 3.2.22
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Google Cloud Storage
148
+ test_files: []