create_github_release 0.2.1 → 0.3.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/LICENSE.txt +1 -1
- data/README.md +36 -21
- data/create_github_release.gemspec +1 -0
- data/exe/create-github-release +12 -8
- data/lib/create_github_release/assertion_base.rb +25 -11
- data/lib/create_github_release/assertions/bundle_is_up_to_date.rb +4 -3
- data/lib/create_github_release/assertions/{docker_is_running.rb → gh_authenticated.rb} +9 -8
- data/lib/create_github_release/assertions/gh_command_exists.rb +3 -2
- data/lib/create_github_release/assertions/git_command_exists.rb +3 -2
- data/lib/create_github_release/assertions/in_git_repo.rb +3 -2
- data/lib/create_github_release/assertions/in_repo_root_directory.rb +3 -2
- data/lib/create_github_release/assertions/last_release_tag_exists.rb +45 -0
- data/lib/create_github_release/assertions/local_and_remote_on_same_commit.rb +4 -3
- data/lib/create_github_release/assertions/local_release_branch_does_not_exist.rb +6 -5
- data/lib/create_github_release/assertions/local_release_tag_does_not_exist.rb +3 -3
- data/lib/create_github_release/assertions/no_staged_changes.rb +3 -2
- data/lib/create_github_release/assertions/no_uncommitted_changes.rb +3 -2
- data/lib/create_github_release/assertions/on_default_branch.rb +5 -4
- data/lib/create_github_release/assertions/remote_release_branch_does_not_exist.rb +6 -5
- data/lib/create_github_release/assertions/remote_release_tag_does_not_exist.rb +6 -5
- data/lib/create_github_release/assertions.rb +2 -2
- data/lib/create_github_release/backtick_debug.rb +69 -0
- data/lib/create_github_release/change.rb +73 -0
- data/lib/create_github_release/changelog.rb +40 -68
- data/lib/create_github_release/command_line_options.rb +367 -0
- data/lib/create_github_release/command_line_parser.rb +113 -25
- data/lib/create_github_release/project.rb +787 -0
- data/lib/create_github_release/release_assertions.rb +3 -3
- data/lib/create_github_release/release_tasks.rb +1 -1
- data/lib/create_github_release/task_base.rb +25 -11
- data/lib/create_github_release/tasks/commit_release.rb +4 -3
- data/lib/create_github_release/tasks/create_github_release.rb +16 -35
- data/lib/create_github_release/tasks/create_release_branch.rb +6 -5
- data/lib/create_github_release/tasks/create_release_pull_request.rb +10 -42
- data/lib/create_github_release/tasks/create_release_tag.rb +6 -5
- data/lib/create_github_release/tasks/push_release.rb +5 -4
- data/lib/create_github_release/tasks/update_changelog.rb +16 -67
- data/lib/create_github_release/tasks/update_version.rb +4 -3
- data/lib/create_github_release/version.rb +1 -1
- data/lib/create_github_release.rb +4 -2
- metadata +23 -8
- data/.vscode/settings.json +0 -7
- data/lib/create_github_release/assertions/changelog_docker_container_exists.rb +0 -73
- data/lib/create_github_release/options.rb +0 -397
- data/lib/create_github_release/release.rb +0 -82
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CreateGithubRelease
|
4
|
+
# Include this module to output debug information for backticks
|
5
|
+
#
|
6
|
+
# The class this module is included in must have a `backtick_debug?` method.
|
7
|
+
#
|
8
|
+
# @example Using this module to debug backticks
|
9
|
+
# class Foo
|
10
|
+
# include CreateGithubRelease::BacktickDebug
|
11
|
+
#
|
12
|
+
# def backtick_debug?; true; end
|
13
|
+
#
|
14
|
+
# def bar
|
15
|
+
# `echo foo`
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# Foo.new.bar #=>
|
20
|
+
# COMMAND
|
21
|
+
# echo foo
|
22
|
+
# OUTPUT
|
23
|
+
# foo
|
24
|
+
# EXITSTATUS
|
25
|
+
# 0
|
26
|
+
#
|
27
|
+
# @api public
|
28
|
+
#
|
29
|
+
module BacktickDebug
|
30
|
+
# Calls `super` and shows the command and its result if `backtick_debug?` is true
|
31
|
+
#
|
32
|
+
# The command, it's output, and it's exit status are output to stdout via `puts`.
|
33
|
+
#
|
34
|
+
# The including class is expected to have a `backtick_debug?` method.
|
35
|
+
#
|
36
|
+
# @example
|
37
|
+
# including_class.new.send('`'.to_sym, 'echo foo') #=>
|
38
|
+
# COMMAND
|
39
|
+
# echo foo
|
40
|
+
# OUTPUT
|
41
|
+
# foo
|
42
|
+
# EXITSTATUS
|
43
|
+
# 0
|
44
|
+
#
|
45
|
+
# @example A command that fails
|
46
|
+
# including_class.new.send('`'.to_sym, 'echo foo; exit 1') #=>
|
47
|
+
# COMMAND
|
48
|
+
# echo foo
|
49
|
+
# OUTPUT
|
50
|
+
# foo
|
51
|
+
# EXITSTATUS
|
52
|
+
# 1
|
53
|
+
#
|
54
|
+
# @param command [String] the command to execute
|
55
|
+
#
|
56
|
+
# @return [String] the output of the command
|
57
|
+
#
|
58
|
+
def `(command)
|
59
|
+
puts "COMMAND\n #{command}" if backtick_debug?
|
60
|
+
super.tap do |output|
|
61
|
+
if backtick_debug?
|
62
|
+
puts "OUTPUT\n"
|
63
|
+
output.lines { |l| puts " #{l.chomp}" }
|
64
|
+
puts "EXITSTATUS\n #{$CHILD_STATUS.exitstatus}\n"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CreateGithubRelease
|
4
|
+
# The release information needed to generate a changelog
|
5
|
+
#
|
6
|
+
# @api public
|
7
|
+
#
|
8
|
+
class Change
|
9
|
+
# Create a new release object
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# sha = 'f5e69d6'
|
13
|
+
# subject = 'Release v1.0.0'
|
14
|
+
#
|
15
|
+
# change = CreateGithubRelease::Change.new(sha, subject)
|
16
|
+
# change.sha # => 'f5e69d6'
|
17
|
+
# change.subject # => 'Release v1.0.0'
|
18
|
+
#
|
19
|
+
# @param sha [String] The sha of the change
|
20
|
+
# @param subject [String] The subject (aka description) of the change
|
21
|
+
#
|
22
|
+
def initialize(sha, subject)
|
23
|
+
@sha = sha
|
24
|
+
@subject = subject
|
25
|
+
end
|
26
|
+
|
27
|
+
# The commit sha of the change
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# sha = 'f5e69d6'
|
31
|
+
# subject = 'Release v1.0.0'
|
32
|
+
#
|
33
|
+
# change = CreateGithubRelease::Change.new(sha, subject))
|
34
|
+
# change.sha # => 'f5e69d6'
|
35
|
+
#
|
36
|
+
# @return [String] The commit sha of the change
|
37
|
+
attr_reader :sha
|
38
|
+
|
39
|
+
# The subject (aka description) of the change
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# sha = 'f5e69d6'
|
43
|
+
# subject = 'Release v1.0.0'
|
44
|
+
#
|
45
|
+
# change = CreateGithubRelease::Change.new(sha, subject))
|
46
|
+
# change.subject # => 'Release v1.0.0'
|
47
|
+
#
|
48
|
+
# @return [String] The subject (aka description) of the change
|
49
|
+
attr_reader :subject
|
50
|
+
|
51
|
+
# Compare two changes to see if they refer to the same change
|
52
|
+
#
|
53
|
+
# Two changes are equal if their `sha` and `subject` attributes are equal.
|
54
|
+
#
|
55
|
+
# @example
|
56
|
+
# change1 = CreateGithubRelease::Change.new('f5e69d6', 'Release v1.0.0')
|
57
|
+
# change2 = CreateGithubRelease::Change.new('f5e69d6', 'Release v1.0.0')
|
58
|
+
# change3 = CreateGithubRelease::Change.new('9387be0', 'Release v1.0.0')
|
59
|
+
# change4 = CreateGithubRelease::Change.new('f5e69d6', 'Release v2.0.0')
|
60
|
+
# change5 = CreateGithubRelease::Change.new('9387be0', 'Release v2.0.0')
|
61
|
+
# change1 == change2 #=> true
|
62
|
+
# change1 == change3 #=> false
|
63
|
+
# change1 == change4 #=> false
|
64
|
+
# change1 == change5 #=> false
|
65
|
+
#
|
66
|
+
# @param other [CreateGithubRelease::Change] The other change to compare this change to
|
67
|
+
#
|
68
|
+
# @return [Boolean] true if the two changes are equal, false otherwise
|
69
|
+
def ==(other)
|
70
|
+
self.class == other.class && sha == other.sha && subject == other.subject
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -22,16 +22,13 @@ module CreateGithubRelease
|
|
22
22
|
# * 07a1167 Release v0.1.0 (#1)
|
23
23
|
# EXISTING_CHANGELOG
|
24
24
|
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# new_release_description = <<~RELEASE
|
28
|
-
# * f5e69d6 Release v1.0.0 (#4)
|
29
|
-
# * 8fe479b Update documentation for initial GA release (#3)
|
30
|
-
# RELEASE
|
25
|
+
# next_release_description = <<~next_release_DESCRIPTION
|
26
|
+
# ## v1.0.0 (2022-11-10)
|
31
27
|
#
|
32
|
-
#
|
28
|
+
# * f5e69d6 Release v1.0.0 (#4)
|
29
|
+
# next_release_DESCRIPTION
|
33
30
|
#
|
34
|
-
# changelog = CreateGithubRelease::Changelog.new(existing_changelog,
|
31
|
+
# changelog = CreateGithubRelease::Changelog.new(existing_changelog, next_release_description)
|
35
32
|
#
|
36
33
|
# expected_new_changelog = <<~CHANGELOG
|
37
34
|
# # Change Log
|
@@ -41,7 +38,6 @@ module CreateGithubRelease
|
|
41
38
|
# ## v1.0.0 (2022-11-10)
|
42
39
|
#
|
43
40
|
# * f5e69d6 Release v1.0.0 (#4)
|
44
|
-
# * 8fe479b Update documentation for initial GA release (#3)
|
45
41
|
#
|
46
42
|
# ## v0.1.0 (2022-10-31)
|
47
43
|
#
|
@@ -50,15 +46,15 @@ module CreateGithubRelease
|
|
50
46
|
#
|
51
47
|
# changelog.front_matter # => "# Change Log\n\nList of changes in each release of this project."
|
52
48
|
# changelog.body # => "## v0.1.0 (2022-10-31)\n\n* 07a1167 Release v0.1.0 (#1)"
|
53
|
-
# changelog.
|
49
|
+
# changelog.next_release_description # => "## v1.0.0 (2022-11-10)\n\n..."
|
54
50
|
# changelog.to_s == expected_new_changelog # => true
|
55
51
|
#
|
56
52
|
# @param existing_changelog [String] Contents of the changelog as a string
|
57
|
-
# @param
|
53
|
+
# @param next_release_description [String] The description of the next release to add to the changelog
|
58
54
|
#
|
59
|
-
def initialize(existing_changelog,
|
55
|
+
def initialize(existing_changelog, next_release_description)
|
60
56
|
@existing_changelog = existing_changelog
|
61
|
-
@
|
57
|
+
@next_release_description = next_release_description
|
62
58
|
|
63
59
|
@lines = existing_changelog.lines.map(&:chomp)
|
64
60
|
end
|
@@ -75,9 +71,9 @@ module CreateGithubRelease
|
|
75
71
|
# ...
|
76
72
|
# CHANGELOG
|
77
73
|
#
|
78
|
-
#
|
74
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
79
75
|
#
|
80
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
76
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
81
77
|
# changelog.front_matter # => "This is the front matter\n"
|
82
78
|
#
|
83
79
|
# @example Changelog without front matter
|
@@ -86,26 +82,26 @@ module CreateGithubRelease
|
|
86
82
|
# ...
|
87
83
|
# CHANGELOG
|
88
84
|
#
|
89
|
-
#
|
85
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
90
86
|
#
|
91
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
87
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
92
88
|
# changelog.front_matter # => ""
|
93
89
|
#
|
94
90
|
# @example An empty changelog
|
95
91
|
# changelog_text = <<~CHANGELOG
|
96
92
|
# CHANGELOG
|
97
93
|
#
|
98
|
-
#
|
94
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
99
95
|
#
|
100
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
96
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
101
97
|
# changelog.front_matter # => ""
|
102
98
|
#
|
103
99
|
# @example An empty changelog
|
104
100
|
# changelog_text = ""
|
105
101
|
#
|
106
|
-
#
|
102
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
107
103
|
#
|
108
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
104
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
109
105
|
# changelog.front_matter # => ""
|
110
106
|
#
|
111
107
|
# @return [String] The front matter of the changelog
|
@@ -124,9 +120,9 @@ module CreateGithubRelease
|
|
124
120
|
# ...
|
125
121
|
# CHANGELOG
|
126
122
|
#
|
127
|
-
#
|
123
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
128
124
|
#
|
129
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
125
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
130
126
|
# changelog.body # => "## v0.1.0\n..."
|
131
127
|
#
|
132
128
|
# @example Changelog without front matter
|
@@ -135,9 +131,9 @@ module CreateGithubRelease
|
|
135
131
|
# ...
|
136
132
|
# CHANGELOG
|
137
133
|
#
|
138
|
-
#
|
134
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
139
135
|
#
|
140
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
136
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
141
137
|
# changelog.body # => "## v0.1.0\n..."
|
142
138
|
#
|
143
139
|
# @example Changelog without a body
|
@@ -145,26 +141,26 @@ module CreateGithubRelease
|
|
145
141
|
# This is the front matter
|
146
142
|
# CHANGELOG
|
147
143
|
#
|
148
|
-
#
|
144
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
149
145
|
#
|
150
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
146
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
151
147
|
# changelog.body # => ""
|
152
148
|
#
|
153
149
|
# @example An empty changelog (new line only)
|
154
150
|
# changelog_text = <<~CHANGELOG
|
155
151
|
# CHANGELOG
|
156
152
|
#
|
157
|
-
#
|
153
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
158
154
|
#
|
159
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
155
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
160
156
|
# changelog.body # => ""
|
161
157
|
#
|
162
158
|
# @example An empty changelog (empty string)
|
163
159
|
# changelog_text = ""
|
164
160
|
#
|
165
|
-
#
|
161
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
166
162
|
#
|
167
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
163
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
168
164
|
# changelog.body # => ""
|
169
165
|
#
|
170
166
|
# @return [String] The body of the existing changelog
|
@@ -184,16 +180,14 @@ module CreateGithubRelease
|
|
184
180
|
#
|
185
181
|
attr_reader :existing_changelog
|
186
182
|
|
187
|
-
# The new release to add to the changelog
|
183
|
+
# The description of the new release to add to the changelog
|
188
184
|
#
|
189
185
|
# @example
|
190
|
-
# changelog.
|
191
|
-
# changelog.new_release.date # => #<Date: 2018-06-30>
|
192
|
-
# changelog.new_release.description # => "[Full Changelog](...)..."
|
186
|
+
# changelog.next_release_description # => "# v1.0.0 - 2018-06-30\n\n[Full Changelog](...)..."
|
193
187
|
#
|
194
|
-
# @return [
|
188
|
+
# @return [String] The description of the new release to add to the changelog
|
195
189
|
#
|
196
|
-
attr_reader :
|
190
|
+
attr_reader :next_release_description
|
197
191
|
|
198
192
|
# The changelog with the new release
|
199
193
|
#
|
@@ -204,9 +198,7 @@ module CreateGithubRelease
|
|
204
198
|
# ...
|
205
199
|
# CHANGELOG
|
206
200
|
#
|
207
|
-
#
|
208
|
-
# 'v1.0.0', Date.parse('2022-11-08'), '...release description...'
|
209
|
-
# )
|
201
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
210
202
|
#
|
211
203
|
# expected_changelog = <<~CHANGELOG
|
212
204
|
# This is the front matter
|
@@ -218,7 +210,7 @@ module CreateGithubRelease
|
|
218
210
|
# ...
|
219
211
|
# CHANGELOG
|
220
212
|
#
|
221
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
213
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
222
214
|
#
|
223
215
|
# changelog.to_s == expected_changelog # => true
|
224
216
|
#
|
@@ -228,9 +220,7 @@ module CreateGithubRelease
|
|
228
220
|
# ...
|
229
221
|
# CHANGELOG
|
230
222
|
#
|
231
|
-
#
|
232
|
-
# 'v1.0.0', Date.parse('2022-11-08'), '...release description...'
|
233
|
-
# )
|
223
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
234
224
|
#
|
235
225
|
# expected_changelog = <<~CHANGELOG
|
236
226
|
# ## v1.0.0 (2022-11-08)
|
@@ -240,7 +230,7 @@ module CreateGithubRelease
|
|
240
230
|
# ...
|
241
231
|
# CHANGELOG
|
242
232
|
#
|
243
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
233
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
244
234
|
#
|
245
235
|
# changelog.to_s == expected_changelog # => true
|
246
236
|
#
|
@@ -249,9 +239,7 @@ module CreateGithubRelease
|
|
249
239
|
# This is the front matter
|
250
240
|
# CHANGELOG
|
251
241
|
#
|
252
|
-
#
|
253
|
-
# 'v1.0.0', Date.parse('2022-11-08'), '...release description...'
|
254
|
-
# )
|
242
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
255
243
|
#
|
256
244
|
# expected_changelog = <<~CHANGELOG
|
257
245
|
# This is the front matter
|
@@ -260,7 +248,7 @@ module CreateGithubRelease
|
|
260
248
|
# ...release description...
|
261
249
|
# CHANGELOG
|
262
250
|
#
|
263
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
251
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
264
252
|
#
|
265
253
|
# changelog.to_s == expected_changelog # => true
|
266
254
|
#
|
@@ -271,9 +259,7 @@ module CreateGithubRelease
|
|
271
259
|
# ...
|
272
260
|
# CHANGELOG
|
273
261
|
#
|
274
|
-
#
|
275
|
-
# 'v1.0.0', Date.parse('2022-11-08'), ''
|
276
|
-
# )
|
262
|
+
# next_release_description = '## v1.0.0\n\n* 8374b31 Add FizzBuzz'
|
277
263
|
#
|
278
264
|
# expected_changelog = <<~CHANGELOG
|
279
265
|
# This is the front matter
|
@@ -284,14 +270,14 @@ module CreateGithubRelease
|
|
284
270
|
# ...
|
285
271
|
# CHANGELOG
|
286
272
|
#
|
287
|
-
# changelog = CreateGithubRelease::Changelog.new(changelog_text,
|
273
|
+
# changelog = CreateGithubRelease::Changelog.new(changelog_text, next_release_description)
|
288
274
|
#
|
289
275
|
# changelog.to_s == expected_changelog # => true
|
290
276
|
#
|
291
277
|
# @return [String] The changelog with the new release details
|
292
278
|
#
|
293
279
|
def to_s
|
294
|
-
formatted_front_matter +
|
280
|
+
formatted_front_matter + next_release_description + formatted_body
|
295
281
|
end
|
296
282
|
|
297
283
|
private
|
@@ -354,20 +340,6 @@ module CreateGithubRelease
|
|
354
340
|
end
|
355
341
|
end
|
356
342
|
|
357
|
-
# The release header to output in the changelog
|
358
|
-
# @return [String] The release header to output in the changelog
|
359
|
-
# @api private
|
360
|
-
def release_header
|
361
|
-
"## #{new_release.tag} (#{new_release.date.strftime('%Y-%m-%d')})\n"
|
362
|
-
end
|
363
|
-
|
364
|
-
# The release description to output in the changelog
|
365
|
-
# @return [String] The release description to output in the changelog
|
366
|
-
# @api private
|
367
|
-
def release_description
|
368
|
-
new_release.description.empty? ? '' : "\n#{new_release.description.chomp}\n"
|
369
|
-
end
|
370
|
-
|
371
343
|
# Line number where the body of the changelog starts
|
372
344
|
# @return [Integer] Line number where the body of the changelog starts
|
373
345
|
# @api private
|