heroku_release 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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- heroku_release (0.0.1)
4
+ heroku_release (0.1.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Heroku Deploy
1
+ = Heroku Release
2
2
 
3
3
  Simple RubyGem for tagging and deploying versioned releases of an application to Heroku with the ability to do rollbacks.
4
4
 
@@ -7,33 +7,34 @@ Simple RubyGem for tagging and deploying versioned releases of an application to
7
7
  If you are using Bundler, add a gem dependency like this:
8
8
 
9
9
  group :development, :test do
10
- gem 'heroku_deploy', '~> version known to work'
10
+ gem 'heroku_release', '~> version known to work'
11
11
  end
12
12
 
13
13
  Require the Rake tasks in your Rakefile:
14
14
 
15
- require 'heroku_deploy/tasks'
15
+ require 'heroku_release/tasks'
16
16
 
17
- You have a few configuration options. If you are using a Git remote other than "heroku" then you must configure that. You can choose to have the release version written to a file on deploy so you can check the version on the live server. Here is an example:
17
+ You have a few configuration options. If you are using a Git remote other than "heroku" then you must configure that. You can choose to have the release version written to a file on deploy so you can check the version on the live server. You can also choose to have a CHANGELOG file auto-generated. Here is a configuration example:
18
18
 
19
- HerokuDeploy.config.heroku_remote = "production" # git remote for heroku, defaults to "heroku"
20
- HerokuDeploy.config.version_file_path = "public/version"
19
+ HerokuRelease.config.heroku_remote = "production" # git remote for heroku, defaults to "heroku"
20
+ HerokuRelease.config.version_file_path = "public/version" # if not set no version file will be generated
21
+ HerokuRelease.config.changelog_path = "CHANGELOG" # if not set no changelog file will be generated
21
22
 
22
- To deploy the master branch to production, use the heroku_deploy rake task:
23
+ To deploy the master branch to production, use the heroku_release rake task:
23
24
 
24
- rake heroku_deploy COMMENT="This is a comment describing what changed since the last release"
25
+ rake heroku_release COMMENT="This is a comment describing what changed since the last release"
25
26
 
26
27
  If the deploy went horribly wrong and you need to do a rollback you can do so:
27
28
 
28
- rake heroku_deploy:rollback
29
+ rake heroku_release:rollback
29
30
 
30
31
  In order to see the changelog:
31
32
 
32
- rake heroku_deploy:log
33
+ rake heroku_release:log
33
34
 
34
35
  To examine git commits since the last release you can do:
35
36
 
36
- rake heroku_deploy:pending
37
+ rake heroku_release:pending
37
38
 
38
39
  == TODO
39
40
 
@@ -1 +1,2 @@
1
+ require 'heroku_release'
1
2
  Dir[File.join(File.dirname(__FILE__), "..", "tasks", "*.rake")].each { |rake_file| load rake_file }
@@ -1,3 +1,3 @@
1
1
  module HerokuRelease
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -39,13 +39,11 @@ module HerokuRelease
39
39
  execute "git tag -a #{release_name} -m '#{comment}'"
40
40
  execute "git push --tags origin"
41
41
  execute "git push --tags #{config.heroku_remote}"
42
+ commit_changelog if config.changelog_path
42
43
  end
43
44
 
44
45
  def log
45
- change_log = git_tags_with_comments.scan(/^\s*(release-\d+-\d+)\s*(.+)$/).reverse.map do |release, comment|
46
- "- #{release}\n\n#{comment}\n\n"
47
- end.join
48
- output "\n" + change_log
46
+ output("\n" + changelog)
49
47
  end
50
48
 
51
49
  def current_release
@@ -116,6 +114,24 @@ module HerokuRelease
116
114
  execute "git push origin master"
117
115
  end
118
116
 
117
+ def commit_changelog
118
+ output "Committing #{config.changelog_path}"
119
+ File.open(config.changelog_path, "w") { |f| f.print(changelog_warning + changelog) }
120
+ execute "git add #{config.changelog_path}"
121
+ execute "git commit -m 'Updated #{config.changelog_path}'"
122
+ execute "git push origin master"
123
+ end
124
+
125
+ def changelog_warning
126
+ "# NOTE: this file is autogenerated by the heroku_release gem - do not hand edit"
127
+ end
128
+
129
+ def changelog
130
+ git_tags_with_comments.scan(/^\s*(release-\d+-\d+)\s*(.+)$/).reverse.map do |release, comment|
131
+ "- #{release}\n\n#{comment}\n\n"
132
+ end.join
133
+ end
134
+
119
135
  def get_release_name
120
136
  "release-#{Time.now.utc.strftime("%Y%m%d-%H%M%S")}"
121
137
  end
@@ -27,6 +27,15 @@ describe HerokuRelease do
27
27
  config.version_file_path = "public/system/version"
28
28
  config.version_file_path.should == "public/system/version"
29
29
  end
30
+
31
+ it "defaults changelog_path to nil" do
32
+ config.changelog_path.should be_nil
33
+ end
34
+
35
+ it "can set changelog_path" do
36
+ config.changelog_path = "CHANGELOG"
37
+ config.changelog_path.should == "CHANGELOG"
38
+ end
30
39
  end
31
40
 
32
41
  def config
data/spec/task_spec.rb CHANGED
@@ -38,10 +38,7 @@ describe HerokuRelease::Task do
38
38
  ENV['COMMENT'] = "the comment"
39
39
  @task.expects(:get_release_name).returns("release-123")
40
40
  @task.expects(:commit_version_file).never
41
- git = sequence('git')
42
- @task.expects(:execute).with("git tag -a release-123 -m 'the comment'").in_sequence(git)
43
- @task.expects(:execute).with("git push --tags origin").in_sequence(git)
44
- @task.expects(:execute).with("git push --tags #{@config.heroku_remote}").in_sequence(git)
41
+ expect_tag_created("release-123", "the comment")
45
42
 
46
43
  @task.tag
47
44
  end
@@ -51,13 +48,27 @@ describe HerokuRelease::Task do
51
48
  @config.version_file_path = "public/version"
52
49
  @task.expects(:get_release_name).returns("release-123")
53
50
  @task.expects(:commit_version_file).with("release-123")
54
- git = sequence('git')
55
- @task.expects(:execute).with("git tag -a release-123 -m 'Tagged release'").in_sequence(git)
56
- @task.expects(:execute).with("git push --tags origin").in_sequence(git)
57
- @task.expects(:execute).with("git push --tags #{@config.heroku_remote}").in_sequence(git)
51
+ expect_tag_created("release-123")
58
52
 
59
53
  @task.tag
60
54
  end
55
+
56
+ it "commits changelog if changelog_path is set" do
57
+ @config.changelog_path = "spec/CHANGELOG"
58
+ @task.expects(:get_release_name).returns("release-123")
59
+ @task.expects(:commit_version_file).never
60
+ @task.expects(:commit_changelog)
61
+ expect_tag_created("release-123")
62
+
63
+ @task.tag
64
+ end
65
+
66
+ def expect_tag_created(release_name, comment = "Tagged release")
67
+ git = sequence('git')
68
+ @task.expects(:execute).with("git tag -a #{release_name} -m '#{comment}'").in_sequence(git)
69
+ @task.expects(:execute).with("git push --tags origin").in_sequence(git)
70
+ @task.expects(:execute).with("git push --tags #{@config.heroku_remote}").in_sequence(git)
71
+ end
61
72
  end
62
73
 
63
74
  describe "log" do
@@ -205,4 +216,23 @@ release-20100926-173016
205
216
  @task.send(:git_tags)
206
217
  end
207
218
  end
219
+
220
+ describe "commit_changelog" do
221
+ after(:each) do
222
+ FileUtils.rm_f(@config.changelog_path)
223
+ end
224
+
225
+ it "writes changelog to changelog_path and commits it" do
226
+ @config.changelog_path = "spec/CHANGELOG"
227
+ @task.expects(:changelog).returns("the changelog")
228
+ git = sequence('git')
229
+ @task.expects(:execute).with("git add #{@config.changelog_path}").in_sequence(git)
230
+ @task.expects(:execute).with("git commit -m 'Updated #{@config.changelog_path}'").in_sequence(git)
231
+ @task.expects(:execute).with("git push origin master").in_sequence(git)
232
+
233
+ @task.send(:commit_changelog)
234
+
235
+ File.read(@config.changelog_path).should == (@task.send(:changelog_warning) + "the changelog")
236
+ end
237
+ end
208
238
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 0
8
7
  - 1
9
- version: 0.0.1
8
+ - 0
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Peter Marklund
@@ -84,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - ">="
86
86
  - !ruby/object:Gem::Version
87
- hash: 746099489
87
+ hash: 318810159
88
88
  segments:
89
89
  - 0
90
90
  version: "0"
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- hash: 746099489
96
+ hash: 318810159
97
97
  segments:
98
98
  - 0
99
99
  version: "0"