aufgaben 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +106 -0
- data/LICENSE +21 -0
- data/README.md +121 -0
- data/lib/aufgaben.rb +5 -0
- data/lib/aufgaben/base.rb +21 -0
- data/lib/aufgaben/bump.rb +4 -0
- data/lib/aufgaben/bump/base.rb +105 -0
- data/lib/aufgaben/bump/nodejs.rb +50 -0
- data/lib/aufgaben/bump/ruby.rb +48 -0
- data/lib/aufgaben/color.rb +19 -0
- data/lib/aufgaben/release.rb +192 -0
- data/lib/aufgaben/version.rb +3 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7ffd158f88ddb4ddeb8f37c3ec2035aecdc060b49b3ff071503bdbc88e9758c1
|
4
|
+
data.tar.gz: '019fee060bb762bb4bc11398da74475070128ffd287fca8a980c69713f9c0c57'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4d2903b58e2d9be8e530710bb8eee38afe9f449dda92af75268626b4537fd7303028b7f3db8bae2d2da8e252cd40ce52ccd6d303f996a83275bcdaad2a3ec41e
|
7
|
+
data.tar.gz: 8e7c9784d66ba273f887b84c7ca6f3b09cad80b106e9db9380e802e3ed694d5622d95ed01f74587290eae50e356536575e6df1296f45dc42d5b23984cea470fc
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
## Unreleased
|
6
|
+
|
7
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.8.2...HEAD)
|
8
|
+
|
9
|
+
## 0.8.2
|
10
|
+
|
11
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.8.1...0.8.2)
|
12
|
+
|
13
|
+
- Retry releasing [#42](https://github.com/ybiquitous/aufgaben/pull/42)
|
14
|
+
|
15
|
+
## 0.8.1
|
16
|
+
|
17
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.8.0...0.8.1)
|
18
|
+
|
19
|
+
- ~~This version is now available on RubyGems.org!~~ [#41](https://github.com/ybiquitous/aufgaben/pull/41)
|
20
|
+
→ Failed.
|
21
|
+
|
22
|
+
## 0.8.0
|
23
|
+
|
24
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.7.1...0.8.0)
|
25
|
+
|
26
|
+
- Support Ruby 3.0.2, 2.7.4, and 2.6.8 for `bump:ruby` [#38](https://github.com/ybiquitous/aufgaben/pull/38)
|
27
|
+
- Colored message for release [#39](https://github.com/ybiquitous/aufgaben/pull/39) [#40](https://github.com/ybiquitous/aufgaben/pull/40)
|
28
|
+
|
29
|
+
## 0.7.1
|
30
|
+
|
31
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.7.0...0.7.1)
|
32
|
+
|
33
|
+
- Auto-release via GitHub Actions (no actual changes) [#37](https://github.com/ybiquitous/aufgaben/pull/37)
|
34
|
+
|
35
|
+
## 0.7.0
|
36
|
+
|
37
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.6.2...0.7.0)
|
38
|
+
|
39
|
+
- Support Ruby 3.0.1, 2.7.3, and 2.6.7 for `bump:ruby` [#34](https://github.com/ybiquitous/aufgaben/pull/34)
|
40
|
+
- **BREAKING** Rename default branch from `master` to `main` [#36](https://github.com/ybiquitous/aufgaben/pull/36)
|
41
|
+
|
42
|
+
## 0.6.2
|
43
|
+
|
44
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.6.1...0.6.2)
|
45
|
+
|
46
|
+
- Improve error message of release task [#33](https://github.com/ybiquitous/aufgaben/pull/33)
|
47
|
+
|
48
|
+
## 0.6.1
|
49
|
+
|
50
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.6.0...0.6.1)
|
51
|
+
|
52
|
+
- Add Ruby 3.0.0 for `bump:ruby` [#30](https://github.com/ybiquitous/aufgaben/pull/30)
|
53
|
+
|
54
|
+
## 0.6.0
|
55
|
+
|
56
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.5.1...0.6.0)
|
57
|
+
|
58
|
+
- Support Rake task dependencies [#29](https://github.com/ybiquitous/aufgaben/pull/29)
|
59
|
+
|
60
|
+
## 0.5.1
|
61
|
+
|
62
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.5.0...0.5.1)
|
63
|
+
|
64
|
+
- Add Ruby 2.7 for `bump:ruby` [#25](https://github.com/ybiquitous/aufgaben/pull/25)
|
65
|
+
|
66
|
+
## 0.5.0
|
67
|
+
|
68
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.4.2...0.5.0)
|
69
|
+
|
70
|
+
- Add `bump:nodejs` task [#22](https://github.com/ybiquitous/aufgaben/pull/22)
|
71
|
+
|
72
|
+
## 0.4.2
|
73
|
+
|
74
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.4.1...0.4.2)
|
75
|
+
|
76
|
+
- Add Ruby 2.7.1 and 2.6.6 news for `bump:ruby` [#21](https://github.com/ybiquitous/aufgaben/pull/21)
|
77
|
+
|
78
|
+
## 0.4.1
|
79
|
+
|
80
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.4.0...0.4.1)
|
81
|
+
|
82
|
+
- Support Ruby 2.7 for `bump:ruby` [#19](https://github.com/ybiquitous/aufgaben/pull/19)
|
83
|
+
|
84
|
+
## 0.4.0
|
85
|
+
|
86
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.3.0...0.4.0)
|
87
|
+
|
88
|
+
- Change `git log` format on `release` task [#16](https://github.com/ybiquitous/aufgaben/pull/16)
|
89
|
+
- Enable interactive mode by default for `release` task [#18](https://github.com/ybiquitous/aufgaben/pull/18)
|
90
|
+
|
91
|
+
## 0.3.0
|
92
|
+
|
93
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.2.0...0.3.0)
|
94
|
+
|
95
|
+
- More detail Ruby release URL [#12](https://github.com/ybiquitous/aufgaben/pull/12)
|
96
|
+
- Add `files` option to `release` task [#14](https://github.com/ybiquitous/aufgaben/pull/14)
|
97
|
+
|
98
|
+
## 0.2.0
|
99
|
+
|
100
|
+
[Full diff](https://github.com/ybiquitous/aufgaben/compare/0.1.0...0.2.0)
|
101
|
+
|
102
|
+
- Add bumping Ruby task [#8](https://github.com/ybiquitous/aufgaben/pull/8)
|
103
|
+
|
104
|
+
## 0.1.0
|
105
|
+
|
106
|
+
Initial release.
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Masafumi Koba
|
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,121 @@
|
|
1
|
+
# Aufgaben
|
2
|
+
|
3
|
+
The collection of useful Rake tasks.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "aufgaben", git: "https://github.com/ybiquitous/aufgaben.git", tag: "<<tag_you_want>>", require: false
|
11
|
+
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
### Releasing
|
17
|
+
|
18
|
+
Put the following code to your `Rakefile`:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require "aufgaben/release"
|
22
|
+
Aufgaben::Release.new
|
23
|
+
```
|
24
|
+
|
25
|
+
The default settings:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Aufgaben::Release.new do |t|
|
29
|
+
t.default_branch = "main"
|
30
|
+
t.dry_run = false
|
31
|
+
t.changelog = "CHANGELOG.md"
|
32
|
+
t.files = []
|
33
|
+
t.new_version = nil # from the CLI argument
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
The following is a customization example:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
Aufgaben::Release.new(:my_release_task_name, depends: [:test]) do |t|
|
41
|
+
t.default_branch = "development"
|
42
|
+
t.changelog = "changes.md"
|
43
|
+
t.files = FileList["lib/version.rb", "lib/**/ver.rb"]
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
And then execute:
|
48
|
+
|
49
|
+
```console
|
50
|
+
$ rake release'[1.2.3]'
|
51
|
+
```
|
52
|
+
|
53
|
+
Or in dry-run mode:
|
54
|
+
|
55
|
+
```console
|
56
|
+
$ rake release'[1.2.3]' DRY_RUN=1
|
57
|
+
```
|
58
|
+
|
59
|
+
By default, the release task is executed in interactive mode.
|
60
|
+
If you want to disable the interactive mode, run as follow:
|
61
|
+
|
62
|
+
```console
|
63
|
+
$ rake release'[1.2.3]' NONINTERACTIVE=1
|
64
|
+
```
|
65
|
+
|
66
|
+
### Bumping up Ruby
|
67
|
+
|
68
|
+
Configure your `Rakefile` as follows:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
require "aufgaben/bump/ruby"
|
72
|
+
Aufgaben::Bump::Ruby.new do |t|
|
73
|
+
t.files << "my-ruby-version-file" # defaults to [".ruby-version", "Dockerfile"]
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
And then execute:
|
78
|
+
|
79
|
+
```console
|
80
|
+
$ rake bump:ruby'[2.6.5]' [DRY_RUN=1]
|
81
|
+
```
|
82
|
+
|
83
|
+
Also, you can customize the task name or dependencies as follows:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
require "aufgaben/bump/ruby"
|
87
|
+
Aufgaben::Bump::Ruby.new(:ruby_files, :update, dependes: [:test])
|
88
|
+
```
|
89
|
+
|
90
|
+
```console
|
91
|
+
# Invoke the `test` task before
|
92
|
+
$ rake update:ruby_files'[2.7.2]'
|
93
|
+
```
|
94
|
+
|
95
|
+
### Bumping up Node.js
|
96
|
+
|
97
|
+
Configure your `Rakefile` as follows:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
require "aufgaben/bump/nodejs"
|
101
|
+
Aufgaben::Bump::Nodejs.new do |t|
|
102
|
+
t.files << "Dockerfile.production" # defaults to ["Dockerfile"]
|
103
|
+
t.version_files << "nodejs-version.txt" # defaults to [".node-version", ".nvmrc"]
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
And then execute:
|
108
|
+
|
109
|
+
```console
|
110
|
+
$ rake bump:nodejs'[12.16.1]' [DRY_RUN=1]
|
111
|
+
```
|
112
|
+
|
113
|
+
## Development
|
114
|
+
|
115
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
116
|
+
|
117
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
118
|
+
|
119
|
+
## Contributing
|
120
|
+
|
121
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/ybiquitous/aufgaben>.
|
data/lib/aufgaben.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "rake/tasklib"
|
3
|
+
|
4
|
+
module Aufgaben
|
5
|
+
class Base < ::Rake::TaskLib
|
6
|
+
attr_reader :name
|
7
|
+
attr_reader :depends
|
8
|
+
attr_accessor :dry_run
|
9
|
+
|
10
|
+
def initialize(name, depends:)
|
11
|
+
super()
|
12
|
+
@name = name
|
13
|
+
@depends = depends
|
14
|
+
@dry_run = false
|
15
|
+
end
|
16
|
+
|
17
|
+
def dry_run?
|
18
|
+
ENV["DRY_RUN"] || dry_run
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require "erb"
|
2
|
+
require "set"
|
3
|
+
|
4
|
+
require_relative "../base"
|
5
|
+
require_relative "../bump"
|
6
|
+
|
7
|
+
module Aufgaben
|
8
|
+
module Bump
|
9
|
+
class Base < Aufgaben::Base
|
10
|
+
DEFAULT_COMMIT_MESSAGE_TEMPLATE = <<-'MSG'.freeze
|
11
|
+
Bump <%= target_name %> from <%= current_version %> to <%= next_version %>
|
12
|
+
|
13
|
+
Via:
|
14
|
+
|
15
|
+
```console
|
16
|
+
$ rake <%= ns %>:<%= name %>'[<%= next_version %>]'
|
17
|
+
```
|
18
|
+
|
19
|
+
Read the [<%= release_label %>](<%= release_url %>) for details.
|
20
|
+
MSG
|
21
|
+
|
22
|
+
attr_reader :ns
|
23
|
+
attr_accessor :files
|
24
|
+
attr_accessor :current_version
|
25
|
+
attr_accessor :commit_message_template
|
26
|
+
|
27
|
+
def initialize(name, ns, target_name, depends:)
|
28
|
+
super(name, depends: depends)
|
29
|
+
|
30
|
+
@ns = ns || default_namespace
|
31
|
+
@target_name = target_name
|
32
|
+
@files ||= []
|
33
|
+
@commit_message_template = DEFAULT_COMMIT_MESSAGE_TEMPLATE
|
34
|
+
|
35
|
+
yield self if block_given?
|
36
|
+
|
37
|
+
namespace(ns) { define }
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_namespace
|
41
|
+
:bump
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
attr_reader :target_name
|
47
|
+
attr_accessor :next_version
|
48
|
+
|
49
|
+
def target_files
|
50
|
+
Set.new(files)
|
51
|
+
end
|
52
|
+
|
53
|
+
def define
|
54
|
+
desc "Bump #{target_name} version"
|
55
|
+
task name, [:next_version] => depends do |_task, args|
|
56
|
+
self.next_version = args.fetch(:next_version) or raise "`next_version is required`"
|
57
|
+
current_version or raise "`current_version` is required"
|
58
|
+
|
59
|
+
puts "Bumping #{target_name} from #{current_version} to #{next_version} ..."
|
60
|
+
puts ""
|
61
|
+
|
62
|
+
current_version_pattern = Regexp.new('\b' + Regexp.escape(current_version) + '\b')
|
63
|
+
|
64
|
+
changed_files = target_files.each_with_object([]) do |file, new_files|
|
65
|
+
next unless File.exist? file
|
66
|
+
|
67
|
+
if dry_run?
|
68
|
+
puts "#{file} will be changed."
|
69
|
+
else
|
70
|
+
print "Writing #{file} ..."
|
71
|
+
content = File.read(file)
|
72
|
+
content.gsub!(current_version_pattern, next_version)
|
73
|
+
File.write(file, content)
|
74
|
+
puts " OK"
|
75
|
+
puts ""
|
76
|
+
end
|
77
|
+
|
78
|
+
new_files << file
|
79
|
+
end
|
80
|
+
|
81
|
+
if changed_files.empty?
|
82
|
+
puts "No changed files."
|
83
|
+
elsif !dry_run?
|
84
|
+
puts "Committing changed files ..."
|
85
|
+
puts ""
|
86
|
+
sh "git", "add", *changed_files
|
87
|
+
sh "git", "commit", "-m", commit_message
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def commit_message
|
93
|
+
ERB.new(commit_message_template).result_with_hash(
|
94
|
+
ns: ns,
|
95
|
+
name: name,
|
96
|
+
target_name: target_name,
|
97
|
+
current_version: current_version,
|
98
|
+
next_version: next_version,
|
99
|
+
release_label: release_label,
|
100
|
+
release_url: release_url,
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative "./base"
|
2
|
+
|
3
|
+
module Aufgaben
|
4
|
+
class Bump::Nodejs < Bump::Base
|
5
|
+
DEFAULT_FILES = %w[
|
6
|
+
Dockerfile
|
7
|
+
].freeze
|
8
|
+
|
9
|
+
DEFAULT_VERSION_FILES = %w[
|
10
|
+
.node-version
|
11
|
+
.nvmrc
|
12
|
+
].freeze
|
13
|
+
|
14
|
+
attr_accessor :version_files
|
15
|
+
|
16
|
+
def initialize(name = :nodejs, ns = default_namespace, depends: [])
|
17
|
+
self.files = DEFAULT_FILES.dup
|
18
|
+
self.version_files = DEFAULT_VERSION_FILES.dup
|
19
|
+
|
20
|
+
super(name, ns, "Node.js", depends: depends)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def current_version
|
26
|
+
@current_version ||= init_current_version
|
27
|
+
end
|
28
|
+
|
29
|
+
def init_current_version
|
30
|
+
version_files.each do |file|
|
31
|
+
next unless File.exist? file
|
32
|
+
match = File.read(file).match(/^(\d+\.\d+\.\d+)$/)
|
33
|
+
return match.captures[0] if match
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def target_files
|
38
|
+
Set.new(files + version_files)
|
39
|
+
end
|
40
|
+
|
41
|
+
def release_label
|
42
|
+
"changelog"
|
43
|
+
end
|
44
|
+
|
45
|
+
def release_url
|
46
|
+
major_version = Integer(next_version.match(/^(\d+)\./).captures[0])
|
47
|
+
"https://github.com/nodejs/node/blob/v#{next_version}/doc/changelogs/CHANGELOG_V#{major_version}.md"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative "./base"
|
2
|
+
|
3
|
+
module Aufgaben
|
4
|
+
class Bump::Ruby < Bump::Base
|
5
|
+
DEFAULT_FILES = %w[
|
6
|
+
.ruby-version
|
7
|
+
Dockerfile
|
8
|
+
].freeze
|
9
|
+
|
10
|
+
DEFAULT_RELEASE_NOTE_URL = "https://www.ruby-lang.org/en/news".freeze
|
11
|
+
RELEASE_NOTE_URLS = {
|
12
|
+
"3.0.2": "https://www.ruby-lang.org/en/news/2021/07/07/ruby-3-0-2-released/",
|
13
|
+
"3.0.1": "https://www.ruby-lang.org/en/news/2021/04/05/ruby-3-0-1-released/",
|
14
|
+
"3.0.0": "https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/",
|
15
|
+
"2.7.4": "https://www.ruby-lang.org/en/news/2021/07/07/ruby-2-7-4-released/",
|
16
|
+
"2.7.3": "https://www.ruby-lang.org/en/news/2021/04/05/ruby-2-7-3-released/",
|
17
|
+
"2.7.2": "https://www.ruby-lang.org/en/news/2020/10/02/ruby-2-7-2-released/",
|
18
|
+
"2.7.1": "https://www.ruby-lang.org/en/news/2020/03/31/ruby-2-7-1-released/",
|
19
|
+
"2.7.0": "https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/",
|
20
|
+
"2.6.8": "https://www.ruby-lang.org/en/news/2021/07/07/ruby-2-6-8-released/",
|
21
|
+
"2.6.7": "https://www.ruby-lang.org/en/news/2021/04/05/ruby-2-6-7-released/",
|
22
|
+
"2.6.6": "https://www.ruby-lang.org/en/news/2020/03/31/ruby-2-6-6-released/",
|
23
|
+
"2.6.5": "https://www.ruby-lang.org/en/news/2019/10/01/ruby-2-6-5-released/",
|
24
|
+
"2.6.4": "https://www.ruby-lang.org/en/news/2019/08/28/ruby-2-6-4-released/",
|
25
|
+
"2.6.3": "https://www.ruby-lang.org/en/news/2019/04/17/ruby-2-6-3-released/",
|
26
|
+
"2.6.2": "https://www.ruby-lang.org/en/news/2019/03/13/ruby-2-6-2-released/",
|
27
|
+
"2.6.1": "https://www.ruby-lang.org/en/news/2019/01/30/ruby-2-6-1-released/",
|
28
|
+
"2.6.0": "https://www.ruby-lang.org/en/news/2018/12/25/ruby-2-6-0-released/",
|
29
|
+
}.freeze
|
30
|
+
|
31
|
+
def initialize(name = :ruby, ns = default_namespace, depends: [])
|
32
|
+
self.files = DEFAULT_FILES.dup
|
33
|
+
self.current_version = RUBY_VERSION
|
34
|
+
|
35
|
+
super(name, ns, "Ruby", depends: depends)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def release_label
|
41
|
+
"release note"
|
42
|
+
end
|
43
|
+
|
44
|
+
def release_url
|
45
|
+
RELEASE_NOTE_URLS.fetch(next_version.to_sym, DEFAULT_RELEASE_NOTE_URL)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
require_relative "color"
|
3
|
+
|
4
|
+
module Aufgaben
|
5
|
+
class Release < Base
|
6
|
+
attr_accessor :default_branch
|
7
|
+
attr_accessor :changelog
|
8
|
+
attr_accessor :files
|
9
|
+
attr_accessor :new_version
|
10
|
+
|
11
|
+
def initialize(name = :release, depends: [])
|
12
|
+
super(name, depends: depends)
|
13
|
+
@default_branch = "main"
|
14
|
+
@changelog = "CHANGELOG.md"
|
15
|
+
@files = []
|
16
|
+
@new_version = nil
|
17
|
+
|
18
|
+
yield self if block_given?
|
19
|
+
define
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def define
|
25
|
+
desc "Perform a release work"
|
26
|
+
task name, [:version] => depends do |_task, args|
|
27
|
+
self.new_version = args[:version] if args[:version]
|
28
|
+
|
29
|
+
unless new_version
|
30
|
+
abort "Specify a new version. Usage: rake #{name}[version]"
|
31
|
+
end
|
32
|
+
|
33
|
+
msg "Start releasing..."
|
34
|
+
|
35
|
+
msg "If you want to do this on dry-run mode, set 'DRY_RUN=1'." unless dry_run?
|
36
|
+
|
37
|
+
sh "git", "checkout", default_branch, "--quiet"
|
38
|
+
sh "git", "pull", "origin", default_branch, "--quiet"
|
39
|
+
sh "bundle", "install", "--quiet"
|
40
|
+
|
41
|
+
if current_version.empty?
|
42
|
+
initial = true
|
43
|
+
else
|
44
|
+
initial = false
|
45
|
+
unless Gem::Version.new(current_version) < Gem::Version.new(new_version)
|
46
|
+
abort "Invalid version! current=#{current_version} new=#{new_version}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
sh "git", "diff", "--exit-code", "--quiet" do |ok|
|
51
|
+
abort "Uncommitted changes found!" unless ok
|
52
|
+
end
|
53
|
+
|
54
|
+
if initial
|
55
|
+
msg "Releasing a new version: #{colored_new_version}"
|
56
|
+
else
|
57
|
+
msg "Releasing a new version: #{current_version} -> #{colored_new_version}"
|
58
|
+
end
|
59
|
+
|
60
|
+
sh "git", "--no-pager", "log", "--format=%C(auto)%h %Creset%s", "#{current_version}..HEAD"
|
61
|
+
|
62
|
+
if dry_run?
|
63
|
+
msg "This is a dry-run mode. No actual changes. Next, run this without `DRY_RUN=1`."
|
64
|
+
else
|
65
|
+
if interactive?
|
66
|
+
answer_yes? or abort "Aborted."
|
67
|
+
end
|
68
|
+
|
69
|
+
if File.exist? changelog
|
70
|
+
update_changelog from: current_version, to: new_version
|
71
|
+
else
|
72
|
+
add_changelog with: new_version
|
73
|
+
end
|
74
|
+
sh "git", "add", changelog
|
75
|
+
|
76
|
+
Dir.glob(files, File::FNM_EXTGLOB).each do |file|
|
77
|
+
update_version_in file
|
78
|
+
sh "git", "add", file
|
79
|
+
end
|
80
|
+
|
81
|
+
sh "git", "commit", "--quiet", "--message", "Version #{new_version}"
|
82
|
+
sh "git", "tag", "--annotate", "--message", "Version #{new_version}", new_version
|
83
|
+
msg "The tag '#{new_version}' is added. Run 'git push --follow-tags'."
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def current_version
|
89
|
+
@current_version ||= `git describe --abbrev=0 --tags`.chomp
|
90
|
+
end
|
91
|
+
|
92
|
+
def update_changelog(from:, to:)
|
93
|
+
compare_url = nil
|
94
|
+
new_lines = File.readlines(changelog, chomp: true).map do |line|
|
95
|
+
case
|
96
|
+
when line == "## Unreleased"
|
97
|
+
"## #{to}"
|
98
|
+
when line.include?("#{from}...HEAD")
|
99
|
+
line.match(%r{\((?<url>.+)/#{from}...HEAD\)}) do |m|
|
100
|
+
compare_url = m[:url]
|
101
|
+
end
|
102
|
+
line.sub("#{from}...HEAD", "#{from}...#{to}")
|
103
|
+
else
|
104
|
+
line
|
105
|
+
end
|
106
|
+
end
|
107
|
+
new_lines.insert(
|
108
|
+
4,
|
109
|
+
"## Unreleased",
|
110
|
+
"",
|
111
|
+
"[Full diff](#{compare_url}/#{to}...HEAD)",
|
112
|
+
"",
|
113
|
+
)
|
114
|
+
File.write(changelog, new_lines.join("\n") + "\n")
|
115
|
+
|
116
|
+
msg "'#{changelog}' is updated."
|
117
|
+
end
|
118
|
+
|
119
|
+
def add_changelog(with:)
|
120
|
+
# for test only
|
121
|
+
git_remote_command = ENV["AUFGABEN_GIT_REMOTE_COMMAND"] || "git remote --verbose"
|
122
|
+
|
123
|
+
repo = nil
|
124
|
+
`#{git_remote_command}`.lines(chomp: true).each do |line|
|
125
|
+
line.match(%r{git@github\.com:([^/]+/[^/]+)\.git}) do |m|
|
126
|
+
repo = m.captures.first
|
127
|
+
break
|
128
|
+
end
|
129
|
+
line.match(%r{https://github\.com/([^/]+/[^/]+)\.git}) do |m|
|
130
|
+
repo = m.captures.first
|
131
|
+
break
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
abort "No remote repositories on GitHub!" unless repo
|
136
|
+
|
137
|
+
File.write(changelog, <<~CONTENT, encoding: Encoding::UTF_8)
|
138
|
+
# Changelog
|
139
|
+
|
140
|
+
All notable changes to this project will be documented in this file.
|
141
|
+
|
142
|
+
## Unreleased
|
143
|
+
|
144
|
+
[Full diff](https://github.com/#{repo}/compare/#{with}...HEAD)
|
145
|
+
|
146
|
+
## #{with}
|
147
|
+
|
148
|
+
Initial release.
|
149
|
+
CONTENT
|
150
|
+
|
151
|
+
msg "'#{changelog}' is added."
|
152
|
+
end
|
153
|
+
|
154
|
+
def update_version_in(file)
|
155
|
+
content = File.read(file)
|
156
|
+
content = content.gsub(Regexp.new('\b' + Regexp.escape(current_version) + '\b'), new_version)
|
157
|
+
File.write(file, content)
|
158
|
+
|
159
|
+
msg "'#{file}' is updated."
|
160
|
+
end
|
161
|
+
|
162
|
+
def msg(text)
|
163
|
+
puts
|
164
|
+
puts "> #{text}"
|
165
|
+
puts
|
166
|
+
end
|
167
|
+
|
168
|
+
def interactive?
|
169
|
+
!ENV["NONINTERACTIVE"]
|
170
|
+
end
|
171
|
+
|
172
|
+
def answer_yes?
|
173
|
+
puts
|
174
|
+
loop do
|
175
|
+
print "> Perform the release of version #{colored_new_version}? [y/N] "
|
176
|
+
answer = STDIN.gets.chomp.downcase
|
177
|
+
if answer == "y"
|
178
|
+
return true
|
179
|
+
elsif answer == "n" || answer == ""
|
180
|
+
return false
|
181
|
+
else
|
182
|
+
puts "> Please type 'y' or 'n'."
|
183
|
+
next
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def colored_new_version
|
189
|
+
Color.new(new_version).green
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aufgaben
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masafumi Koba
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
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: rake
|
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: minitest
|
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
|
+
description: Aufgaben provides a collection of practical Rake tasks for automation.
|
56
|
+
email:
|
57
|
+
- ybiquitous@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- CHANGELOG.md
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- lib/aufgaben.rb
|
66
|
+
- lib/aufgaben/base.rb
|
67
|
+
- lib/aufgaben/bump.rb
|
68
|
+
- lib/aufgaben/bump/base.rb
|
69
|
+
- lib/aufgaben/bump/nodejs.rb
|
70
|
+
- lib/aufgaben/bump/ruby.rb
|
71
|
+
- lib/aufgaben/color.rb
|
72
|
+
- lib/aufgaben/release.rb
|
73
|
+
- lib/aufgaben/version.rb
|
74
|
+
homepage: https://github.com/ybiquitous/aufgaben
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata:
|
78
|
+
homepage_uri: https://github.com/ybiquitous/aufgaben
|
79
|
+
source_code_uri: https://github.com/ybiquitous/aufgaben
|
80
|
+
changelog_uri: https://github.com/ybiquitous/aufgaben/blob/main/CHANGELOG.md
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.6.0
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubygems_version: 3.2.22
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: The collection of useful Rake tasks.
|
100
|
+
test_files: []
|