create_github_release 1.4.0 → 1.5.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/create_github_release.gemspec +1 -1
- data/lib/create_github_release/assertions/release_pr_label_exists.rb +56 -0
- data/lib/create_github_release/assertions.rb +1 -0
- data/lib/create_github_release/command_line/options.rb +7 -0
- data/lib/create_github_release/command_line/parser.rb +11 -1
- data/lib/create_github_release/command_line.rb +1 -1
- data/lib/create_github_release/project.rb +30 -1
- data/lib/create_github_release/release_assertions.rb +2 -1
- data/lib/create_github_release/tasks/create_release_pull_request.rb +18 -1
- data/lib/create_github_release/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 312da511d779225d398925e66001d292366c70883f24c739b0e6288e0082891f
|
4
|
+
data.tar.gz: d5dc70f33050b9b1cbd0d8d228782c294bca9c73143e0b4724869224c802f59d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3bd21e337933bb66b61f8eda03f7b9e932b547427161a2970d61d6d7f6009a395dc5db64cf3ac56b44480bac4bc5b6c9903b2702fc606803533373b6691db3c
|
7
|
+
data.tar.gz: 6302667c91366596ca30aacfa2114e7c62bbfbfdaa5ff5f6c0b7b05af4e52da82e4e4dd9d43d17172474ea5146bdfeadb6c6b45c8fbc24564e0d5763a6c7a6b5
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## v1.5.0 (2024-09-10)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.4.0..v1.5.0)
|
11
|
+
|
12
|
+
Changes since v1.4.0:
|
13
|
+
|
14
|
+
* fdc35ee Optionally apply a release label to release PRs
|
15
|
+
* c122e7f Add Semver PR Label Check workflow
|
16
|
+
* afc3883 Update to the latest version of the CodeClimate test coverage reporter
|
17
|
+
* 0a57cbd Fix test errors due to array being in different order
|
18
|
+
* 30d46fb Fix rubocop offense from new Gemspec/AddRuntimeDependency cop
|
19
|
+
|
8
20
|
## v1.4.0 (2024-05-10)
|
9
21
|
|
10
22
|
[Full Changelog](https://jcouball@github.com/main-branch/create_github_release/compare/v1.3.4..v1.4.0)
|
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
36
36
|
spec.require_paths = ['lib']
|
37
37
|
|
38
|
-
spec.
|
38
|
+
spec.add_dependency 'version_boss', '~> 0.1'
|
39
39
|
|
40
40
|
spec.add_development_dependency 'bundler-audit', '~> 0.9'
|
41
41
|
spec.add_development_dependency 'debug', '~> 1.9'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
require 'create_github_release/assertion_base'
|
5
|
+
|
6
|
+
module CreateGithubRelease
|
7
|
+
module Assertions
|
8
|
+
# Assert that the release tag does not exist in the local repository
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
class ReleasePrLabelExists < AssertionBase
|
13
|
+
# Assert that the release pr label is defined in GitHub
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# require 'create_github_release'
|
17
|
+
#
|
18
|
+
# options = CreateGithubRelease::Options.new { |o| o.release_type = 'major', o.release_pr_label = 'release' }
|
19
|
+
# assertion = CreateGithubRelease::Assertions::LastReleaseTagExists.new(options)
|
20
|
+
# begin
|
21
|
+
# assertion.assert
|
22
|
+
# puts 'Assertion passed'
|
23
|
+
# rescue SystemExit
|
24
|
+
# puts 'Assertion failed'
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# @return [void]
|
28
|
+
#
|
29
|
+
# @raise [SystemExit] if the assertion fails
|
30
|
+
#
|
31
|
+
def assert
|
32
|
+
return if project.release_pr_label.nil?
|
33
|
+
|
34
|
+
print "Checking that release pr label '#{project.release_pr_label}' exists..."
|
35
|
+
|
36
|
+
if labels.include?(project.release_pr_label)
|
37
|
+
puts 'OK'
|
38
|
+
else
|
39
|
+
error "Release pr label '#{project.release_pr_label}' does not exist"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# Get the list of labels for the current repository from GitHub
|
46
|
+
# @return [Array<String>] The list of labels for the current repository
|
47
|
+
# @api private
|
48
|
+
def labels
|
49
|
+
output = `gh label list`
|
50
|
+
error 'Could not list pr labels' unless $CHILD_STATUS.success?
|
51
|
+
|
52
|
+
output.lines.map(&:chomp).map { |line| line.split("\t").first }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -21,5 +21,6 @@ require_relative 'assertions/local_release_tag_does_not_exist'
|
|
21
21
|
require_relative 'assertions/no_staged_changes'
|
22
22
|
require_relative 'assertions/no_uncommitted_changes'
|
23
23
|
require_relative 'assertions/on_default_branch'
|
24
|
+
require_relative 'assertions/release_pr_label_exists'
|
24
25
|
require_relative 'assertions/remote_release_branch_does_not_exist'
|
25
26
|
require_relative 'assertions/remote_release_tag_does_not_exist'
|
@@ -63,6 +63,13 @@ module CreateGithubRelease
|
|
63
63
|
# @return [String]
|
64
64
|
# @api public
|
65
65
|
|
66
|
+
# @!attribute release_pr_label [rw] the label to apply to the release pull request
|
67
|
+
# @example
|
68
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_pr_label: 'release')
|
69
|
+
# options.release_pr_label #=> 'release'
|
70
|
+
# @return [String]
|
71
|
+
# @api public
|
72
|
+
|
66
73
|
# @attribute changelog_path [rw] the path to the changelog file
|
67
74
|
# @example
|
68
75
|
# options = CreateGithubRelease::CommandLine::Options.new(changelog_path: 'CHANGELOG.md')
|
@@ -140,10 +140,20 @@ module CreateGithubRelease
|
|
140
140
|
%i[
|
141
141
|
define_help_option define_default_branch_option define_release_branch_option define_pre_option
|
142
142
|
define_pre_type_option define_remote_option define_last_release_version_option define_version_option
|
143
|
-
define_next_release_version_option define_changelog_path_option
|
143
|
+
define_next_release_version_option define_release_pr_label_option define_changelog_path_option
|
144
|
+
define_quiet_option define_verbose_option
|
144
145
|
].each { |m| send(m) }
|
145
146
|
end
|
146
147
|
|
148
|
+
# Define the release_pr_label option which requires a value
|
149
|
+
# @return [void]
|
150
|
+
# @api private
|
151
|
+
def define_release_pr_label_option
|
152
|
+
option_parser.on('--release-pr-label=LABEL', 'The label to apply to the release pull request') do |label|
|
153
|
+
options.release_pr_label = label
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
147
157
|
# Define the pre option
|
148
158
|
# @return [void]
|
149
159
|
# @api private
|
@@ -32,7 +32,7 @@ module CreateGithubRelease
|
|
32
32
|
# @return [Array<Symbol>]
|
33
33
|
ALLOWED_OPTIONS = %i[
|
34
34
|
release_type pre pre_type default_branch release_branch remote last_release_version
|
35
|
-
next_release_version changelog_path quiet verbose
|
35
|
+
next_release_version release_pr_label changelog_path quiet verbose
|
36
36
|
].freeze
|
37
37
|
end
|
38
38
|
end
|
@@ -69,7 +69,8 @@ module CreateGithubRelease
|
|
69
69
|
:release_type, :pre, :pre_type, :release_url, :remote, :remote_base_url,
|
70
70
|
:remote_repository, :remote_url, :changelog_path, :changes,
|
71
71
|
:next_release_description, :last_release_changelog, :next_release_changelog,
|
72
|
-
:first_commit, :verbose, :quiet, :release_pr_number, :release_pr_url
|
72
|
+
:first_commit, :verbose, :quiet, :release_pr_number, :release_pr_url,
|
73
|
+
:release_pr_label
|
73
74
|
|
74
75
|
# attr_writer :first_release
|
75
76
|
|
@@ -292,6 +293,34 @@ module CreateGithubRelease
|
|
292
293
|
@release_branch ||= options.release_branch || "release-#{next_release_tag}"
|
293
294
|
end
|
294
295
|
|
296
|
+
# @!attribute [rw] release_pr_label
|
297
|
+
#
|
298
|
+
# The name of the label to apply to the release pull request
|
299
|
+
#
|
300
|
+
# @example By default, `release_pr_label` is nil indicating no label should be applied
|
301
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
302
|
+
# project = CreateGithubRelease::Project.new(options)
|
303
|
+
# project.release_pr_label #=> nil
|
304
|
+
#
|
305
|
+
# @example Set to 'release'
|
306
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', release_pr_label: 'release')
|
307
|
+
# project = CreateGithubRelease::Project.new(options)
|
308
|
+
# project.release_pr_label #=> 'release'
|
309
|
+
#
|
310
|
+
# @example It can also be set explicitly
|
311
|
+
# options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
|
312
|
+
# project = CreateGithubRelease::Project.new(options)
|
313
|
+
# project.release_pr_label = 'release' # could be set to nil to remove the label
|
314
|
+
# project.release_pr_label #=> 'release'
|
315
|
+
#
|
316
|
+
# @return [String, nil]
|
317
|
+
#
|
318
|
+
# @api public
|
319
|
+
#
|
320
|
+
def release_pr_label
|
321
|
+
@release_pr_label ||= options.release_pr_label || nil
|
322
|
+
end
|
323
|
+
|
295
324
|
# @!attribute [rw] release_log_url
|
296
325
|
#
|
297
326
|
# The URL of the page containing a list of the changes in the release
|
@@ -61,7 +61,8 @@ module CreateGithubRelease
|
|
61
61
|
CreateGithubRelease::Assertions::LocalReleaseBranchDoesNotExist,
|
62
62
|
CreateGithubRelease::Assertions::RemoteReleaseBranchDoesNotExist,
|
63
63
|
CreateGithubRelease::Assertions::GhCommandExists,
|
64
|
-
CreateGithubRelease::Assertions::GhAuthenticated
|
64
|
+
CreateGithubRelease::Assertions::GhAuthenticated,
|
65
|
+
CreateGithubRelease::Assertions::ReleasePrLabelExists
|
65
66
|
].freeze
|
66
67
|
|
67
68
|
# Run all assertions
|
@@ -48,7 +48,7 @@ module CreateGithubRelease
|
|
48
48
|
print 'Creating GitHub pull request...'
|
49
49
|
tag = project.next_release_tag
|
50
50
|
default_branch = project.default_branch
|
51
|
-
|
51
|
+
`#{command(tag, path, default_branch)}`
|
52
52
|
if $CHILD_STATUS.success?
|
53
53
|
puts 'OK'
|
54
54
|
else
|
@@ -56,6 +56,23 @@ module CreateGithubRelease
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
# The command to create the release pull request
|
60
|
+
# @param tag [String] The tag for the release
|
61
|
+
# @param path [String] The path to the file with the PR body
|
62
|
+
# @param default_branch [String] The default branch for the repository
|
63
|
+
# @return [String] The command to create the release pull request
|
64
|
+
# @api private
|
65
|
+
def command(tag, path, default_branch)
|
66
|
+
command = [
|
67
|
+
'gh', 'pr', 'create',
|
68
|
+
'--title', "'Release #{tag}'",
|
69
|
+
'--body-file', "'#{path}'",
|
70
|
+
'--base', "'#{default_branch}'"
|
71
|
+
]
|
72
|
+
command += ['--label', "'#{project.release_pr_label}'"] if project.release_pr_label
|
73
|
+
command.join(' ')
|
74
|
+
end
|
75
|
+
|
59
76
|
# Write the changelog to a new temporary file
|
60
77
|
# @return [String] the path to the temporary file
|
61
78
|
# @raise [SystemExit] if the temp could not be created
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: create_github_release
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: version_boss
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- lib/create_github_release/assertions/no_staged_changes.rb
|
220
220
|
- lib/create_github_release/assertions/no_uncommitted_changes.rb
|
221
221
|
- lib/create_github_release/assertions/on_default_branch.rb
|
222
|
+
- lib/create_github_release/assertions/release_pr_label_exists.rb
|
222
223
|
- lib/create_github_release/assertions/remote_release_branch_does_not_exist.rb
|
223
224
|
- lib/create_github_release/assertions/remote_release_tag_does_not_exist.rb
|
224
225
|
- lib/create_github_release/backtick_debug.rb
|
@@ -250,8 +251,8 @@ metadata:
|
|
250
251
|
allowed_push_host: https://rubygems.org
|
251
252
|
homepage_uri: https://github.com/main-branch/create_github_release
|
252
253
|
source_code_uri: https://github.com/main-branch/create_github_release
|
253
|
-
changelog_uri: https://rubydoc.info/gems/create_github_release/1.
|
254
|
-
documentation_uri: https://rubydoc.info/gems/create_github_release/1.
|
254
|
+
changelog_uri: https://rubydoc.info/gems/create_github_release/1.5.0/file/CHANGELOG.md
|
255
|
+
documentation_uri: https://rubydoc.info/gems/create_github_release/1.5.0
|
255
256
|
rubygems_mfa_required: 'true'
|
256
257
|
post_install_message:
|
257
258
|
rdoc_options: []
|
@@ -268,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
269
|
- !ruby/object:Gem::Version
|
269
270
|
version: '0'
|
270
271
|
requirements: []
|
271
|
-
rubygems_version: 3.5.
|
272
|
+
rubygems_version: 3.5.16
|
272
273
|
signing_key:
|
273
274
|
specification_version: 4
|
274
275
|
summary: A script to create a GitHub release for a Ruby Gem
|