create_github_release 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/CHANGELOG.md +18 -0
- data/README.md +156 -38
- data/Rakefile +6 -6
- data/create_github_release.gemspec +3 -3
- data/exe/create-github-release +1 -1
- data/exe/revert-github-release +165 -0
- data/lib/create_github_release/assertions/bundle_is_up_to_date.rb +1 -1
- data/lib/create_github_release/assertions/gh_authenticated.rb +1 -1
- data/lib/create_github_release/assertions/gh_command_exists.rb +1 -1
- data/lib/create_github_release/assertions/git_command_exists.rb +1 -1
- data/lib/create_github_release/assertions/in_git_repo.rb +1 -1
- data/lib/create_github_release/assertions/in_repo_root_directory.rb +1 -1
- data/lib/create_github_release/assertions/local_and_remote_on_same_commit.rb +1 -1
- data/lib/create_github_release/assertions/local_release_branch_does_not_exist.rb +1 -1
- data/lib/create_github_release/assertions/no_staged_changes.rb +1 -1
- data/lib/create_github_release/assertions/no_uncommitted_changes.rb +1 -1
- data/lib/create_github_release/assertions/on_default_branch.rb +1 -1
- data/lib/create_github_release/assertions/remote_release_branch_does_not_exist.rb +1 -1
- data/lib/create_github_release/assertions/remote_release_tag_does_not_exist.rb +1 -1
- data/lib/create_github_release/command_line/options.rb +151 -0
- data/lib/create_github_release/command_line/parser.rb +262 -0
- data/lib/create_github_release/command_line/validations.rb +293 -0
- data/lib/create_github_release/command_line/validator.rb +93 -0
- data/lib/create_github_release/command_line.rb +43 -0
- data/lib/create_github_release/project.rb +115 -55
- data/lib/create_github_release/release_assertions.rb +1 -1
- data/lib/create_github_release/release_tasks.rb +1 -1
- data/lib/create_github_release/tasks/commit_release.rb +1 -1
- data/lib/create_github_release/tasks/create_github_release.rb +1 -1
- data/lib/create_github_release/tasks/create_release_branch.rb +1 -1
- data/lib/create_github_release/tasks/create_release_pull_request.rb +1 -1
- data/lib/create_github_release/tasks/create_release_tag.rb +1 -1
- data/lib/create_github_release/tasks/push_release.rb +1 -1
- data/lib/create_github_release/tasks/update_changelog.rb +1 -1
- data/lib/create_github_release/tasks/update_version.rb +5 -2
- data/lib/create_github_release/version.rb +1 -1
- data/lib/create_github_release.rb +1 -2
- metadata +12 -34
- data/lib/create_github_release/command_line_options.rb +0 -378
- data/lib/create_github_release/command_line_parser.rb +0 -229
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'validations'
|
4
|
+
|
5
|
+
module CreateGithubRelease
|
6
|
+
module CommandLine
|
7
|
+
# Validates a set of options after the options have been fully initialized
|
8
|
+
# @api private
|
9
|
+
class Validator
|
10
|
+
# Create a new instance of this class
|
11
|
+
# @param options [CreateGithubRelease::CommandLine::Options] the options to validate
|
12
|
+
# @api private
|
13
|
+
def initialize(options)
|
14
|
+
@options = options
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns `true` if all options are valid and `false` otherwise
|
18
|
+
#
|
19
|
+
# * If the options are valid, returns `true` clears the `#errors` array
|
20
|
+
# * If the options are not valid, returns `false` and populates the `#errors` array
|
21
|
+
#
|
22
|
+
# @example when all options are valid
|
23
|
+
# options = CreateGithubRelease::CommandLine::Options.new
|
24
|
+
# options.release_type = 'major'
|
25
|
+
# options.valid? #=> true
|
26
|
+
# options.errors #=> []
|
27
|
+
#
|
28
|
+
# @example when one or more options are not valid
|
29
|
+
# options = CreateGithubRelease::CommandLine::Options.new
|
30
|
+
# options.release_type #=> nil
|
31
|
+
# options.valid? #=> false
|
32
|
+
# options.errors #=> ["--release-type must be given and be one of 'major', 'minor', 'patch'"]
|
33
|
+
#
|
34
|
+
# @return [Boolean]
|
35
|
+
#
|
36
|
+
def valid?
|
37
|
+
@errors = []
|
38
|
+
validation_classes.each do |validation_class|
|
39
|
+
validation = validation_class.new(options)
|
40
|
+
@errors << validation.error unless validation.valid?
|
41
|
+
end
|
42
|
+
@errors.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns an array of error messages
|
46
|
+
#
|
47
|
+
# * If the options are valid, returns an empty array
|
48
|
+
# * If the options are not valid, returns an array of error messages
|
49
|
+
#
|
50
|
+
# @example when all options are valid
|
51
|
+
# options = CreateGithubRelease::CommandLine::Options.new
|
52
|
+
# options.release_type = 'major'
|
53
|
+
# options.valid? #=> true
|
54
|
+
# options.errors #=> []
|
55
|
+
#
|
56
|
+
# @example when one or more options are not valid
|
57
|
+
# options = CreateGithubRelease::CommandLine::Options.new
|
58
|
+
# options.release_type #=> nil
|
59
|
+
# options.quiet = options.verbose = true
|
60
|
+
# options.valid? #=> false
|
61
|
+
# options.errors #=> [
|
62
|
+
# "Both --quiet and --verbose cannot be given",
|
63
|
+
# "--release-type must be given and be one of 'major', 'minor', 'patch'"
|
64
|
+
# ]
|
65
|
+
#
|
66
|
+
# @return [Array<String>] an array of error messages
|
67
|
+
#
|
68
|
+
def errors
|
69
|
+
valid?
|
70
|
+
@errors
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
# The options to validate
|
76
|
+
# @return [CreateGithubRelease::CommandLine::Options]
|
77
|
+
# @api private
|
78
|
+
attr_reader :options
|
79
|
+
|
80
|
+
# Returns an array of validation classes
|
81
|
+
# @return [Array<CreateGithubRelease::Validations::Base>]
|
82
|
+
# @api private
|
83
|
+
def validation_classes
|
84
|
+
[].tap do |validation_classes|
|
85
|
+
CreateGithubRelease::CommandLine::Validations.constants.each do |constant_name|
|
86
|
+
constant = Validations.const_get(constant_name)
|
87
|
+
validation_classes << constant if constant.is_a?(Class) && constant_name.to_s.start_with?('Validate')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CreateGithubRelease
|
4
|
+
# This module has all the classes and modules for the command line interface
|
5
|
+
#
|
6
|
+
# The Parser class is the main interface. It parses and validates the command line
|
7
|
+
# arguments and returns an instance of the Options class.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# parser = CreateGithubRelease::CommandLine::Parser.new
|
11
|
+
# options = parser.parse(*ARGV)
|
12
|
+
# if !option.valid?
|
13
|
+
# puts options.errors
|
14
|
+
# exit 1
|
15
|
+
# end
|
16
|
+
# # ... do something with the options
|
17
|
+
#
|
18
|
+
# @api public
|
19
|
+
#
|
20
|
+
module CommandLine
|
21
|
+
# An array of the valid release types
|
22
|
+
# @return [Array<String>]
|
23
|
+
# @api private
|
24
|
+
VALID_RELEASE_TYPES = %w[major minor patch pre release first].freeze
|
25
|
+
|
26
|
+
# Regex pattern for a [valid git reference](https://git-scm.com/docs/git-check-ref-format)
|
27
|
+
# @return [Regexp]
|
28
|
+
# @api private
|
29
|
+
VALID_REF_PATTERN = /^(?:(?:[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*)|(?:[a-zA-Z0-9-]+))$/
|
30
|
+
|
31
|
+
# An array of the allowed options that can be passed to `.new`
|
32
|
+
# @return [Array<Symbol>]
|
33
|
+
ALLOWED_OPTIONS = %i[
|
34
|
+
release_type pre pre_type default_branch release_branch remote last_release_version
|
35
|
+
next_release_version changelog_path quiet verbose
|
36
|
+
].freeze
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
require_relative 'command_line/options'
|
41
|
+
require_relative 'command_line/parser'
|
42
|
+
require_relative 'command_line/validations'
|
43
|
+
require_relative 'command_line/validator'
|
@@ -26,18 +26,18 @@ module CreateGithubRelease
|
|
26
26
|
# used in the block passed to the initializer.
|
27
27
|
#
|
28
28
|
# @example calling `.new` without a block
|
29
|
-
# options = CreateGithubRelease::
|
29
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'minor' }
|
30
30
|
# project = CreateGithubRelease::Project.new(options)
|
31
31
|
# options.release_type = 'minor'
|
32
32
|
#
|
33
33
|
# @example calling `.new` with a block
|
34
|
-
# options = CreateGithubRelease::
|
34
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'minor' }
|
35
35
|
# project = CreateGithubRelease::Project.new(options) do |p|
|
36
36
|
# p.release_type = 'major'
|
37
37
|
# end
|
38
38
|
# options.release_type = 'major'
|
39
39
|
#
|
40
|
-
# @param options [CreateGithubRelease::
|
40
|
+
# @param options [CreateGithubRelease::CommandLine::Options] the options to initialize the instance with
|
41
41
|
#
|
42
42
|
# @yield [self] an initialization block
|
43
43
|
# @yieldparam self [CreateGithubRelease::Project] the instance being initialized aka `self`
|
@@ -55,20 +55,21 @@ module CreateGithubRelease
|
|
55
55
|
# The command line options used to initialize this project
|
56
56
|
#
|
57
57
|
# @example
|
58
|
-
# options = CreateGithubRelease::
|
58
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
59
59
|
# project = CreateGithubRelease::Project.new(options)
|
60
60
|
# project.options == options #=> true
|
61
61
|
#
|
62
|
-
# @return [CreateGithubRelease::
|
62
|
+
# @return [CreateGithubRelease::CommandLine::Options]
|
63
63
|
#
|
64
64
|
attr_reader :options
|
65
65
|
|
66
66
|
attr_writer \
|
67
67
|
:default_branch, :next_release_tag, :next_release_date, :next_release_version,
|
68
68
|
:last_release_tag, :last_release_version, :release_branch, :release_log_url,
|
69
|
-
:release_type, :
|
70
|
-
:
|
71
|
-
:
|
69
|
+
:release_type, :pre, :pre_type, :release_url, :remote, :remote_base_url,
|
70
|
+
:remote_repository, :remote_url, :changelog_path, :changes,
|
71
|
+
:next_release_description, :last_release_changelog, :next_release_changelog,
|
72
|
+
:first_commit, :verbose, :quiet
|
72
73
|
|
73
74
|
# attr_writer :first_release
|
74
75
|
|
@@ -82,12 +83,12 @@ module CreateGithubRelease
|
|
82
83
|
# Uses the value of `remote` to determine the remote repository to query.
|
83
84
|
#
|
84
85
|
# @example By default, `default_branch` is based on `git remote show`
|
85
|
-
# options = CreateGithubRelease::
|
86
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
86
87
|
# project = CreateGithubRelease::Project.new(options)
|
87
88
|
# options.default_branch # => 'main'
|
88
89
|
#
|
89
90
|
# @example `default_branch` can be set explicitly
|
90
|
-
# options = CreateGithubRelease::
|
91
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
91
92
|
# project = CreateGithubRelease::Project.new(options)
|
92
93
|
# project.default_branch = 'master'
|
93
94
|
# project.default_branch #=> 'master'
|
@@ -114,13 +115,13 @@ module CreateGithubRelease
|
|
114
115
|
# Uses the value of `next_release_version` to determine the tag name.
|
115
116
|
#
|
116
117
|
# @example By default, `next_release_tag` is based on `next_release_version`
|
117
|
-
# options = CreateGithubRelease::
|
118
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
118
119
|
# project = CreateGithubRelease::Project.new(options)
|
119
120
|
# project.next_release_version = '1.0.0'
|
120
121
|
# project.next_relase_tag #=> 'v1.0.0'
|
121
122
|
#
|
122
123
|
# @example `next_tag` can be set explicitly
|
123
|
-
# options = CreateGithubRelease::
|
124
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
124
125
|
# project = CreateGithubRelease::Project.new(options)
|
125
126
|
# project.next_release_tag = 'v1.0.0'
|
126
127
|
# project.next_relase_tag #=> 'v1.0.0'
|
@@ -140,13 +141,13 @@ module CreateGithubRelease
|
|
140
141
|
# If the next_release_tag does not exist, Date.today is returned.
|
141
142
|
#
|
142
143
|
# @example By default, `next_release_date` is based on `next_release_tag`
|
143
|
-
# options = CreateGithubRelease::
|
144
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
144
145
|
# project = CreateGithubRelease::Project.new(options)
|
145
146
|
# project.next_release_tag = 'v1.0.0'
|
146
147
|
# project.next_release_date #=> #<Date: 2023-02-01 ((2459189j,0s,0n),+0s,2299161j)>
|
147
148
|
#
|
148
149
|
# @example It can also be set explicitly
|
149
|
-
# options = CreateGithubRelease::
|
150
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
150
151
|
# project = CreateGithubRelease::Project.new(options)
|
151
152
|
# project.next_release_date = Date.new(2023, 2, 1)
|
152
153
|
# project.next_release_date #=> #<Date: 2023-02-01 ((2459189j,0s,0n),+0s,2299161j)>
|
@@ -172,7 +173,7 @@ module CreateGithubRelease
|
|
172
173
|
# `true` if the given tag exists in the local repository
|
173
174
|
#
|
174
175
|
# @example
|
175
|
-
# options = CreateGithubRelease::
|
176
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
176
177
|
# project = CreateGithubRelease::Project.new(options)
|
177
178
|
# project.tag_exist?('v1.0.0') #=> false
|
178
179
|
#
|
@@ -194,12 +195,12 @@ module CreateGithubRelease
|
|
194
195
|
# The version of the next release
|
195
196
|
#
|
196
197
|
# @example By default, `next_release_version` is based on the value returned by `semverify <release_type> --dry-run`
|
197
|
-
# options = CreateGithubRelease::
|
198
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
198
199
|
# project = CreateGithubRelease::Project.new(options)
|
199
200
|
# project.next_release_version #=> '1.0.0'
|
200
201
|
#
|
201
202
|
# @example It can also be set explicitly
|
202
|
-
# options = CreateGithubRelease::
|
203
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
203
204
|
# project = CreateGithubRelease::Project.new(options)
|
204
205
|
# project.next_release_version = '1.0.0
|
205
206
|
# project.next_release_version #=> '1.0.0'
|
@@ -221,13 +222,13 @@ module CreateGithubRelease
|
|
221
222
|
# Uses the value of `last_release_version` to determine the tag name.
|
222
223
|
#
|
223
224
|
# @example By default, `last_release_tag` is based on `last_release_version`
|
224
|
-
# options = CreateGithubRelease::
|
225
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
225
226
|
# project = CreateGithubRelease::Project.new(options)
|
226
227
|
# project.last_release_version = '0.0.1'
|
227
228
|
# project.last_relase_tag #=> 'v0.0.1'
|
228
229
|
#
|
229
230
|
# @example `last_release_tag` can be set explicitly
|
230
|
-
# options = CreateGithubRelease::
|
231
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
231
232
|
# project = CreateGithubRelease::Project.new(options)
|
232
233
|
# project.last_release_tag = 'v0.0.1'
|
233
234
|
# project.last_relase_tag #=> 'v0.0.1'
|
@@ -245,12 +246,12 @@ module CreateGithubRelease
|
|
245
246
|
# The version of the last release
|
246
247
|
#
|
247
248
|
# @example By default, `last_release_version` is based on the value returned by `semverify current`
|
248
|
-
# options = CreateGithubRelease::
|
249
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
249
250
|
# project = CreateGithubRelease::Project.new(options)
|
250
251
|
# project.last_release_version #=> '0.0.1'
|
251
252
|
#
|
252
253
|
# @example It can also be set explicitly
|
253
|
-
# options = CreateGithubRelease::
|
254
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
254
255
|
# project = CreateGithubRelease::Project.new(options)
|
255
256
|
# project.last_release_version = '0.0.1
|
256
257
|
# project.last_release_version #=> '0.0.1'
|
@@ -270,13 +271,13 @@ module CreateGithubRelease
|
|
270
271
|
# The name of the release branch being created
|
271
272
|
#
|
272
273
|
# @example By default, `release_branch` is based on the value returned by `next_release_tag`
|
273
|
-
# options = CreateGithubRelease::
|
274
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
274
275
|
# project = CreateGithubRelease::Project.new(options)
|
275
276
|
# project.next_release_tag = 'v1.0.0'
|
276
277
|
# project.release_branch #=> 'release-v1.0.0'
|
277
278
|
#
|
278
279
|
# @example It can also be set explicitly
|
279
|
-
# options = CreateGithubRelease::
|
280
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
280
281
|
# project = CreateGithubRelease::Project.new(options)
|
281
282
|
# project.next_release_branch = 'release-v1.0.0'
|
282
283
|
# project.next_release_branch #=> 'release-v1.0.0'
|
@@ -296,7 +297,7 @@ module CreateGithubRelease
|
|
296
297
|
# The URL of the page containing a list of the changes in the release
|
297
298
|
#
|
298
299
|
# @example By default, `release_log_url` is based on `remote_url`, `last_release_tag`, and `next_release_tag`
|
299
|
-
# options = CreateGithubRelease::
|
300
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
300
301
|
# project = CreateGithubRelease::Project.new(options)
|
301
302
|
# project.remote_url = URI.parse('https://github.com/org/repo')
|
302
303
|
# project.last_release_tag = 'v0.0.1'
|
@@ -304,7 +305,7 @@ module CreateGithubRelease
|
|
304
305
|
# project.release_log_url #=> #<URI::HTTPS https://github.com/org/repo/compare/v0.0.1..v1.0.0>
|
305
306
|
#
|
306
307
|
# @example It can also be set explicitly
|
307
|
-
# options = CreateGithubRelease::
|
308
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
308
309
|
# project = CreateGithubRelease::Project.new(options)
|
309
310
|
# project.release_log_url = URI.parse('https://github.com/org/repo/compare/v0.0.1..v1.0.0')
|
310
311
|
# project.release_log_url #=> #<URI::HTTPS https://github.com/org/repo/compare/v0.0.1..v1.0.0>
|
@@ -330,12 +331,12 @@ module CreateGithubRelease
|
|
330
331
|
# @note this must be one of the values accepted by the `semverify` command
|
331
332
|
#
|
332
333
|
# @example By default, this value comes from the options object
|
333
|
-
# options = CreateGithubRelease::
|
334
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
334
335
|
# project = CreateGithubRelease::Project.new(options)
|
335
336
|
# project.release_type #=> 'major'
|
336
337
|
#
|
337
338
|
# @example It can also be set explicitly
|
338
|
-
# options = CreateGithubRelease::
|
339
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
339
340
|
# project = CreateGithubRelease::Project.new(options)
|
340
341
|
# project.release_type = 'patch'
|
341
342
|
# project.release_type #=> 'patch'
|
@@ -350,19 +351,66 @@ module CreateGithubRelease
|
|
350
351
|
@release_type ||= options.release_type || raise(ArgumentError, 'release_type is required')
|
351
352
|
end
|
352
353
|
|
354
|
+
# @!attribute [rw] pre
|
355
|
+
#
|
356
|
+
# Set to true if a pre-release is be created
|
357
|
+
#
|
358
|
+
# @example By default, this value comes from the options object
|
359
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', pre: true, pre_type: 'alpha')
|
360
|
+
# project = CreateGithubRelease::Project.new(options)
|
361
|
+
# project.pre #=> 'true'
|
362
|
+
#
|
363
|
+
# @example It can also be set explicitly
|
364
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
365
|
+
# project = CreateGithubRelease::Project.new(options)
|
366
|
+
# project.pre = true
|
367
|
+
# project.pre #=> true
|
368
|
+
#
|
369
|
+
# @return [Boolean]
|
370
|
+
#
|
371
|
+
# @api public
|
372
|
+
#
|
373
|
+
def pre
|
374
|
+
@pre ||= options.pre
|
375
|
+
end
|
376
|
+
|
377
|
+
# @!attribute [rw] pre_type
|
378
|
+
#
|
379
|
+
# Set to the pre-release type to create. For example, "alpha", "beta", "pre", etc
|
380
|
+
#
|
381
|
+
# @example By default, this value comes from the options object
|
382
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', pre: true, pre_type: 'alpha')
|
383
|
+
# project = CreateGithubRelease::Project.new(options)
|
384
|
+
# project.pre_type #=> 'alpha'
|
385
|
+
#
|
386
|
+
# @example It can also be set explicitly
|
387
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
388
|
+
# project = CreateGithubRelease::Project.new(options)
|
389
|
+
# project.pre = true
|
390
|
+
# project.pre_type = 'alpha'
|
391
|
+
# project.pre_type #=> 'alpha'
|
392
|
+
#
|
393
|
+
# @return [String]
|
394
|
+
#
|
395
|
+
# @api public
|
396
|
+
#
|
397
|
+
def pre_type
|
398
|
+
@pre_type ||= options.pre_type
|
399
|
+
end
|
400
|
+
|
353
401
|
# @!attribute [rw] release_url
|
354
402
|
#
|
355
403
|
# The URL of the page containing a list of the changes in the release
|
356
404
|
#
|
357
405
|
# @example By default, `release_url` is based on `remote_url` and `next_release_tag`
|
358
|
-
# options = CreateGithubRelease::
|
406
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
359
407
|
# project = CreateGithubRelease::Project.new(options)
|
360
408
|
# project.remote_url = URI.parse('https://github.com/org/repo')
|
361
409
|
# project.next_release_tag = 'v1.0.0'
|
362
410
|
# project.release_url #=> #<URI::HTTPS https://github.com/org/repo/releases/tag/v1.0.0>
|
363
411
|
#
|
364
412
|
# @example It can also be set explicitly
|
365
|
-
# options = CreateGithubRelease::
|
413
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
366
414
|
# project = CreateGithubRelease::Project.new(options)
|
367
415
|
# project.release_url = URI.parse('https://github.com/org/repo/releases/tag/v1.0.0')
|
368
416
|
# project.release_url #=> #<URI::HTTPS https://github.com/org/repo/releases/tag/v1.0.0>
|
@@ -380,17 +428,17 @@ module CreateGithubRelease
|
|
380
428
|
# The git remote used to determine the repository url
|
381
429
|
#
|
382
430
|
# @example By default, 'origin' is used
|
383
|
-
# options = CreateGithubRelease::
|
431
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
384
432
|
# project = CreateGithubRelease::Project.new(options)
|
385
433
|
# project.remote #=> 'origin'
|
386
434
|
#
|
387
435
|
# @example It can also be set in the options
|
388
|
-
# options = CreateGithubRelease::
|
436
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', remote: 'upstream')
|
389
437
|
# project = CreateGithubRelease::Project.new(options)
|
390
438
|
# project.remote #=> 'upstream'
|
391
439
|
#
|
392
440
|
# @example It can also be set explicitly
|
393
|
-
# options = CreateGithubRelease::
|
441
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
394
442
|
# project = CreateGithubRelease::Project.new(options)
|
395
443
|
# project.remote = 'upstream'
|
396
444
|
# project.remote #=> 'upstream'
|
@@ -408,13 +456,13 @@ module CreateGithubRelease
|
|
408
456
|
# The base part of the remote url (e.g. 'https://github.com/')
|
409
457
|
#
|
410
458
|
# @example By default, this value is based on `remote_url`
|
411
|
-
# options = CreateGithubRelease::
|
459
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
412
460
|
# project = CreateGithubRelease::Project.new(options)
|
413
461
|
# project.remote_url = URI.parse('https://github.com/org/repo')
|
414
462
|
# project.remote #=> #<URI::HTTPS https://github.com/>
|
415
463
|
#
|
416
464
|
# @example It can also be set explicitly
|
417
|
-
# options = CreateGithubRelease::
|
465
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
418
466
|
# project = CreateGithubRelease::Project.new(options)
|
419
467
|
# project.remote_base_url = URI.parse('https://github.com/')
|
420
468
|
# project.remote_base_url #=> #<URI::HTTPS https://github.com/>
|
@@ -432,13 +480,13 @@ module CreateGithubRelease
|
|
432
480
|
# The git remote owner and repository name (e.g. 'org/repo')
|
433
481
|
#
|
434
482
|
# @example By default, this value is based on `remote_url`
|
435
|
-
# options = CreateGithubRelease::
|
483
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
436
484
|
# project = CreateGithubRelease::Project.new(options)
|
437
485
|
# project.remote_url = URI.parse('htps://github.com/org/repo')
|
438
486
|
# project.remote_repository #=> 'org/repo'
|
439
487
|
#
|
440
488
|
# @example It can also be set explicitly
|
441
|
-
# options = CreateGithubRelease::
|
489
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
442
490
|
# project = CreateGithubRelease::Project.new(options)
|
443
491
|
# project.remote_repository = 'org/repo'
|
444
492
|
#
|
@@ -455,12 +503,12 @@ module CreateGithubRelease
|
|
455
503
|
# The URL of the git remote repository (e.g. 'https://github.com/org/repo')
|
456
504
|
#
|
457
505
|
# @example By default, this value is based on `remote` and the `git remote get-url` command
|
458
|
-
# options = CreateGithubRelease::
|
506
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
459
507
|
# project = CreateGithubRelease::Project.new(options)
|
460
508
|
# project.remote #=> #<URI::HTTPS https://github.com/org/repo>
|
461
509
|
#
|
462
510
|
# @example It can also be set explicitly
|
463
|
-
# options = CreateGithubRelease::
|
511
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
464
512
|
# project = CreateGithubRelease::Project.new(options)
|
465
513
|
# project.remote_url = URI.parse('https://github.com/org/repo')
|
466
514
|
# project.remote_url #=> #<URI::HTTPS https://github.com/org/repo>
|
@@ -485,17 +533,19 @@ module CreateGithubRelease
|
|
485
533
|
# The path relative to the project root where the changelog is located
|
486
534
|
#
|
487
535
|
# @example By default, this value is 'CHANGELOG.md'
|
488
|
-
# options = CreateGithubRelease::
|
536
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
489
537
|
# project = CreateGithubRelease::Project.new(options)
|
490
538
|
# project.changelog_path #=> 'CHANGELOG.md'
|
491
539
|
#
|
492
540
|
# @example It can also be set in the options
|
493
|
-
# options = CreateGithubRelease::
|
541
|
+
# options = CreateGithubRelease::CommandLine::Options.new(
|
542
|
+
# release_type: 'major', changelog_path: 'docs/CHANGES.txt'
|
543
|
+
# )
|
494
544
|
# project = CreateGithubRelease::Project.new(options)
|
495
545
|
# project.remote_repository = 'docs/CHANGES.txt'
|
496
546
|
#
|
497
547
|
# @example It can also be set explicitly
|
498
|
-
# options = CreateGithubRelease::
|
548
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
499
549
|
# project = CreateGithubRelease::Project.new(options)
|
500
550
|
# project.changelog_path = 'docs/CHANGES.txt'
|
501
551
|
# project.remote_repository = 'docs/CHANGES.txt'
|
@@ -515,7 +565,7 @@ module CreateGithubRelease
|
|
515
565
|
# Calls `git log HEAD <next_release_tag>` to list the changes.
|
516
566
|
#
|
517
567
|
# @example By default, uses `git log`
|
518
|
-
# options = CreateGithubRelease::
|
568
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
519
569
|
# project = CreateGithubRelease::Project.new(options)
|
520
570
|
# pp project.changes
|
521
571
|
# [
|
@@ -524,7 +574,7 @@ module CreateGithubRelease
|
|
524
574
|
# ]
|
525
575
|
#
|
526
576
|
# @example It can also be set explicitly
|
527
|
-
# options = CreateGithubRelease::
|
577
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
528
578
|
# project = CreateGithubRelease::Project.new(options)
|
529
579
|
# project.changes = 'All the changes'
|
530
580
|
# project.changes #=> 'All the changes'
|
@@ -550,7 +600,7 @@ module CreateGithubRelease
|
|
550
600
|
# The formatted release description
|
551
601
|
#
|
552
602
|
# @example
|
553
|
-
# options = CreateGithubRelease::
|
603
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
554
604
|
# project = CreateGithubRelease::Project.new(options) do |p|
|
555
605
|
# p.remote_url = URI.parse('https://github.com/username/repo')
|
556
606
|
# p.last_release_tag = 'v0.1.0'
|
@@ -601,7 +651,7 @@ module CreateGithubRelease
|
|
601
651
|
#
|
602
652
|
# * e718690 Release v0.1.0 (#3)
|
603
653
|
# CHANGELOG
|
604
|
-
# options = CreateGithubRelease::
|
654
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
605
655
|
# project = CreateGithubRelease::Project.new(options) do |p|
|
606
656
|
# p.changelog_path = changelog_path
|
607
657
|
# end
|
@@ -634,7 +684,7 @@ module CreateGithubRelease
|
|
634
684
|
# last_release_changelog.
|
635
685
|
#
|
636
686
|
# @example
|
637
|
-
# options = CreateGithubRelease::
|
687
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
638
688
|
# project = CreateGithubRelease::Project.new(options) do |p|
|
639
689
|
# p.last_release_changelog = <<~CHANGELOG
|
640
690
|
# # Project Changelog
|
@@ -666,7 +716,7 @@ module CreateGithubRelease
|
|
666
716
|
# Show the project details as a string
|
667
717
|
#
|
668
718
|
# @example
|
669
|
-
# options = CreateGithubRelease::
|
719
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
670
720
|
# project = CreateGithubRelease::Project.new(options)
|
671
721
|
# puts projects.to_s
|
672
722
|
# default_branch: main
|
@@ -718,12 +768,12 @@ module CreateGithubRelease
|
|
718
768
|
# If `true` enables verbose output
|
719
769
|
#
|
720
770
|
# @example By default, this value is based on the `verbose` option
|
721
|
-
# options = CreateGithubRelease::
|
771
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', verbose: true)
|
722
772
|
# project = CreateGithubRelease::Project.new(options)
|
723
773
|
# project.verbose? #=> true
|
724
774
|
#
|
725
775
|
# @example It can also be set explicitly
|
726
|
-
# options = CreateGithubRelease::
|
776
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
727
777
|
# project = CreateGithubRelease::Project.new(options)
|
728
778
|
# project.verbose = true
|
729
779
|
# project.verbose? #=> true
|
@@ -743,12 +793,12 @@ module CreateGithubRelease
|
|
743
793
|
# If `true` supresses all output
|
744
794
|
#
|
745
795
|
# @example By default, this value is based on the `quiet` option
|
746
|
-
# options = CreateGithubRelease::
|
796
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', quiet: true)
|
747
797
|
# project = CreateGithubRelease::Project.new(options)
|
748
798
|
# project.quiet? #=> true
|
749
799
|
#
|
750
800
|
# @example It can also be set explicitly
|
751
|
-
# options = CreateGithubRelease::
|
801
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
752
802
|
# project = CreateGithubRelease::Project.new(options)
|
753
803
|
# project.quiet = true
|
754
804
|
# project.quiet? #=> true
|
@@ -768,12 +818,12 @@ module CreateGithubRelease
|
|
768
818
|
# true if release_type is 'first' otherwise false
|
769
819
|
#
|
770
820
|
# @example Returns true if release_type is 'first'
|
771
|
-
# options = CreateGithubRelease::
|
821
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'first')
|
772
822
|
# project = CreateGithubRelease::Project.new(options)
|
773
823
|
# project.first_release? #=> true
|
774
824
|
#
|
775
825
|
# @example Returnss false if release_type is not 'first'
|
776
|
-
# options = CreateGithubRelease::
|
826
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
777
827
|
# project = CreateGithubRelease::Project.new(options)
|
778
828
|
# project.first_release? #=> false
|
779
829
|
#
|
@@ -792,7 +842,7 @@ module CreateGithubRelease
|
|
792
842
|
# The SHA of the oldest commit that is an ancestor of HEAD
|
793
843
|
#
|
794
844
|
# @example
|
795
|
-
# options = CreateGithubRelease::
|
845
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
796
846
|
# project = CreateGithubRelease::Project.new(options)
|
797
847
|
# project.first_commit? #=> '1234567'
|
798
848
|
#
|
@@ -826,12 +876,22 @@ module CreateGithubRelease
|
|
826
876
|
# @return [String] The next version of the project
|
827
877
|
# @api private
|
828
878
|
def next_version
|
829
|
-
output =
|
879
|
+
output = `#{next_version_cmd}`
|
830
880
|
raise 'Could not determine next version using semverify' unless $CHILD_STATUS.success?
|
831
881
|
|
832
882
|
output.lines.last.chomp
|
833
883
|
end
|
834
884
|
|
885
|
+
# Construct the command used to get the next version
|
886
|
+
# @return [String]
|
887
|
+
# @api private
|
888
|
+
def next_version_cmd
|
889
|
+
cmd = "semverify next-#{release_type}"
|
890
|
+
cmd << ' --pre' if pre
|
891
|
+
cmd << " --pre-type=#{pre_type}" if pre_type
|
892
|
+
cmd << ' --dry-run'
|
893
|
+
end
|
894
|
+
|
835
895
|
# Setup versions and tags for a first release
|
836
896
|
# @return [void]
|
837
897
|
# @api private
|
@@ -24,7 +24,7 @@ module CreateGithubRelease
|
|
24
24
|
# assertions = CreateGithubRelease::ReleaseAssertions.new(options)
|
25
25
|
# assertions.options # => #<CreateGithubRelease::Options:0x00007f9b0a0b0a00>
|
26
26
|
#
|
27
|
-
# @return [CreateGithubRelease::
|
27
|
+
# @return [CreateGithubRelease::CommandLine::Options]
|
28
28
|
attr_reader :options
|
29
29
|
|
30
30
|
# Create a new instance of ReleaseAssertions
|
@@ -24,7 +24,7 @@ module CreateGithubRelease
|
|
24
24
|
# tasks = CreateGithubRelease::ReleaseTasks.new(options)
|
25
25
|
# tasks.options # => #<CreateGithubRelease::Options:0x00007f9b0a0b0a00>
|
26
26
|
#
|
27
|
-
# @return [CreateGithubRelease::
|
27
|
+
# @return [CreateGithubRelease::CommandLine::Options]
|
28
28
|
attr_reader :options
|
29
29
|
|
30
30
|
# Create a new instance of ReleaseTasks
|
@@ -15,7 +15,7 @@ module CreateGithubRelease
|
|
15
15
|
# @example
|
16
16
|
# require 'create_github_release'
|
17
17
|
#
|
18
|
-
# options = CreateGithubRelease::
|
18
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
|
19
19
|
# project = CreateGithubRelease::Project.new(options)
|
20
20
|
# task = CreateGithubRelease::Tasks::CommitRelease.new(project)
|
21
21
|
# begin
|
@@ -16,7 +16,7 @@ module CreateGithubRelease
|
|
16
16
|
# @example
|
17
17
|
# require 'create_github_release'
|
18
18
|
#
|
19
|
-
# options = CreateGithubRelease::
|
19
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
|
20
20
|
# project = CreateGithubRelease::Project.new(options)
|
21
21
|
# task = CreateGithubRelease::Tasks::CreateGithubRelease.new(project)
|
22
22
|
# begin
|