fastlane-plugin-slack_upload 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +84 -0
- data/lib/fastlane/plugin/slack_upload.rb +16 -0
- data/lib/fastlane/plugin/slack_upload/actions/slack_upload_action.rb +111 -0
- data/lib/fastlane/plugin/slack_upload/helper/slack_upload_helper.rb +16 -0
- data/lib/fastlane/plugin/slack_upload/version.rb +5 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 98fa51f89907a53168f8c2a7f70b2fd96b3bce79a0db66953b9efbe5a14f7f0e
|
4
|
+
data.tar.gz: 7359277a1387186d6622483e075c96430e775c2b4c2b35acdec27385dcb4b98b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fec1ed1fc1db2e60ea8d85d779d8c15ef8fb364e25744cc3253e0e7d05cd48bb415906e6d26a9935a47146cef54bedcd2063848fbb5565a1b6da95949854bd55
|
7
|
+
data.tar.gz: 07ca1f726f73128c03f472d45cc91cd6a0005dc296415ea61688ae56681304d6c5cca3699073809f2a26f914215b6eb957bc0f555be3ed806da2dc37ef180ee2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Dawid Cieslak <cieslakdawid@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.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# slack_upload plugin
|
2
|
+
|
3
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-slack_upload)
|
4
|
+
|
5
|
+
|
6
|
+
This plugin simply uploads a given file to your Slack.
|
7
|
+
|
8
|
+
Sometimes as part of CI builds you want to generate some files from the project that might be valuable for your team. You can think about documentation or screenshots of the application on different devices. With `slack_uplaod` it's easy to send them to dedicated `Slack` channel or directly to your teammates.
|
9
|
+
|
10
|
+
Note: `Fastlane` comes with `slack` plugin by default, although it uses `slack-notifier` API that doesn't support uploading files.
|
11
|
+
|
12
|
+
## Getting Started
|
13
|
+
|
14
|
+
1. Generate `Slack token` for `Fastlane` bot
|
15
|
+
- From your Slack organization page, go to `Manage` -> `Custom Integrations`
|
16
|
+
- Open `Bots`
|
17
|
+
- Add Configuration
|
18
|
+
- Choose a name for your bot, e.g. `"fastlane"`
|
19
|
+
- Save `API Token`
|
20
|
+
|
21
|
+
2. Add plugin to `fastlane`
|
22
|
+
|
23
|
+
```bash
|
24
|
+
fastlane add_plugin slack_upload
|
25
|
+
```
|
26
|
+
|
27
|
+
3. Add `slack_upload` to your lane in `Fastfile` whenever you want to upload the file
|
28
|
+
|
29
|
+
In the following example we generate screenshots ([More info](https://docs.fastlane.tools/getting-started/ios/screenshots/)) and send them to `#general` channel
|
30
|
+
|
31
|
+
```bash
|
32
|
+
lane :screenshots_lane do
|
33
|
+
|
34
|
+
version = get_version_number
|
35
|
+
|
36
|
+
# Generate screenshots
|
37
|
+
capture_screenshots
|
38
|
+
|
39
|
+
# Zip screenshots folder
|
40
|
+
zip(
|
41
|
+
path: "./fastlane/screenshots",
|
42
|
+
output_path: "./fastlane/screenshots.zip"
|
43
|
+
)
|
44
|
+
|
45
|
+
# Upload to slack
|
46
|
+
slack_upload(
|
47
|
+
slack_api_token: "xyz", # Preferably configure as ENV['SLACK_API_TOKEN']
|
48
|
+
title: "New version #{version} is available ",
|
49
|
+
channel: "#general",
|
50
|
+
file_path: "./fastlane/screenshots.zip",
|
51
|
+
initial_comment: "Changelog goes here"
|
52
|
+
)
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
|
57
|
+
## Run tests for this plugin
|
58
|
+
|
59
|
+
To run both the tests, and code style validation, run
|
60
|
+
|
61
|
+
```
|
62
|
+
rake
|
63
|
+
```
|
64
|
+
|
65
|
+
To automatically fix many of the styling issues, use
|
66
|
+
```
|
67
|
+
rubocop -a
|
68
|
+
```
|
69
|
+
|
70
|
+
## Issues and Feedback
|
71
|
+
|
72
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
73
|
+
|
74
|
+
## Troubleshooting
|
75
|
+
|
76
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
77
|
+
|
78
|
+
## Using _fastlane_ Plugins
|
79
|
+
|
80
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
81
|
+
|
82
|
+
## About _fastlane_
|
83
|
+
|
84
|
+
_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,16 @@
|
|
1
|
+
require 'fastlane/plugin/slack_upload/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module SlackUpload
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::SlackUpload.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
|
2
|
+
module Fastlane
|
3
|
+
module Actions
|
4
|
+
class SlackUploadAction < Action
|
5
|
+
def self.run(params)
|
6
|
+
require 'slack-ruby-client'
|
7
|
+
|
8
|
+
title = params[:title]
|
9
|
+
filepath = params[:file_path]
|
10
|
+
filename = params[:file_name]
|
11
|
+
initialComment = params[:initial_comment]
|
12
|
+
|
13
|
+
if params[:channel].to_s.length > 0 # From `slack` plugin implementation: https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/actions/slack.rb
|
14
|
+
channel = params[:channel]
|
15
|
+
channel = ('#' + params[:channel]) unless ['#', '@'].include?(channel[0]) # send message to channel by default
|
16
|
+
end
|
17
|
+
|
18
|
+
if params[:file_type].to_s.empty?
|
19
|
+
filetype = File.extname(filepath)[1..-1] # Remove '.' from the file extension
|
20
|
+
else
|
21
|
+
filetype = params[:file_type]
|
22
|
+
end
|
23
|
+
|
24
|
+
Slack.configure do |config|
|
25
|
+
config.token = params[:slack_api_token]
|
26
|
+
end
|
27
|
+
|
28
|
+
client = Slack::Web::Client.new
|
29
|
+
|
30
|
+
begin
|
31
|
+
results = client.files_upload(
|
32
|
+
channels: channel,
|
33
|
+
as_user: true,
|
34
|
+
file: Faraday::UploadIO.new(filepath, filetype),
|
35
|
+
title: title,
|
36
|
+
filename: filename,
|
37
|
+
initial_comment: initialComment
|
38
|
+
)
|
39
|
+
rescue => exception
|
40
|
+
UI.error("Exception: #{exception}")
|
41
|
+
ensure
|
42
|
+
UI.success('Successfully sent file to Slack')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.available_options
|
47
|
+
[
|
48
|
+
FastlaneCore::ConfigItem.new(key: :slack_api_token,
|
49
|
+
env_name: "SLACK_API_TOKEN",
|
50
|
+
sensitive: true,
|
51
|
+
description: "Slack API token"),
|
52
|
+
FastlaneCore::ConfigItem.new(key: :title,
|
53
|
+
env_name: "SLACK_UPLOAD_TITLE",
|
54
|
+
description: "Title of the file",
|
55
|
+
optional: false),
|
56
|
+
FastlaneCore::ConfigItem.new(key: :channel,
|
57
|
+
env_name: "SLACK_UPLOAD_CHANNEL",
|
58
|
+
description: "#channel or @username",
|
59
|
+
optional: false),
|
60
|
+
FastlaneCore::ConfigItem.new(key: :file_path,
|
61
|
+
env_name: "SLACK_UPLOAD_FILE_PATH",
|
62
|
+
description: "Path to the file",
|
63
|
+
optional: false),
|
64
|
+
FastlaneCore::ConfigItem.new(key: :file_type,
|
65
|
+
env_name: "SLACK_UPLOAD_FILE_TYPE",
|
66
|
+
description: "A file type identifier",
|
67
|
+
optional: true),
|
68
|
+
FastlaneCore::ConfigItem.new(key: :file_name,
|
69
|
+
env_name: "SLACK_UPLOAD_FILE_NAME",
|
70
|
+
description: "Filename of file",
|
71
|
+
optional: true),
|
72
|
+
FastlaneCore::ConfigItem.new(key: :initial_comment,
|
73
|
+
env_name: "SLACK_UPLOAD_INITIAL_COMMENT",
|
74
|
+
description: "Initial comment to add to file",
|
75
|
+
optional: true)
|
76
|
+
]
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.is_supported?(platform)
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.description
|
84
|
+
'Uploads given file to Slack'
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.authors
|
88
|
+
['Dawid Cieslak']
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.example_code
|
92
|
+
[
|
93
|
+
'slack_upload(
|
94
|
+
title: "New version #{version} is available ",
|
95
|
+
channel: "#general",
|
96
|
+
file_path: "./screenshots.zip"
|
97
|
+
)',
|
98
|
+
'slack_upload(
|
99
|
+
slack_api_token: "xyz",
|
100
|
+
title: "New version #{version} is available ",
|
101
|
+
channel: "#general",
|
102
|
+
file_path: "./screenshots.zip",
|
103
|
+
file_type: "zip", # Optional, type can be recognized from file path,
|
104
|
+
file_name: "screen_shots.zip", # Optional, name can be recognized from file path,
|
105
|
+
initial_comment: "Enjoy!" # Optional
|
106
|
+
)'
|
107
|
+
]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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 SlackUploadHelper
|
8
|
+
# class methods that you define here become available in your action
|
9
|
+
# as `Helper::SlackUploadHelper.your_method`
|
10
|
+
#
|
11
|
+
def self.show_message
|
12
|
+
UI.message("Hello from the slack_upload plugin helper!")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-slack_upload
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dawid Cieslak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: slack-ruby-client
|
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: rspec_junit_formatter
|
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: rake
|
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: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.55'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.55'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-require_tools
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: fastlane
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 2.97.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 2.97.0
|
153
|
+
description:
|
154
|
+
email: cieslakdawid@gmail.com
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- LICENSE
|
160
|
+
- README.md
|
161
|
+
- lib/fastlane/plugin/slack_upload.rb
|
162
|
+
- lib/fastlane/plugin/slack_upload/actions/slack_upload_action.rb
|
163
|
+
- lib/fastlane/plugin/slack_upload/helper/slack_upload_helper.rb
|
164
|
+
- lib/fastlane/plugin/slack_upload/version.rb
|
165
|
+
homepage: https://github.com/cieslakdawid/fastlane-plugin-slack_upload
|
166
|
+
licenses:
|
167
|
+
- MIT
|
168
|
+
metadata: {}
|
169
|
+
post_install_message:
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
requirements: []
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 2.7.7
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: Uploads specified file to Slack
|
189
|
+
test_files: []
|