capistrano-github-releases 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c039113c72bc7bd53910a0972e31e6e8dd2d8b6d
4
- data.tar.gz: 5b9987290f4d22c063862a75d20a26b0986f98b1
3
+ metadata.gz: b99ef94f18f7f29ffa32bd6e7185c1430e0e9f13
4
+ data.tar.gz: a2d39e1eaa10283d3966d2b69a43e7901e990c5f
5
5
  SHA512:
6
- metadata.gz: a7167d91088eb9473ed46b13e48d90fc57f0c6ca021009698dd982486ced0c442312524dfed762cf25e88aa6305e2ac7c53ade38787ae9b247a32a4352ffb72b
7
- data.tar.gz: 7907ed41515ab6faf811f82029eb4339d7e23362188276037ecf69e55194385ae3d554e688688567919cf0f2683e98e3e7171cc1d0a04f076241d0915df152d1
6
+ metadata.gz: 6459d3c0006701494e17823d5ed54a00fc9201f374649de1f46f88dbe782bfd05301e5528c3a428f482891774899515bed3ce7a5f891d4b044412ef015396cd6
7
+ data.tar.gz: edfc97f6516ac0c220e0b6244dd1f612876a273d9370f9a1b5e3f80a4427b6ad0523b85129c26473e3f33275dddd17e9fcd547a102139a32d29b45c160e4d50d
data/README.md CHANGED
@@ -1,25 +1,36 @@
1
- Capistrano::Github::Releases
2
- ============================
1
+ Capistrano Github-Releases
2
+ ==========================
3
+
4
+ GitHub Releases tasks for Capistrano v3:
5
+
6
+ ```sh
7
+ $ bundle exec cap production github:releases:create # Auto creation by last pull-request
8
+ $ bundle exec cap production github:releases:add_comment # Auto comment to last pull-request
9
+ ```
3
10
 
4
11
  [![Gem Version](https://badge.fury.io/rb/capistrano-github-releases.png)][gem]
5
12
  [gem]: https://rubygems.org/gems/capistrano-github-releases
6
13
 
7
- GitHub Releases tasks for Capistrano v3:
8
-
9
14
  Installation
10
15
  ------------
11
16
 
12
17
  Add this line to your application's Gemfile:
13
18
 
14
- gem 'capistrano-github-releases'
19
+ ```ruby
20
+ gem 'capistrano-github-releases'
21
+ ```
15
22
 
16
23
  And then execute:
17
24
 
18
- $ bundle
25
+ ```sh
26
+ $ bundle
27
+ ```
19
28
 
20
29
  Or install it yourself as:
21
30
 
22
- $ gem install capistrano-github-releases
31
+ ```sh
32
+ $ gem install capistrano-github-releases
33
+ ```
23
34
 
24
35
  Usage
25
36
  -----
@@ -33,16 +44,45 @@ require 'capistrano/github/releases'
33
44
  deploy/production.rb:
34
45
 
35
46
  ```ruby
36
- after 'deploy:published', 'github:releases:create'
37
- after 'deploy:published', 'github:releases:add_comment'
47
+ after 'deploy:finishing', 'github:releases:create'
48
+ after 'deploy:finishing', 'github:releases:add_comment'
38
49
  ```
39
50
 
51
+ ### Options
52
+
53
+ Set capistrano variables with `set name, value`.
54
+
55
+ Name | Default | Description
56
+ ---- | ------- | -----------
57
+ release_tag | `Time.now.strftime('release-%Y%m%d-%H%M')` | Create releases when git-tag name
58
+ release_comment | This pull-request deployed to production and ... | Pull requests to deploy report comment
59
+
60
+ ### GitHub Enterprise
61
+
62
+ deploy.rb:
63
+
64
+ ```ruby
65
+ Octokit.configure do |c|
66
+ c.api_endpoint = 'http://your.enterprise.domain/api/v3'
67
+ c.web_endpoint = 'http://your.enterprise.domain/'
68
+ end
69
+ ```
40
70
 
41
71
  Contributing
42
72
  ------------
43
73
 
44
- 1. Fork it ( http://github.com/<my-github-username>/capistrano-github-releases/fork )
74
+ 1. Fork it ( http://github.com/linyows/capistrano-github-releases/fork )
45
75
  2. Create your feature branch (`git checkout -b my-new-feature`)
46
76
  3. Commit your changes (`git commit -am 'Add some feature'`)
47
77
  4. Push to the branch (`git push origin my-new-feature`)
48
78
  5. Create new Pull Request
79
+
80
+ Authors
81
+ -------
82
+
83
+ - [linyows](https://github.com/linyows)
84
+
85
+ License
86
+ -------
87
+
88
+ The MIT License (MIT)
@@ -1,7 +1,7 @@
1
1
  module Capistrano
2
2
  module Github
3
3
  module Releases
4
- VERSION = "0.0.1"
4
+ VERSION = '0.1.0'
5
5
  end
6
6
  end
7
7
  end
@@ -22,6 +22,10 @@ namespace :github do
22
22
  username
23
23
  }
24
24
 
25
+ set :release_tag, -> {
26
+ Time.now.strftime('release-%Y%m%d-%H%M')
27
+ }
28
+
25
29
  set :github_username, -> {
26
30
  if ENV['GITHUB_USERNAME'].nil?
27
31
  username = HighLine.new.ask("GitHub Username? [default: #{fetch(:username)}]")
@@ -32,13 +36,18 @@ namespace :github do
32
36
  }
33
37
 
34
38
  set :release_title, -> {
35
- begin
36
- pull_request = Octokit.pull(fetch(:github_repo), fetch(:pull_request_id))
37
- default_title = pull_request.title
38
- rescue => e
39
- puts e
40
- default_title = fetch(:release_tag)
39
+ default_title = nil
40
+
41
+ run_locally do
42
+ begin
43
+ pull_request = Octokit.pull(fetch(:github_repo), fetch(:pull_request_id))
44
+ default_title = pull_request.title
45
+ rescue => e
46
+ error e.message
47
+ default_title = fetch(:release_tag)
48
+ end
41
49
  end
50
+
42
51
  title = HighLine.new.ask("Release Title? [default: #{default_title}]")
43
52
  title = default_title if title.empty?
44
53
  title
@@ -50,17 +59,20 @@ namespace :github do
50
59
  "#{body + "\n" unless body.empty?}#{pull_req}"
51
60
  }
52
61
 
53
- set :release_tag, -> {
54
- Time.now.strftime('release-%Y%m%d-%H%M')
55
- }
56
-
57
62
  set :pull_request_id, -> {
58
- merge_comment = `git log | grep 'Merge pull request' | head -n 1`
59
- merge_comment.match(/#(\d+)/)[1].to_i
63
+ id = nil
64
+
65
+ run_locally do
66
+ merge_comment = capture "git log | grep 'Merge pull request' | head -n 1"
67
+ id = merge_comment.match(/#(\d+)/)[1].to_i
68
+ end
69
+
70
+ id
60
71
  }
61
72
 
62
73
  set :release_comment, -> {
63
74
  url = "#{fetch(:github_releases_path)}/#{fetch(:release_tag)}"
75
+
64
76
  <<-MD.gsub(/^ {6}/, '').strip
65
77
  I deployed this with production environment and created a release tag. :octocat:
66
78
  #{fetch(:release_title)}: [#{fetch(:release_tag)}](#{url})
@@ -85,56 +97,72 @@ namespace :github do
85
97
  "#{Octokit.web_endpoint}#{fetch(:github_repo)}/releases/tag"
86
98
  }
87
99
 
88
- set :github_authentication, -> {
89
- Octokit.configure do |c|
90
- c.login = fetch(:github_username)
91
- c.access_token = fetch(:github_token)
100
+ desc 'GitHub authentication'
101
+ task :authentication do
102
+ run_locally do
103
+ begin
104
+ Octokit.configure do |c|
105
+ c.login = fetch(:github_username)
106
+ c.access_token = fetch(:github_token)
107
+ end
108
+
109
+ rate_limit = Octokit.rate_limit
110
+ info 'Exceeded limit of the GitHub API request' if rate_limit.remaining.zero?
111
+ debug "#{rate_limit}"
112
+ rescue Octokit::NotFound
113
+ # No rate limit for white listed users
114
+ rescue => e
115
+ error e.message
116
+ end
92
117
  end
93
- }
118
+ end
94
119
 
95
- desc 'Create new release note.'
96
- task :create do
97
- begin
98
- fetch(:github_authentication)
99
-
100
- Octokit.create_release(
101
- fetch(:github_repo),
102
- fetch(:release_tag),
103
- name: fetch(:release_title),
104
- body: fetch(:release_body),
105
- target_commitish: 'master',
106
- draft: false,
107
- prerelease: false
108
- )
109
- rescue => e
110
- puts e
111
- invoke 'github:git:create_tag_and_push_origin'
120
+ desc 'Create new release note'
121
+ task create: :authentication do
122
+ run_locally do
123
+ begin
124
+ Octokit.create_release(
125
+ fetch(:github_repo),
126
+ fetch(:release_tag),
127
+ name: fetch(:release_title),
128
+ body: fetch(:release_body),
129
+ target_commitish: 'master',
130
+ draft: false,
131
+ prerelease: false
132
+ )
133
+ rescue => e
134
+ error e.message
135
+ invoke 'github:git:create_tag_and_push_origin'
136
+ end
112
137
  end
113
138
  end
114
139
 
115
- desc 'Add comment for new release.'
116
- task :add_comment do
117
- begin
118
- fetch(:github_authentication)
119
-
120
- Octokit.add_comment(
121
- fetch(:github_repo),
122
- fetch(:pull_request_id),
123
- fetch(:release_comment)
124
- )
125
- rescue => e
126
- puts e
140
+ desc 'Add comment for new release'
141
+ task add_comment: :authentication do
142
+ run_locally do
143
+ begin
144
+ Octokit.add_comment(
145
+ fetch(:github_repo),
146
+ fetch(:pull_request_id),
147
+ fetch(:release_comment)
148
+ )
149
+ rescue => e
150
+ error e.message
151
+ end
127
152
  end
128
153
  end
129
154
  end
130
155
 
131
156
  namespace :git do
132
- desc 'Create tag for new release and push to origin.'
157
+ desc 'Create tag for new release and push to origin'
133
158
  task :create_tag_and_push_origin do
134
159
  message = "#{fetch(:release_title)} by #{fetch(:username)}\n"
135
160
  message += "#{fetch(:github_repo)}##{fetch(:pull_request_id)}"
136
- `git tag -am "#{message}" #{fetch(:release_tag)}`
137
- `git push origin #{fetch(:release_tag)}`
161
+
162
+ run_locally do
163
+ execute :git, :tag, '-am', "#{message}", "#{fetch(:release_tag)}"
164
+ execute :git, :push, :origin, "#{fetch(:release_tag)}"
165
+ end
138
166
  end
139
167
  end
140
168
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-github-releases
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - linyows
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-24 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano