capistrano-fiesta 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/lib/capistrano/fiesta/draft.rb +23 -0
- data/lib/capistrano/fiesta/editor.rb +4 -4
- data/lib/capistrano/fiesta/github.rb +29 -0
- data/lib/capistrano/fiesta/logger.rb +15 -0
- data/lib/capistrano/fiesta/report.rb +39 -31
- data/lib/capistrano/fiesta/story.rb +8 -0
- data/lib/capistrano/fiesta/version.rb +1 -1
- data/lib/capistrano/tasks/fiesta.rake +15 -22
- data/lib/capistrano/templates/{fiesta.erb → draft.erb} +0 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8569d071a7d622c8c77e09c37a2004c1b2dda7f3
|
4
|
+
data.tar.gz: fc09af141ae0face70f402820bfde64239922b86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea945561cd5903e6873f09f674c791655ede9a14ec5605d93aee0076639c95806962b5c10e9bffef6d3cf15198364af5b7b652d2b306f0de36961b0bde7082cf
|
7
|
+
data.tar.gz: 1b1a5981d4a29bb94adf3825e6d1a68c26f03fbcc3ad3264496f1b656b8298d5439f9c1646da7671b45c99f9dc1a79ec4d13c194468787181c197c2f175f4381
|
data/.travis.yml
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
3
|
+
module Capistrano
|
4
|
+
module Fiesta
|
5
|
+
class Draft
|
6
|
+
attr_reader :comment, :stories
|
7
|
+
|
8
|
+
def initialize(comment:, stories: [])
|
9
|
+
@comment, @stories = comment, stories
|
10
|
+
end
|
11
|
+
|
12
|
+
def render
|
13
|
+
ERB.new(File.read(template), nil, '-').result(binding)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def template
|
19
|
+
File.join(File.expand_path('../../templates', __FILE__), 'draft.erb')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -7,9 +7,9 @@ module Capistrano
|
|
7
7
|
@content = content
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def edit
|
11
11
|
create_temp_file
|
12
|
-
|
12
|
+
open
|
13
13
|
read
|
14
14
|
end
|
15
15
|
|
@@ -20,8 +20,8 @@ module Capistrano
|
|
20
20
|
file.close
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def open
|
24
|
+
system(ENV["EDITOR"] || "vi", file.path)
|
25
25
|
end
|
26
26
|
|
27
27
|
def read
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "octokit"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module Capistrano
|
5
|
+
module Fiesta
|
6
|
+
class Github
|
7
|
+
def client
|
8
|
+
Octokit::Client.new(config)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def config
|
14
|
+
{ access_token: hub_config["oauth_token"] }
|
15
|
+
end
|
16
|
+
|
17
|
+
def hub_config_path
|
18
|
+
Dir.home + "/.config/hub"
|
19
|
+
end
|
20
|
+
|
21
|
+
def hub_config
|
22
|
+
YAML.load_file(hub_config_path)["github.com"].first
|
23
|
+
rescue Errno::ENOENT
|
24
|
+
Logger.warn "No github config found at #{hub_config_path}, using ENV defaults (https://github.com/octokit/octokit.rb/blob/master/lib/octokit/default.rb)"
|
25
|
+
{}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,47 +1,70 @@
|
|
1
1
|
Encoding.default_internal = Encoding.default_external = 'utf-8'
|
2
2
|
|
3
|
-
require "capistrano/fiesta/
|
3
|
+
require "capistrano/fiesta/github"
|
4
|
+
require "capistrano/fiesta/draft"
|
4
5
|
require "capistrano/fiesta/editor"
|
5
|
-
require "
|
6
|
-
require "
|
7
|
-
require "yaml"
|
6
|
+
require "capistrano/fiesta/logger"
|
7
|
+
require "capistrano/fiesta/story"
|
8
8
|
|
9
9
|
module Capistrano
|
10
10
|
module Fiesta
|
11
11
|
class Report
|
12
|
-
|
12
|
+
class << self
|
13
|
+
attr_accessor :chat_client
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :announcement
|
17
|
+
|
18
|
+
def self.create(*args)
|
19
|
+
report = new(*args)
|
20
|
+
report.save
|
21
|
+
report
|
22
|
+
end
|
13
23
|
|
14
24
|
def initialize(github_url, last_release: nil, comment: nil)
|
15
25
|
@github_url, @last_release, @comment = github_url, last_release, comment
|
16
|
-
@logs = []
|
17
26
|
end
|
18
27
|
|
19
|
-
def
|
20
|
-
editor.
|
28
|
+
def save
|
29
|
+
@announcement = editor.edit if stories.any?
|
21
30
|
end
|
22
31
|
|
23
32
|
def stories
|
24
33
|
@stories ||= merged_pull_requests.map { |pr| Story.new(pr) }
|
25
34
|
end
|
26
35
|
|
36
|
+
def announce(channel: 'releases', **options)
|
37
|
+
return Logger.warn 'Announcement blank, nothing posted to Slack' unless announcement?
|
38
|
+
options[:payload] = { channel: channel, username: 'New Releases', icon_emoji: ':tada:', text: announcement }
|
39
|
+
chat.post(options)
|
40
|
+
rescue NameError
|
41
|
+
Logger.warn "Install Slackistrano to announce releases on Slack"
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_release(name = nil)
|
45
|
+
return Logger.warn 'No new stories, skipping GitHub release' if stories.none?
|
46
|
+
name ||= Time.now.to_i.to_s
|
47
|
+
github.create_release(repo, "release-#{name}", name: name, body: stories.map(&:to_markdown).join("\n"))
|
48
|
+
end
|
49
|
+
|
27
50
|
private
|
28
51
|
|
29
52
|
def editor
|
30
|
-
Editor.new(draft)
|
53
|
+
Editor.new(draft.render)
|
31
54
|
end
|
32
55
|
|
33
56
|
def draft
|
34
|
-
|
57
|
+
Draft.new(comment: @comment, stories: stories)
|
35
58
|
end
|
36
59
|
|
37
|
-
def
|
38
|
-
|
60
|
+
def announcement?
|
61
|
+
announcement && !announcement.empty?
|
39
62
|
end
|
40
63
|
|
41
64
|
def merged_pull_requests
|
42
65
|
github.search_issues("base:master repo:#{repo} merged:>#{last_released_at}").items
|
43
66
|
rescue Octokit::UnprocessableEntity => e
|
44
|
-
|
67
|
+
Logger.warn "Unable to access GitHub. Message given was: #{e.message}"
|
45
68
|
[]
|
46
69
|
end
|
47
70
|
|
@@ -54,26 +77,11 @@ module Capistrano
|
|
54
77
|
end
|
55
78
|
|
56
79
|
def github
|
57
|
-
@github ||=
|
58
|
-
end
|
59
|
-
|
60
|
-
def config
|
61
|
-
{ access_token: hub_config["oauth_token"] }
|
62
|
-
end
|
63
|
-
|
64
|
-
def hub_config_path
|
65
|
-
Dir.home + "/.config/hub"
|
66
|
-
end
|
67
|
-
|
68
|
-
def hub_config
|
69
|
-
YAML.load_file(hub_config_path)["github.com"].first
|
70
|
-
rescue Errno::ENOENT
|
71
|
-
log "No github config found at #{hub_config_path}, using ENV defaults (https://github.com/octokit/octokit.rb/blob/master/lib/octokit/default.rb)"
|
72
|
-
{}
|
80
|
+
@github ||= Github.new.client
|
73
81
|
end
|
74
82
|
|
75
|
-
def
|
76
|
-
|
83
|
+
def chat
|
84
|
+
self.class.chat_client || Slackistrano
|
77
85
|
end
|
78
86
|
end
|
79
87
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
1
|
namespace :fiesta do
|
3
|
-
desc 'Generate a release report
|
2
|
+
desc 'Generate a release report and post it on Slack'
|
4
3
|
task :report do
|
5
4
|
invoke 'fiesta:set_last_release'
|
6
5
|
invoke 'fiesta:generate'
|
@@ -16,28 +15,22 @@ namespace :fiesta do
|
|
16
15
|
|
17
16
|
task :generate do
|
18
17
|
run_locally do
|
19
|
-
|
20
|
-
report
|
21
|
-
|
22
|
-
|
23
|
-
if result && !result.empty?
|
24
|
-
Slackistrano.post(
|
25
|
-
team: fetch(:slack_team),
|
26
|
-
token: fetch(:slack_token),
|
27
|
-
webhook: fetch(:slack_webhook),
|
28
|
-
via_slackbot: fetch(:slack_via_slackbot),
|
29
|
-
payload: {
|
30
|
-
channel: fetch(:fiesta_slack_channel),
|
31
|
-
username: 'New Releases',
|
32
|
-
icon_emoji: ':tada:',
|
33
|
-
text: result
|
34
|
-
}
|
35
|
-
)
|
36
|
-
else
|
37
|
-
report.logs.each { |log| warn log }
|
38
|
-
end
|
18
|
+
report = Capistrano::Fiesta::Report.create(repo_url, last_release: fetch(:last_release), comment: fetch(:fiesta_comment))
|
19
|
+
report.announce(slack)
|
20
|
+
report.create_release(fetch(:release_name)) if fetch(:branch) == 'master'
|
21
|
+
Capistrano::Fiesta::Logger.logs.each { |log| warn log }
|
39
22
|
end
|
40
23
|
end
|
24
|
+
|
25
|
+
def slack
|
26
|
+
{
|
27
|
+
team: fetch(:slack_team),
|
28
|
+
token: fetch(:slack_token),
|
29
|
+
webhook: fetch(:slack_webhook),
|
30
|
+
via_slackbot: fetch(:slack_via_slackbot),
|
31
|
+
channel: fetch(:fiesta_slack_channel)
|
32
|
+
}
|
33
|
+
end
|
41
34
|
end
|
42
35
|
|
43
36
|
before 'deploy:starting', 'fiesta:set_last_release'
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-fiesta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Balvig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -169,12 +169,15 @@ files:
|
|
169
169
|
- capistrano-fiesta.gemspec
|
170
170
|
- lib/capistrano-fiesta.rb
|
171
171
|
- lib/capistrano/fiesta.rb
|
172
|
+
- lib/capistrano/fiesta/draft.rb
|
172
173
|
- lib/capistrano/fiesta/editor.rb
|
174
|
+
- lib/capistrano/fiesta/github.rb
|
175
|
+
- lib/capistrano/fiesta/logger.rb
|
173
176
|
- lib/capistrano/fiesta/report.rb
|
174
177
|
- lib/capistrano/fiesta/story.rb
|
175
178
|
- lib/capistrano/fiesta/version.rb
|
176
179
|
- lib/capistrano/tasks/fiesta.rake
|
177
|
-
- lib/capistrano/templates/
|
180
|
+
- lib/capistrano/templates/draft.erb
|
178
181
|
homepage: https://github.com/balvig/capistrano-fiesta
|
179
182
|
licenses:
|
180
183
|
- MIT
|