fastlane-plugin-google_drive 0.1.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -7
- data/lib/fastlane/plugin/google_drive/actions/create_google_drive_folder_action.rb +103 -0
- data/lib/fastlane/plugin/google_drive/actions/google_drive_upload_action.rb +11 -97
- data/lib/fastlane/plugin/google_drive/actions/update_google_drive_file_action.rb +103 -0
- data/lib/fastlane/plugin/google_drive/actions/upload_google_drive_action.rb +24 -0
- data/lib/fastlane/plugin/google_drive/actions/upload_to_google_drive_action.rb +110 -0
- data/lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb +20 -2
- data/lib/fastlane/plugin/google_drive/version.rb +1 -1
- metadata +31 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbca024b341c811412e22d2b275bf3fccb75557aacee681df62f808a17ae011f
|
4
|
+
data.tar.gz: 2d55aeeb8afb05861e733974e09d9a2376d3f69a1dcb1d56b9543f0565dc2930
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae3dc9110b9f974d4b35d48b7f45c072683ba0ef3004e08fe63a0ac0ac0d7d9fed4feb5c31b7dc9319097846c85d150c0a30bdebb9d8b25df12851267b9d504d
|
7
|
+
data.tar.gz: fbeec3d0f8cd9e7593ef48e693a16c2a8e97cefafb26aa4e5134c182b961587eac8e3b48a05fb54c287dffd0446458b9d78a479bef57e9d55be7636c9d74a3c8
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
# google_drive plugin
|
1
|
+
# google_drive `fastlane` plugin
|
2
2
|
|
3
3
|
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-google_drive)
|
4
|
+
[![Gem Version Badge](https://badge.fury.io/rb/fastlane-plugin-google_drive.svg)](https://badge.fury.io/rb/fastlane-plugin-google_drive)
|
5
|
+
[![Build Status](https://travis-ci.com/bskim45/fastlane-plugin-google_drive.svg?branch=master)](https://travis-ci.com/bskim45/fastlane-plugin-google_drive)
|
6
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/681ab1f5c19ca029dff4/test_coverage)](https://codeclimate.com/github/bskim45/fastlane-plugin-google_drive/test_coverage)
|
7
|
+
[![security](https://hakiri.io/github/bskim45/fastlane-plugin-google_drive/master.svg)](https://hakiri.io/github/bskim45/fastlane-plugin-google_drive/master)
|
4
8
|
|
5
9
|
## Getting Started
|
6
10
|
|
@@ -12,26 +16,57 @@ fastlane add_plugin google_drive
|
|
12
16
|
|
13
17
|
## About google_drive
|
14
18
|
|
15
|
-
|
19
|
+
> Please refer to [this guide](https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md) to create an Google Drive credential.
|
16
20
|
|
17
|
-
|
21
|
+
Upload files to Google Drive folder.
|
22
|
+
> Aliases for this action - `google_drive_upload` and `upload_google_drive` will be removed in next version.
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
upload_to_google_drive(
|
26
|
+
drive_keyfile: 'drive_key.json',
|
27
|
+
service_account: true,
|
28
|
+
folder_id: 'folder_id',
|
29
|
+
upload_files: ['file_to_upload', 'another_file_to_upload']
|
30
|
+
)
|
31
|
+
```
|
32
|
+
|
33
|
+
Create new Google Drive folder:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
create_google_drive_folder(
|
37
|
+
drive_keyfile: 'drive_key.json',
|
38
|
+
folder_id: '#{folder_id}',
|
39
|
+
folder_title: 'new_folder'
|
40
|
+
)
|
41
|
+
```
|
42
|
+
|
43
|
+
Update the content of existing Google Drive file:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
update_google_drive_file(
|
47
|
+
drive_keyfile: 'drive_key.json',
|
48
|
+
file_id: 'file_id',
|
49
|
+
upload_file: 'path/to/file.txt'
|
50
|
+
)
|
51
|
+
```
|
52
|
+
|
53
|
+
Download feature is not implemented yet. PR is always welcome.
|
18
54
|
|
19
55
|
## Example
|
20
56
|
|
21
57
|
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`.
|
22
58
|
|
23
|
-
**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)
|
24
|
-
|
25
59
|
## Run tests for this plugin
|
26
60
|
|
27
61
|
To run both the tests, and code style validation, run
|
28
62
|
|
29
|
-
```
|
63
|
+
```bash
|
30
64
|
rake
|
31
65
|
```
|
32
66
|
|
33
67
|
To automatically fix many of the styling issues, use
|
34
|
-
|
68
|
+
|
69
|
+
```bash
|
35
70
|
rubocop -a
|
36
71
|
```
|
37
72
|
|
@@ -50,3 +85,9 @@ For more information about how the `fastlane` plugin system works, check out the
|
|
50
85
|
## About _fastlane_
|
51
86
|
|
52
87
|
_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).
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
The MIT License (MIT)
|
92
|
+
|
93
|
+
Copyright (c) 2019 Bumsoo Kim (<https://bsk.im>)
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/google_drive_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GDRIVE_CREATED_FOLDER_ID = :GDRIVE_CREATED_FOLDER_ID
|
8
|
+
GDRIVE_CREATED_FOLDER_URL = :GDRIVE_CREATED_FOLDER_URL
|
9
|
+
end
|
10
|
+
class CreateGoogleDriveFolderAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Using config file: #{params[:drive_keyfile]}")
|
13
|
+
|
14
|
+
session = Helper::GoogleDriveHelper.setup(
|
15
|
+
keyfile: params[:drive_keyfile],
|
16
|
+
service_account: params[:service_account]
|
17
|
+
)
|
18
|
+
|
19
|
+
folder = Helper::GoogleDriveHelper.file_by_id(
|
20
|
+
session: session, fid: params[:folder_id]
|
21
|
+
)
|
22
|
+
|
23
|
+
title = params[:folder_title]
|
24
|
+
UI.message('------------------')
|
25
|
+
UI.important("Creating #{title}")
|
26
|
+
new_folder = Helper::GoogleDriveHelper.create_subcollection(root_folder: folder, title: title)
|
27
|
+
UI.success('Success')
|
28
|
+
UI.message('------------------')
|
29
|
+
|
30
|
+
folder_id = new_folder.resource_id.split(':').last
|
31
|
+
Actions.lane_context[SharedValues::GDRIVE_CREATED_FOLDER_ID] = folder_id
|
32
|
+
Actions.lane_context[SharedValues::GDRIVE_CREATED_FOLDER_URL] = new_folder.human_url
|
33
|
+
|
34
|
+
new_folder
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.description
|
38
|
+
'Create new folder on Google Drive'
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.details
|
42
|
+
[
|
43
|
+
'Create new folder on Google Drive',
|
44
|
+
'See https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md to get a keyfile'
|
45
|
+
].join("\n")
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.available_options
|
49
|
+
[
|
50
|
+
FastlaneCore::ConfigItem.new(key: :drive_keyfile,
|
51
|
+
env_name: 'GDRIVE_KEY_FILE',
|
52
|
+
description: 'Json config file',
|
53
|
+
type: String,
|
54
|
+
default_value: 'drive_key.json',
|
55
|
+
verify_block: proc do |value|
|
56
|
+
UI.user_error!("Couldn't find config keyfile at path '#{value}'") unless File.exist?(value)
|
57
|
+
end),
|
58
|
+
FastlaneCore::ConfigItem.new(key: :service_account,
|
59
|
+
env_name: 'GDRIVE_SERVICE_ACCOUNT',
|
60
|
+
description: 'Credential is service account',
|
61
|
+
optional: true,
|
62
|
+
is_string: false,
|
63
|
+
default_value: false),
|
64
|
+
FastlaneCore::ConfigItem.new(key: :folder_id,
|
65
|
+
env_name: "GDRIVE_UPLOAD_FOLDER_ID",
|
66
|
+
description: "Upload target folder id",
|
67
|
+
optional: false,
|
68
|
+
type: String,
|
69
|
+
verify_block: proc do |value|
|
70
|
+
UI.user_error!("No target folder_id given, pass using `folder_id: 'some_id'`") unless value and !value.empty?
|
71
|
+
end),
|
72
|
+
FastlaneCore::ConfigItem.new(key: :folder_title,
|
73
|
+
env_name: "GDRIVE_FOLDER_NAME",
|
74
|
+
description: "Folder title of new one",
|
75
|
+
optional: false,
|
76
|
+
type: String,
|
77
|
+
verify_block: proc do |value|
|
78
|
+
UI.user_error!("No folder title given") if value.nil? || value.empty?
|
79
|
+
end)
|
80
|
+
]
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.output
|
84
|
+
[
|
85
|
+
['GDRIVE_CREATED_FOLDER_ID', 'ID of the created folder'],
|
86
|
+
['GDRIVE_CREATED_FOLDER_URL', 'Link to the created folder']
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.return_value
|
91
|
+
'`GoogleDrive::Collection` object which indicates the created folder.'
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.authors
|
95
|
+
['Kohki Miki (@giginet)']
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.is_supported?(platform)
|
99
|
+
true
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -1,109 +1,23 @@
|
|
1
|
-
require 'fastlane/action'
|
2
|
-
require_relative '../helper/google_drive_helper'
|
3
|
-
|
4
1
|
module Fastlane
|
5
2
|
module Actions
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def self.run(params)
|
12
|
-
UI.message("Using config file: #{params[:drive_keyfile]}")
|
13
|
-
|
14
|
-
session = Helper::GoogleDriveHelper.setup(
|
15
|
-
keyfile: params[:drive_keyfile],
|
16
|
-
service_account: params[:service_account]
|
17
|
-
)
|
18
|
-
|
19
|
-
folder = Helper::GoogleDriveHelper.file_by_id(
|
20
|
-
session: session, fid: params[:folder_id]
|
21
|
-
)
|
22
|
-
|
23
|
-
uploaded_files = []
|
24
|
-
assets = params[:upload_files]
|
25
|
-
|
26
|
-
UI.abort_with_message!("No files to upload") if assets.nil? or assets.empty?
|
27
|
-
|
28
|
-
assets.each do |asset|
|
29
|
-
UI.message('------------------')
|
30
|
-
UI.important("Uploading #{asset}")
|
31
|
-
uploaded_files.push(Helper::GoogleDriveHelper.upload_file(file: folder, file_name: asset))
|
32
|
-
UI.success('Success')
|
33
|
-
UI.message('------------------')
|
34
|
-
end
|
35
|
-
|
36
|
-
Actions.lane_context[SharedValues::GDRIVE_UPLOADED_FILE_NAMES] = uploaded_files.map(&:title)
|
37
|
-
Actions.lane_context[SharedValues::GDRIVE_UPLOADED_FILE_URLS] = uploaded_files.map(&:human_url)
|
38
|
-
end
|
3
|
+
require 'fastlane/plugin/google_drive/actions/upload_to_google_drive_action'
|
4
|
+
class GoogleDriveUploadAction < UploadToGoogleDriveAction
|
5
|
+
#####################################################
|
6
|
+
# @!group Documentation
|
7
|
+
#####################################################
|
39
8
|
|
40
9
|
def self.description
|
41
|
-
|
10
|
+
"Alias for the `upload_to_google_drive` action"
|
42
11
|
end
|
43
12
|
|
44
|
-
def self.
|
45
|
-
|
46
|
-
'Upload files to Google Drive',
|
47
|
-
'See https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md to get a keyfile'
|
48
|
-
].join("\n")
|
13
|
+
def self.category
|
14
|
+
:deprecated
|
49
15
|
end
|
50
16
|
|
51
|
-
def self.
|
17
|
+
def self.deprecated_notes
|
52
18
|
[
|
53
|
-
|
54
|
-
|
55
|
-
description: 'Json config file',
|
56
|
-
type: String,
|
57
|
-
default_value: 'drive_key.json',
|
58
|
-
verify_block: proc do |value|
|
59
|
-
UI.user_error!("Couldn't find config keyfile at path '#{value}'") unless File.exist?(value)
|
60
|
-
end),
|
61
|
-
FastlaneCore::ConfigItem.new(key: :service_account,
|
62
|
-
env_name: 'GDRIVE_SERVICE_ACCOUNT',
|
63
|
-
description: 'Credential is service account',
|
64
|
-
optional: true,
|
65
|
-
is_string: false,
|
66
|
-
default_value: false),
|
67
|
-
FastlaneCore::ConfigItem.new(key: :folder_id,
|
68
|
-
env_name: "GDRIVE_UPLOAD_FOLDER_ID",
|
69
|
-
description: "Upload target folder id",
|
70
|
-
optional: false,
|
71
|
-
type: String,
|
72
|
-
verify_block: proc do |value|
|
73
|
-
UI.user_error!("No target folder id given, pass using `folder_id: 'some_id'`") unless value and !value.empty?
|
74
|
-
end),
|
75
|
-
FastlaneCore::ConfigItem.new(key: :upload_files,
|
76
|
-
env_name: "GDRIVE_UPLOAD_FILES",
|
77
|
-
description: "Path to files to be uploaded",
|
78
|
-
optional: false,
|
79
|
-
is_string: false,
|
80
|
-
verify_block: proc do |value|
|
81
|
-
UI.user_error!("upload_files must be an Array of paths to files") unless value.kind_of?(Array)
|
82
|
-
UI.user_error!("No upload file is given, pass using `upload_files: ['a', 'b']`") unless value and !value.empty?
|
83
|
-
value.each do |path|
|
84
|
-
UI.user_error!("Couldn't find upload file at path '#{path}'") unless File.exist?(path)
|
85
|
-
end
|
86
|
-
end)
|
87
|
-
]
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.output
|
91
|
-
[
|
92
|
-
['GDRIVE_UPLOADED_FILE_NAMES', 'The array of names of uploaded files'],
|
93
|
-
['GDRIVE_UPLOADED_FILE_URLS', 'The array of links to uploaded files']
|
94
|
-
]
|
95
|
-
end
|
96
|
-
|
97
|
-
def self.return_value
|
98
|
-
# nothing
|
99
|
-
end
|
100
|
-
|
101
|
-
def self.authors
|
102
|
-
['Bumsoo Kim (@bskim45)']
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.is_supported?(platform)
|
106
|
-
true
|
19
|
+
"Please use `upload_to_google_drive` instead."
|
20
|
+
].join("\n")
|
107
21
|
end
|
108
22
|
end
|
109
23
|
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/google_drive_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GDRIVE_UPDATED_FILE_NAME = :GDRIVE_UPDATED_FILE_NAME
|
8
|
+
GDRIVE_UPDATED_FILE_URL = :GDRIVE_UPDATED_FILE_URL
|
9
|
+
end
|
10
|
+
class UpdateGoogleDriveFileAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Using config file: #{params[:drive_keyfile]}")
|
13
|
+
|
14
|
+
session = Helper::GoogleDriveHelper.setup(
|
15
|
+
keyfile: params[:drive_keyfile],
|
16
|
+
service_account: params[:service_account]
|
17
|
+
)
|
18
|
+
|
19
|
+
file = Helper::GoogleDriveHelper.file_by_id(
|
20
|
+
session: session, fid: params[:file_id]
|
21
|
+
)
|
22
|
+
|
23
|
+
upload_file = params[:upload_file]
|
24
|
+
UI.abort_with_message!("No file to upload") if upload_file.nil? or upload_file.empty?
|
25
|
+
|
26
|
+
UI.message('------------------')
|
27
|
+
UI.important("Uploading #{upload_file}")
|
28
|
+
Helper::GoogleDriveHelper.update_file(file: file, file_name: upload_file)
|
29
|
+
UI.success('Success')
|
30
|
+
UI.message('------------------')
|
31
|
+
|
32
|
+
Actions.lane_context[SharedValues::GDRIVE_UPDATED_FILE_NAME] = file.title
|
33
|
+
Actions.lane_context[SharedValues::GDRIVE_UPDATED_FILE_URL] = file.human_url
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.description
|
37
|
+
'Update a Google Drive file'
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.details
|
41
|
+
[
|
42
|
+
'Update a Google Drive file',
|
43
|
+
'See https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md to get a keyfile'
|
44
|
+
].join("\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.available_options
|
48
|
+
[
|
49
|
+
FastlaneCore::ConfigItem.new(key: :drive_keyfile,
|
50
|
+
env_name: 'GDRIVE_KEY_FILE',
|
51
|
+
description: 'Json config file',
|
52
|
+
type: String,
|
53
|
+
default_value: 'drive_key.json',
|
54
|
+
verify_block: proc do |value|
|
55
|
+
UI.user_error!("Couldn't find config keyfile at path '#{value}'") unless File.exist?(value)
|
56
|
+
end),
|
57
|
+
FastlaneCore::ConfigItem.new(key: :service_account,
|
58
|
+
env_name: 'GDRIVE_SERVICE_ACCOUNT',
|
59
|
+
description: 'Credential is service account',
|
60
|
+
optional: true,
|
61
|
+
is_string: false,
|
62
|
+
default_value: false),
|
63
|
+
FastlaneCore::ConfigItem.new(key: :file_id,
|
64
|
+
env_name: "GDRIVE_UPDATE_FILE_ID",
|
65
|
+
description: "Target file id to update the content",
|
66
|
+
optional: false,
|
67
|
+
type: String,
|
68
|
+
verify_block: proc do |value|
|
69
|
+
UI.user_error!("No target file id given, pass using `file_id: 'some_id'`") unless value and !value.empty?
|
70
|
+
end),
|
71
|
+
FastlaneCore::ConfigItem.new(key: :upload_file,
|
72
|
+
env_name: "GDRIVE_UPLOAD_FILE",
|
73
|
+
description: "Path to a file to be uploaded",
|
74
|
+
optional: false,
|
75
|
+
is_string: false,
|
76
|
+
verify_block: proc do |value|
|
77
|
+
UI.user_error!("No upload file is given, pass using `upload_file: 'some/path/a.txt'`") unless value and !value.empty?
|
78
|
+
UI.user_error!("Couldn't find upload file at path '#{value}'") unless File.exist?(value)
|
79
|
+
end)
|
80
|
+
]
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.output
|
84
|
+
[
|
85
|
+
['GDRIVE_UPDATED_FILE_NAME', 'The name of the uploaded file'],
|
86
|
+
['GDRIVE_UPDATED_FILE_URL', 'The link to the uploaded file']
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.return_value
|
91
|
+
# nothing
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.authors
|
95
|
+
['Bumsoo Kim (@bskim45)']
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.is_supported?(platform)
|
99
|
+
true
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
require 'fastlane/plugin/google_drive/actions/upload_to_google_drive_action'
|
4
|
+
class UploadGoogleDriveAction < UploadToGoogleDriveAction
|
5
|
+
#####################################################
|
6
|
+
# @!group Documentation
|
7
|
+
#####################################################
|
8
|
+
|
9
|
+
def self.description
|
10
|
+
"Alias for the `upload_to_google_drive` action"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.category
|
14
|
+
:deprecated
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.deprecated_notes
|
18
|
+
[
|
19
|
+
"Please use `upload_to_google_drive` instead."
|
20
|
+
].join("\n")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/google_drive_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
GDRIVE_UPLOADED_FILE_NAMES = :GDRIVE_UPLOADED_FILE_NAMES
|
8
|
+
GDRIVE_UPLOADED_FILE_URLS = :GDRIVE_UPLOADED_FILE_URLS
|
9
|
+
end
|
10
|
+
class UploadToGoogleDriveAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Using config file: #{params[:drive_keyfile]}")
|
13
|
+
|
14
|
+
session = Helper::GoogleDriveHelper.setup(
|
15
|
+
keyfile: params[:drive_keyfile],
|
16
|
+
service_account: params[:service_account]
|
17
|
+
)
|
18
|
+
|
19
|
+
folder = Helper::GoogleDriveHelper.file_by_id(
|
20
|
+
session: session, fid: params[:folder_id]
|
21
|
+
)
|
22
|
+
|
23
|
+
uploaded_files = []
|
24
|
+
assets = params[:upload_files]
|
25
|
+
|
26
|
+
UI.abort_with_message!("No files to upload") if assets.nil? or assets.empty?
|
27
|
+
|
28
|
+
assets.each do |asset|
|
29
|
+
UI.message('------------------')
|
30
|
+
UI.important("Uploading #{asset}")
|
31
|
+
uploaded_files.push(Helper::GoogleDriveHelper.upload_file(file: folder, file_name: asset))
|
32
|
+
UI.success('Success')
|
33
|
+
UI.message('------------------')
|
34
|
+
end
|
35
|
+
|
36
|
+
Actions.lane_context[SharedValues::GDRIVE_UPLOADED_FILE_NAMES] = uploaded_files.map(&:title)
|
37
|
+
Actions.lane_context[SharedValues::GDRIVE_UPLOADED_FILE_URLS] = uploaded_files.map(&:human_url)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.description
|
41
|
+
'Upload files to Google Drive'
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.details
|
45
|
+
[
|
46
|
+
'Upload files to Google Drive',
|
47
|
+
'See https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md to get a keyfile'
|
48
|
+
].join("\n")
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.available_options
|
52
|
+
[
|
53
|
+
FastlaneCore::ConfigItem.new(key: :drive_keyfile,
|
54
|
+
env_name: 'GDRIVE_KEY_FILE',
|
55
|
+
description: 'Json config file',
|
56
|
+
type: String,
|
57
|
+
default_value: 'drive_key.json',
|
58
|
+
verify_block: proc do |value|
|
59
|
+
UI.user_error!("Couldn't find config keyfile at path '#{value}'") unless File.exist?(value)
|
60
|
+
end),
|
61
|
+
FastlaneCore::ConfigItem.new(key: :service_account,
|
62
|
+
env_name: 'GDRIVE_SERVICE_ACCOUNT',
|
63
|
+
description: 'Credential is service account',
|
64
|
+
optional: true,
|
65
|
+
is_string: false,
|
66
|
+
default_value: false),
|
67
|
+
FastlaneCore::ConfigItem.new(key: :folder_id,
|
68
|
+
env_name: "GDRIVE_UPLOAD_FOLDER_ID",
|
69
|
+
description: "Upload target folder id",
|
70
|
+
optional: false,
|
71
|
+
type: String,
|
72
|
+
verify_block: proc do |value|
|
73
|
+
UI.user_error!("No target folder id given, pass using `folder_id: 'some_id'`") unless value and !value.empty?
|
74
|
+
end),
|
75
|
+
FastlaneCore::ConfigItem.new(key: :upload_files,
|
76
|
+
env_name: "GDRIVE_UPLOAD_FILES",
|
77
|
+
description: "Path to files to be uploaded",
|
78
|
+
optional: false,
|
79
|
+
is_string: false,
|
80
|
+
verify_block: proc do |value|
|
81
|
+
UI.user_error!("upload_files must be an Array of paths to files") unless value.kind_of?(Array)
|
82
|
+
UI.user_error!("No upload file is given, pass using `upload_files: ['a', 'b']`") unless value and !value.empty?
|
83
|
+
value.each do |path|
|
84
|
+
UI.user_error!("Couldn't find upload file at path '#{path}'") unless File.exist?(path)
|
85
|
+
end
|
86
|
+
end)
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.output
|
91
|
+
[
|
92
|
+
['GDRIVE_UPLOADED_FILE_NAMES', 'The array of names of uploaded files'],
|
93
|
+
['GDRIVE_UPLOADED_FILE_URLS', 'The array of links to uploaded files']
|
94
|
+
]
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.return_value
|
98
|
+
# nothing
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.authors
|
102
|
+
['Bumsoo Kim (@bskim45)']
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.is_supported?(platform)
|
106
|
+
true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'fastlane_core/ui/ui'
|
2
2
|
require 'google_drive'
|
3
|
-
|
4
3
|
module Fastlane
|
5
4
|
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
6
5
|
|
@@ -29,7 +28,26 @@ module Fastlane
|
|
29
28
|
raise "Not Google Drive file" unless file.kind_of?(::GoogleDrive::File)
|
30
29
|
|
31
30
|
begin
|
32
|
-
file = file.upload_from_file(file_name, title)
|
31
|
+
file = file.upload_from_file(file_name, title, convert: false)
|
32
|
+
file
|
33
|
+
rescue Exception => e
|
34
|
+
UI.error(e.message)
|
35
|
+
UI.user_error!("Upload '#{file_name}' failed")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.create_subcollection(root_folder:, title:)
|
40
|
+
root_folder.create_subcollection(title)
|
41
|
+
rescue Exception => e
|
42
|
+
UI.error(e.message)
|
43
|
+
UI.user_error!("Create '#{title}' failed")
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.update_file(file: nil, file_name: nil)
|
47
|
+
raise "Not a Google Drive file" unless file.kind_of?(::GoogleDrive::File)
|
48
|
+
|
49
|
+
begin
|
50
|
+
file = file.update_from_file(file_name)
|
33
51
|
file
|
34
52
|
rescue Exception => e
|
35
53
|
UI.error(e.message)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-google_drive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bumsoo Kim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google_drive
|
@@ -16,14 +16,34 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.5
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
29
|
+
version: '3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.5
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: google-api-client
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.37.0
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.37.0
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: pry
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +162,14 @@ dependencies:
|
|
142
162
|
requirements:
|
143
163
|
- - ">="
|
144
164
|
- !ruby/object:Gem::Version
|
145
|
-
version: 2.
|
165
|
+
version: 2.140.0
|
146
166
|
type: :development
|
147
167
|
prerelease: false
|
148
168
|
version_requirements: !ruby/object:Gem::Requirement
|
149
169
|
requirements:
|
150
170
|
- - ">="
|
151
171
|
- !ruby/object:Gem::Version
|
152
|
-
version: 2.
|
172
|
+
version: 2.140.0
|
153
173
|
description:
|
154
174
|
email: bskim45@gmail.com
|
155
175
|
executables: []
|
@@ -159,7 +179,11 @@ files:
|
|
159
179
|
- LICENSE
|
160
180
|
- README.md
|
161
181
|
- lib/fastlane/plugin/google_drive.rb
|
182
|
+
- lib/fastlane/plugin/google_drive/actions/create_google_drive_folder_action.rb
|
162
183
|
- lib/fastlane/plugin/google_drive/actions/google_drive_upload_action.rb
|
184
|
+
- lib/fastlane/plugin/google_drive/actions/update_google_drive_file_action.rb
|
185
|
+
- lib/fastlane/plugin/google_drive/actions/upload_google_drive_action.rb
|
186
|
+
- lib/fastlane/plugin/google_drive/actions/upload_to_google_drive_action.rb
|
163
187
|
- lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb
|
164
188
|
- lib/fastlane/plugin/google_drive/version.rb
|
165
189
|
homepage: https://github.com/bskim45/fastlane-plugin-google_drive
|
@@ -181,8 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
205
|
- !ruby/object:Gem::Version
|
182
206
|
version: '0'
|
183
207
|
requirements: []
|
184
|
-
|
185
|
-
rubygems_version: 2.7.4
|
208
|
+
rubygems_version: 3.0.8
|
186
209
|
signing_key:
|
187
210
|
specification_version: 4
|
188
211
|
summary: Upload files to Google Drive
|