create_github_release 1.2.0 → 1.3.1
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 +18 -0
- data/README.md +1 -1
- data/exe/revert-github-release +166 -0
- data/lib/create_github_release/command_line/parser.rb +25 -15
- data/lib/create_github_release/tasks/update_version.rb +4 -1
- data/lib/create_github_release/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8dd471fba24b22c130b2d03d534e44b46753300a3e41ff08bb8d68b93e6cdee
|
4
|
+
data.tar.gz: 51d08847e10a5856b3a94fd7ee774ca104e47db954bdf73ea1fc4749529600b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f926991f50c625bdbef00025bdb7f618268c1e1eba763bd320ef38e94885ea3da8a626e5f3b3747e6def444653fa33cb88bcc751cf0fa1403dee518a704afa7c
|
7
|
+
data.tar.gz: e520e45d0015579988f9bbb554afe065e2169905be3dcf6fd36d8bf0191f157eb865080db6205d12acccbc390e23543ca7fbcbffa324c75e99bda61e3bc7b9b9
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,24 @@ 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.3.1 (2024-01-08)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.3.0..v1.3.1)
|
11
|
+
|
12
|
+
Changes since v1.3.0:
|
13
|
+
|
14
|
+
* 7015e17 Require create_github_release/version where the gem version is needed (#50)
|
15
|
+
|
16
|
+
## v1.3.0 (2024-01-08)
|
17
|
+
|
18
|
+
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.2.0..v1.3.0)
|
19
|
+
|
20
|
+
Changes since v1.2.0:
|
21
|
+
|
22
|
+
* fa6ddb2 Add option to create and revert scripts to show version (#48)
|
23
|
+
* 954bea7 Add revert-github-release script (#47)
|
24
|
+
* 564267a Correctly use semverify to increment pre-release versions (#46)
|
25
|
+
|
8
26
|
## v1.2.0 (2024-01-07)
|
9
27
|
|
10
28
|
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.1.0..v1.2.0)
|
data/README.md
CHANGED
@@ -0,0 +1,166 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# This script is used to revert a release that was created with the create-github-release gem
|
5
|
+
# It will delete the release branch and tag locally and remotely
|
6
|
+
|
7
|
+
require 'create_github_release'
|
8
|
+
require 'create_github_release/version'
|
9
|
+
|
10
|
+
require 'English'
|
11
|
+
require 'optparse'
|
12
|
+
|
13
|
+
# Options for running this script
|
14
|
+
class Options
|
15
|
+
attr_writer :default_branch, :release_version, :release_tag, :release_branch, :current_branch, :remote
|
16
|
+
|
17
|
+
def default_branch = @default_branch ||= 'main'
|
18
|
+
def release_version = @release_version ||= `semverify current`.chomp
|
19
|
+
def release_tag = @release_tag ||= "v#{release_version}"
|
20
|
+
def release_branch = @release_branch ||= "release-#{release_tag}"
|
21
|
+
def current_branch = @current_branch ||= `git rev-parse --abbrev-ref HEAD`.chomp
|
22
|
+
def remote = @remote ||= 'origin'
|
23
|
+
end
|
24
|
+
|
25
|
+
# Parse the command line options for this script
|
26
|
+
class Parser
|
27
|
+
# Create a new command line parser
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# parser = CommandLineParser.new
|
31
|
+
#
|
32
|
+
def initialize
|
33
|
+
@option_parser = OptionParser.new
|
34
|
+
define_options
|
35
|
+
@options = Options.new
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_reader :option_parser, :options
|
39
|
+
|
40
|
+
# Parse the command line arguements returning the options
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# options = Parser.new.parse(*ARGV)
|
44
|
+
#
|
45
|
+
# @param args [Array<String>] the command line arguments
|
46
|
+
#
|
47
|
+
# @return [Options] the options
|
48
|
+
#
|
49
|
+
def parse(*args)
|
50
|
+
begin
|
51
|
+
option_parser.parse!(remaining_args = args.dup)
|
52
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
53
|
+
report_errors(e.message)
|
54
|
+
end
|
55
|
+
parse_remaining_args(remaining_args)
|
56
|
+
options
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
# Output an error message and useage to stderr and exit
|
62
|
+
# @return [void]
|
63
|
+
# @api private
|
64
|
+
def report_errors(*errors)
|
65
|
+
warn error_message(errors)
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
|
69
|
+
# The command line template as a string
|
70
|
+
# @return [String]
|
71
|
+
# @api private
|
72
|
+
def command_template
|
73
|
+
<<~COMMAND
|
74
|
+
#{File.basename($PROGRAM_NAME)} [--help]
|
75
|
+
COMMAND
|
76
|
+
end
|
77
|
+
|
78
|
+
BANNER = <<~BANNER.freeze
|
79
|
+
Usage:
|
80
|
+
#{File.basename($PROGRAM_NAME)} [--help | --version]
|
81
|
+
|
82
|
+
This script reverts the effect of running the create-github-release script.
|
83
|
+
It must be run in the root directory of the work tree with the release
|
84
|
+
branch checked out (which is the state create-github-release leaves you in).
|
85
|
+
|
86
|
+
This script should be run beefore the release PR is merged.
|
87
|
+
|
88
|
+
This script removes the release branch and release tag both in the local
|
89
|
+
repository and on the remote. Deleting the branch on GitHub will close the
|
90
|
+
GitHub PR automatically.
|
91
|
+
|
92
|
+
Options:
|
93
|
+
BANNER
|
94
|
+
|
95
|
+
# Define the options for OptionParser
|
96
|
+
# @return [void]
|
97
|
+
# @api private
|
98
|
+
def define_options
|
99
|
+
option_parser.banner = BANNER
|
100
|
+
%i[
|
101
|
+
define_help_option define_version_option
|
102
|
+
].each { |m| send(m) }
|
103
|
+
end
|
104
|
+
|
105
|
+
# Define the help option
|
106
|
+
# @return [void]
|
107
|
+
# @api private
|
108
|
+
def define_help_option
|
109
|
+
option_parser.on_tail('-h', '--help', 'Show this message') do
|
110
|
+
puts option_parser
|
111
|
+
exit 0
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Define the version option
|
116
|
+
# @return [void]
|
117
|
+
# @api private
|
118
|
+
def define_version_option
|
119
|
+
option_parser.on_tail('-v', '--version', 'Output the version of this script') do
|
120
|
+
puts CreateGithubRelease::VERSION
|
121
|
+
exit 0
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Parse non-option arguments
|
126
|
+
# @return [void]
|
127
|
+
# @api private
|
128
|
+
def parse_remaining_args(remaining_args)
|
129
|
+
# There should be no remaining args
|
130
|
+
report_errors('Too many args') unless remaining_args.empty?
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def in_work_tree? = `git rev-parse --is-inside-work-tree 2>/dev/null`.chomp == 'true'
|
135
|
+
def in_root_directory? = `git rev-parse --show-toplevel 2>/dev/null`.chomp == Dir.pwd
|
136
|
+
|
137
|
+
def ref_exists?(name)
|
138
|
+
`git rev-parse --verify #{name} >/dev/null 2>&1`
|
139
|
+
$CHILD_STATUS.success?
|
140
|
+
end
|
141
|
+
|
142
|
+
unless in_work_tree? && in_root_directory?
|
143
|
+
warn 'ERROR: Not in the root directory of a Git work tree'
|
144
|
+
exit 1
|
145
|
+
end
|
146
|
+
|
147
|
+
# Parse the command line options
|
148
|
+
options = Parser.new.parse(*ARGV)
|
149
|
+
|
150
|
+
unless options.release_branch == options.current_branch
|
151
|
+
warn "ERROR: The current branch '#{options.current_branch}' is not the release branch for #{options.release_version}"
|
152
|
+
exit 1
|
153
|
+
end
|
154
|
+
|
155
|
+
unless ref_exists?(options.default_branch)
|
156
|
+
warn "ERROR: The default branch '#{options.default_branch}' does not exist"
|
157
|
+
exit 1
|
158
|
+
end
|
159
|
+
|
160
|
+
`git checkout #{options.default_branch} >/dev/null`
|
161
|
+
`git branch -D #{options.release_branch} >/dev/null`
|
162
|
+
`git tag -d #{options.release_tag} >/dev/null`
|
163
|
+
`git push #{options.remote} --delete #{options.release_branch} >/dev/null`
|
164
|
+
`git push #{options.remote} --delete #{options.release_tag} >/dev/null`
|
165
|
+
|
166
|
+
puts "Reverted release #{options.release_version}"
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'English'
|
4
4
|
require 'optparse'
|
5
5
|
require 'create_github_release/command_line/options'
|
6
|
+
require 'create_github_release/version'
|
6
7
|
|
7
8
|
module CreateGithubRelease
|
8
9
|
module CommandLine
|
@@ -118,28 +119,27 @@ module CreateGithubRelease
|
|
118
119
|
exit 1
|
119
120
|
end
|
120
121
|
|
121
|
-
# The
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
122
|
+
# The banner for the option parser
|
123
|
+
BANNER = <<~BANNER.freeze
|
124
|
+
Usage:
|
125
|
+
#{File.basename($PROGRAM_NAME)} --help | RELEASE_TYPE [options]
|
126
|
+
|
127
|
+
Version #{CreateGithubRelease::VERSION}
|
128
|
+
|
129
|
+
RELEASE_TYPE must be 'major', 'minor', 'patch', 'pre', 'release', or 'first'
|
130
|
+
|
131
|
+
Options:
|
132
|
+
BANNER
|
129
133
|
|
130
134
|
# Define the options for OptionParser
|
131
135
|
# @return [void]
|
132
136
|
# @api private
|
133
137
|
def define_options
|
134
138
|
# @sg-ignore
|
135
|
-
option_parser.banner =
|
136
|
-
option_parser.separator ''
|
137
|
-
option_parser.separator "RELEASE_TYPE must be 'major', 'minor', 'patch', 'pre', 'release', or 'first'"
|
138
|
-
option_parser.separator ''
|
139
|
-
option_parser.separator 'Options:'
|
139
|
+
option_parser.banner = BANNER
|
140
140
|
%i[
|
141
141
|
define_help_option define_default_branch_option define_release_branch_option define_pre_option
|
142
|
-
define_pre_type_option define_remote_option define_last_release_version_option
|
142
|
+
define_pre_type_option define_remote_option define_last_release_version_option define_version_option
|
143
143
|
define_next_release_version_option define_changelog_path_option define_quiet_option define_verbose_option
|
144
144
|
].each { |m| send(m) }
|
145
145
|
end
|
@@ -176,7 +176,7 @@ module CreateGithubRelease
|
|
176
176
|
# @return [void]
|
177
177
|
# @api private
|
178
178
|
def define_verbose_option
|
179
|
-
option_parser.on('-
|
179
|
+
option_parser.on('-V', '--[no-]verbose', 'Show extra output') do |verbose|
|
180
180
|
options.verbose = verbose
|
181
181
|
end
|
182
182
|
end
|
@@ -247,6 +247,16 @@ module CreateGithubRelease
|
|
247
247
|
options.changelog_path = name
|
248
248
|
end
|
249
249
|
end
|
250
|
+
|
251
|
+
# Define the version option
|
252
|
+
# @return [void]
|
253
|
+
# @api private
|
254
|
+
def define_version_option
|
255
|
+
option_parser.on_tail('-v', '--version', 'Output the version of this script') do
|
256
|
+
puts CreateGithubRelease::VERSION
|
257
|
+
exit 0
|
258
|
+
end
|
259
|
+
end
|
250
260
|
end
|
251
261
|
# rubocop:enable Metrics/ClassLength
|
252
262
|
end
|
@@ -43,7 +43,10 @@ module CreateGithubRelease
|
|
43
43
|
# @return [void]
|
44
44
|
# @api private
|
45
45
|
def increment_version
|
46
|
-
|
46
|
+
command = "semverify next-#{project.release_type}"
|
47
|
+
command += ' --pre' if project.pre
|
48
|
+
command += " --pre-type=#{project.pre_type}" if project.pre_type
|
49
|
+
`#{command}`
|
47
50
|
error 'Could not increment version' unless $CHILD_STATUS.success?
|
48
51
|
end
|
49
52
|
|
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.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semverify
|
@@ -185,6 +185,7 @@ email:
|
|
185
185
|
- jcouball@yahoo.com
|
186
186
|
executables:
|
187
187
|
- create-github-release
|
188
|
+
- revert-github-release
|
188
189
|
extensions: []
|
189
190
|
extra_rdoc_files: []
|
190
191
|
files:
|
@@ -201,6 +202,7 @@ files:
|
|
201
202
|
- Rakefile
|
202
203
|
- create_github_release.gemspec
|
203
204
|
- exe/create-github-release
|
205
|
+
- exe/revert-github-release
|
204
206
|
- lib/create_github_release.rb
|
205
207
|
- lib/create_github_release/assertion_base.rb
|
206
208
|
- lib/create_github_release/assertions.rb
|
@@ -248,8 +250,8 @@ metadata:
|
|
248
250
|
allowed_push_host: https://rubygems.org
|
249
251
|
homepage_uri: https://github.com/main-branch/create_github_release
|
250
252
|
source_code_uri: https://github.com/main-branch/create_github_release
|
251
|
-
changelog_uri: https://rubydoc.info/gems/create_github_release/1.
|
252
|
-
documentation_uri: https://rubydoc.info/gems/create_github_release/1.
|
253
|
+
changelog_uri: https://rubydoc.info/gems/create_github_release/1.3.1/file/CHANGELOG.md
|
254
|
+
documentation_uri: https://rubydoc.info/gems/create_github_release/1.3.1
|
253
255
|
rubygems_mfa_required: 'true'
|
254
256
|
post_install_message:
|
255
257
|
rdoc_options: []
|