create_github_release 1.1.0 → 1.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/.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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04e71e4f65e274c0bea5a1629d80b2f88689e547f07fa644b51cbaf480877122
|
4
|
+
data.tar.gz: f105cc39f93ff1c3f3cb85f8d675fb18163a4f1054130c3f3fa1871d7c22c66f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c1b778ad46a00c912850f1cb09daacf6615f27cf1c8fbddaaa5f02a7c4e7cbc63a617868e431dca80aae6500b070c5d1b7fc2c50c7ccc1b0e363e2a332a122f
|
7
|
+
data.tar.gz: 7f2bd65c4ac7cadf6ec45a7c4fbf914a8287b7c99bab509a2618161002978bdcd805d8236161a2e6c47827de9a79577ca62eae5f47986c4ac6491c91df0cb850
|
data/.yardopts
CHANGED
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.0 (2024-01-08)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.2.0..v1.3.0)
|
11
|
+
|
12
|
+
Changes since v1.2.0:
|
13
|
+
|
14
|
+
* fa6ddb2 Add option to create and revert scripts to show version (#48)
|
15
|
+
* 954bea7 Add revert-github-release script (#47)
|
16
|
+
* 564267a Correctly use semverify to increment pre-release versions (#46)
|
17
|
+
|
18
|
+
## v1.2.0 (2024-01-07)
|
19
|
+
|
20
|
+
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.1.0..v1.2.0)
|
21
|
+
|
22
|
+
Changes since v1.1.0:
|
23
|
+
|
24
|
+
* 80da449 Add support for pre-release versions (#43)
|
25
|
+
|
8
26
|
## v1.1.0 (2023-10-15)
|
9
27
|
|
10
28
|
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.0.0..v1.1.0)
|
data/README.md
CHANGED
@@ -5,34 +5,46 @@
|
|
5
5
|
[](https://codeclimate.com/github/main-branch/create_github_release/maintainability)
|
6
6
|
[](https://codeclimate.com/github/main-branch/create_github_release/test_coverage)
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
When run in your gem's git worktree, the `create-github-release` script does the
|
9
|
+
following:
|
10
|
+
|
11
|
+
* bumps the gem's version following SemVer,
|
12
|
+
* updates the gems's changelog,
|
13
|
+
* creates a new release branch and release tag,
|
14
|
+
* commits the version and changelog changes to the release branch,
|
15
|
+
* pushes these changes to GitHub and creates a PR to merge the release branch to the
|
16
|
+
default branch
|
17
|
+
|
18
|
+
Since this script builds a changelog by listing the commits since the last release, it
|
19
|
+
works best if you are disciplined about squashing PR commits to the minimum number of
|
20
|
+
commits necessary (usually one) in order to avoid a noisy changelog.
|
21
|
+
|
22
|
+
Tested on Ruby 3.0+
|
23
|
+
|
24
|
+
* [Installation](#installation)
|
25
|
+
* [Usage](#usage)
|
26
|
+
* [First release using this script when there were NO prior releases](#first-release-using-this-script-when-there-were-no-prior-releases)
|
27
|
+
* [First release using this script when there were prior releases](#first-release-using-this-script-when-there-were-prior-releases)
|
28
|
+
* [Subsequent releases using this script](#subsequent-releases-using-this-script)
|
29
|
+
* [Pre-release versions](#pre-release-versions)
|
30
|
+
* [Creating the first pre-release version for a release](#creating-the-first-pre-release-version-for-a-release)
|
31
|
+
* [Creating subsequent pre-releases](#creating-subsequent-pre-releases)
|
32
|
+
* [Changing the pre-release type](#changing-the-pre-release-type)
|
33
|
+
* [Creating the release after pre-releases](#creating-the-release-after-pre-releases)
|
23
34
|
* [After Running create-github-release](#after-running-create-github-release)
|
24
|
-
|
25
|
-
* [
|
26
|
-
* [
|
27
|
-
|
28
|
-
|
35
|
+
* [FAQ](#faq)
|
36
|
+
* [What if I want to reverse the changes made by this script?](#what-if-i-want-to-reverse-the-changes-made-by-this-script)
|
37
|
+
* [How is the changelog updated?](#how-is-the-changelog-updated)
|
38
|
+
* [Development](#development)
|
39
|
+
* [Contributing](#contributing)
|
40
|
+
* [License](#license)
|
29
41
|
|
30
42
|
## Installation
|
31
43
|
|
32
44
|
Add `create_github_release` as a development dependency in your project's gemspec:
|
33
45
|
|
34
46
|
```ruby
|
35
|
-
spec.add_development_dependency 'create_github_release'
|
47
|
+
spec.add_development_dependency 'create_github_release'
|
36
48
|
```
|
37
49
|
|
38
50
|
and then install using `bundle update`.
|
@@ -45,16 +57,18 @@ This gem installs the `create-guthub-release` command line tool:
|
|
45
57
|
Usage:
|
46
58
|
create-github-release --help | RELEASE_TYPE [options]
|
47
59
|
|
48
|
-
RELEASE_TYPE must be 'major', 'minor', 'patch', or 'first'
|
60
|
+
RELEASE_TYPE must be 'major', 'minor', 'patch', 'pre', 'release', or 'first'
|
49
61
|
|
50
62
|
Options:
|
51
63
|
--default-branch=BRANCH_NAME Override the default branch
|
52
64
|
--release-branch=BRANCH_NAME Override the release branch to create
|
65
|
+
-p, --pre Create a pre-release
|
66
|
+
-t, --pre-type=TYPE Type of pre-release to create (e.g. alpha, beta, etc.)
|
53
67
|
--remote=REMOTE_NAME Use this remote name instead of 'origin'
|
54
68
|
--last-release-version=VERSION
|
55
69
|
Use this version instead `semverify current`
|
56
70
|
--next-release-version=VERSION
|
57
|
-
Use this version instead `semverify RELEASE_TYPE`
|
71
|
+
Use this version instead `semverify next-RELEASE_TYPE`
|
58
72
|
--changelog-path=PATH Use this file instead of CHANGELOG.md
|
59
73
|
-q, --[no-]quiet Do not show output
|
60
74
|
-v, --[no-]verbose Show extra output
|
@@ -195,7 +209,85 @@ The `create-github-release` script will do the following:
|
|
195
209
|
See [After running create-github-release](#after-running-create-github-release)
|
196
210
|
for instructions for completing your release.
|
197
211
|
|
198
|
-
|
212
|
+
### Pre-release versions
|
213
|
+
|
214
|
+
This gem allows creation of a release with a pre-release version as [defined in the
|
215
|
+
Semver 2.0.0 spec](https://semver.org/#spec-item-9). An example of a pre-release
|
216
|
+
version is `1.0.0-beta.1`.
|
217
|
+
|
218
|
+
Pre-release versions have a lower precedence than their associated normal version.
|
219
|
+
This means the pre-release version sorts before the associated release version. For
|
220
|
+
example, `1.0.0-beta.1` comes before `1.0.0`. A pre-release version indicates that
|
221
|
+
the version is unstable and might not yet satisfy the intended compatibility
|
222
|
+
requirements as denoted by its associated normal version
|
223
|
+
|
224
|
+
This gem limits pre-release versions to the form `MAJOR.MINOR.PATCH-PRERELEASE` where
|
225
|
+
`PRERELEASE` can ONLY have the following form: `TYPE.DIGITS`. `TYPE` is any text
|
226
|
+
string allowed in the Semver 2.0.0 spec and is typically 'alpha', 'beta', 'pre',
|
227
|
+
'rc', etc. `DIGITS` is a numeric identifier that does not include leading zeroes.
|
228
|
+
|
229
|
+
#### Creating the first pre-release version for a release
|
230
|
+
|
231
|
+
Let's say that:
|
232
|
+
* The current release version is `1.3.4`
|
233
|
+
* You want to create the first pre-release for the next MINOR release
|
234
|
+
* You want the pre-release TYPE to be 'alpha'
|
235
|
+
|
236
|
+
You would use the following command:
|
237
|
+
|
238
|
+
```shell
|
239
|
+
create-github-release minor --pre --pre-type=alpha
|
240
|
+
```
|
241
|
+
|
242
|
+
This would create a release whose version is `1.4.0-alpha.1`.
|
243
|
+
|
244
|
+
#### Creating subsequent pre-releases
|
245
|
+
|
246
|
+
Let's say you would like to create another alpha pre-release for the `1.4.0` release.
|
247
|
+
|
248
|
+
You would use the following command:
|
249
|
+
|
250
|
+
```shell
|
251
|
+
create-github-release pre
|
252
|
+
```
|
253
|
+
|
254
|
+
This woould increment the pre-release numeric identifier giving the version is `1.4.0-alpha.2`.
|
255
|
+
|
256
|
+
It is only valid to use the `pre` command when the current release is a pre-release
|
257
|
+
version. For example, it would not be valid to run `create-github-release pre` if the
|
258
|
+
current version is `1.0.0`.
|
259
|
+
|
260
|
+
#### Changing the pre-release type
|
261
|
+
|
262
|
+
Continuing with the previous example where the current release version is
|
263
|
+
`1.4.0-alpha.2`, if you now you want to create a beta pre-release, you would use the
|
264
|
+
following command:
|
265
|
+
|
266
|
+
```shell
|
267
|
+
create-github-release pre --pre-type=beta
|
268
|
+
```
|
269
|
+
|
270
|
+
This would change the release type and reset the pre-release numeric identifier to
|
271
|
+
'1' resulting in the verion `1.4.0-beta.1`
|
272
|
+
|
273
|
+
Note that the current release type MUST be lexically less than the new release type
|
274
|
+
specified on the command line. This means that if the current version is
|
275
|
+
`1.4.0-beta.1`, it would not be valid to change the release type to `alpha` since
|
276
|
+
'alpha' <= 'beta'.
|
277
|
+
|
278
|
+
#### Creating the release after pre-releases
|
279
|
+
|
280
|
+
Now let's say that the current version is `1.4.0-beta.1`. To create release whose version
|
281
|
+
is `1.4.0`, use the command:
|
282
|
+
|
283
|
+
```shell
|
284
|
+
create-github-release release
|
285
|
+
```
|
286
|
+
|
287
|
+
It is only valid to use the `release` command when the current release version is a
|
288
|
+
pre-release version.
|
289
|
+
|
290
|
+
### After Running create-github-release
|
199
291
|
|
200
292
|
If you want to make additional updates to the ChangeLog or make changes as
|
201
293
|
part of the release PR, it is best to do them before running this script. If
|
@@ -216,15 +308,47 @@ git push
|
|
216
308
|
```
|
217
309
|
|
218
310
|
GitHub will automatically close the PR after the `git push` command. These commands
|
219
|
-
are output by `create-github-release` so you do not have to memorize them
|
311
|
+
are output by `create-github-release` so you do not have to memorize them.
|
220
312
|
|
221
|
-
It is important to use a fast foward
|
222
|
-
|
223
|
-
merging a PR.
|
313
|
+
It is important to use a fast foward merge to ensure that the release tag points to
|
314
|
+
the right commit after the merge. The GitHub UI does not allow fast forward merges
|
315
|
+
when merging a PR.
|
224
316
|
|
225
|
-
Finally, publish your gem to rubygems.org with the
|
317
|
+
Finally, publish your gem to rubygems.org with the command:
|
226
318
|
|
227
|
-
|
319
|
+
```shell
|
320
|
+
rake release:rubygem_push
|
321
|
+
```
|
322
|
+
|
323
|
+
## FAQ
|
324
|
+
|
325
|
+
### What if I want to reverse the changes made by this script?
|
326
|
+
|
327
|
+
You will need to delete the Git tag and branch created by this script both remotely and locally.
|
328
|
+
|
329
|
+
In your worktree run the following commands:
|
330
|
+
|
331
|
+
```shell
|
332
|
+
DEFAULT_BRANCH=main
|
333
|
+
RELEASE_VERSION=1.0.1
|
334
|
+
RELEASE_TAG="v${RELEASE_VERSION}"
|
335
|
+
RELEASE_BRANCH="release_${RELEASE_TAG}"
|
336
|
+
REMOTE=origin
|
337
|
+
|
338
|
+
# Make sure the release branch is not checked out
|
339
|
+
git checkout "${DEFAULT_BRANCH}"
|
340
|
+
|
341
|
+
# Delete remote branch and tag
|
342
|
+
# Deleting the remote branch will automatically close the release PR
|
343
|
+
git push "${REMOTE}" --delete "${RELEASE_BRANCH}"
|
344
|
+
git push "${REMOTE}" --delete "${RELEASE_TAG}"
|
345
|
+
|
346
|
+
# Delete the local branch and tag
|
347
|
+
git branch -D "${RELEASE_BRANCH}"
|
348
|
+
git tag -d "${RELEASE_TAG}"
|
349
|
+
```
|
350
|
+
|
351
|
+
### How is the changelog updated?
|
228
352
|
|
229
353
|
A release description is generated by listing the commits between the last release
|
230
354
|
and the next release.
|
@@ -266,24 +390,18 @@ The resulting updated changelog file has the following sections:
|
|
266
390
|
2. next release description
|
267
391
|
3. body (including past release descriptions)
|
268
392
|
|
269
|
-
## Limitations
|
270
|
-
|
271
|
-
* Does not work on Windows
|
272
|
-
* Has only been tested on MRI Ruby
|
273
|
-
*
|
274
|
-
|
275
393
|
## Development
|
276
394
|
|
277
395
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
278
396
|
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
279
397
|
prompt that will allow you to experiment.
|
280
398
|
|
281
|
-
To install this gem onto your
|
399
|
+
To install this gem onto your current Ruby environment, run `bundle exec rake install`.
|
282
400
|
|
283
401
|
## Contributing
|
284
402
|
|
285
403
|
Bug reports and pull requests are welcome on
|
286
|
-
[this project's GitHub
|
404
|
+
[this project's GitHub page](https://github.com/main-branch/create_github_release)
|
287
405
|
|
288
406
|
## License
|
289
407
|
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# The default task
|
4
4
|
|
5
5
|
desc 'Run the same tasks that the CI build will run'
|
6
|
-
task default: %w[spec rubocop yard yard:audit yard:coverage
|
6
|
+
task default: %w[spec rubocop yard yard:audit yard:coverage bundle:audit build]
|
7
7
|
|
8
8
|
# Bundler Audit
|
9
9
|
|
@@ -75,12 +75,12 @@ Yardstick::Rake::Verify.new(:'yard:coverage') do |verify|
|
|
75
75
|
verify.threshold = 100
|
76
76
|
end
|
77
77
|
|
78
|
-
# Solargraph typecheck
|
78
|
+
# # Solargraph typecheck
|
79
79
|
|
80
|
-
desc 'Run the solargraph type checker'
|
81
|
-
task :'solargraph:typecheck' do
|
82
|
-
|
83
|
-
end
|
80
|
+
# desc 'Run the solargraph type checker'
|
81
|
+
# task :'solargraph:typecheck' do
|
82
|
+
# sh 'bundle exec solargraph typecheck --level=typed'
|
83
|
+
# end
|
84
84
|
|
85
85
|
# Additional cleanup
|
86
86
|
|
@@ -21,7 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.metadata['homepage_uri'] = spec.homepage
|
23
23
|
spec.metadata['source_code_uri'] = spec.homepage
|
24
|
-
spec.metadata['changelog_uri'] = spec.
|
24
|
+
spec.metadata['changelog_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}/file/CHANGELOG.md"
|
25
|
+
spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}"
|
25
26
|
|
26
27
|
# Specify which files should be added to the gem when it is released.
|
27
28
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -42,10 +43,9 @@ Gem::Specification.new do |spec|
|
|
42
43
|
spec.add_development_dependency 'redcarpet', '~> 3.5'
|
43
44
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
44
45
|
spec.add_development_dependency 'rubocop', '~> 1.36'
|
45
|
-
spec.add_development_dependency 'ruby-debug-ide', '~> 0.7'
|
46
46
|
spec.add_development_dependency 'simplecov', '~> 0.21'
|
47
47
|
spec.add_development_dependency 'simplecov-lcov', '~> 0.8'
|
48
|
-
spec.add_development_dependency 'solargraph', '~> 0.49'
|
48
|
+
# spec.add_development_dependency 'solargraph', '~> 0.49'
|
49
49
|
spec.add_development_dependency 'timecop', '~> 0.9'
|
50
50
|
spec.add_development_dependency 'yard', '~> 0.9'
|
51
51
|
spec.add_development_dependency 'yardstick', '~> 0.9'
|
data/exe/create-github-release
CHANGED
@@ -0,0 +1,165 @@
|
|
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
|
+
|
9
|
+
require 'English'
|
10
|
+
require 'optparse'
|
11
|
+
|
12
|
+
# Options for running this script
|
13
|
+
class Options
|
14
|
+
attr_writer :default_branch, :release_version, :release_tag, :release_branch, :current_branch, :remote
|
15
|
+
|
16
|
+
def default_branch = @default_branch ||= 'main'
|
17
|
+
def release_version = @release_version ||= `semverify current`.chomp
|
18
|
+
def release_tag = @release_tag ||= "v#{release_version}"
|
19
|
+
def release_branch = @release_branch ||= "release-#{release_tag}"
|
20
|
+
def current_branch = @current_branch ||= `git rev-parse --abbrev-ref HEAD`.chomp
|
21
|
+
def remote = @remote ||= 'origin'
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parse the command line options for this script
|
25
|
+
class Parser
|
26
|
+
# Create a new command line parser
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# parser = CommandLineParser.new
|
30
|
+
#
|
31
|
+
def initialize
|
32
|
+
@option_parser = OptionParser.new
|
33
|
+
define_options
|
34
|
+
@options = Options.new
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_reader :option_parser, :options
|
38
|
+
|
39
|
+
# Parse the command line arguements returning the options
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# options = Parser.new.parse(*ARGV)
|
43
|
+
#
|
44
|
+
# @param args [Array<String>] the command line arguments
|
45
|
+
#
|
46
|
+
# @return [Options] the options
|
47
|
+
#
|
48
|
+
def parse(*args)
|
49
|
+
begin
|
50
|
+
option_parser.parse!(remaining_args = args.dup)
|
51
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
52
|
+
report_errors(e.message)
|
53
|
+
end
|
54
|
+
parse_remaining_args(remaining_args)
|
55
|
+
options
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
# Output an error message and useage to stderr and exit
|
61
|
+
# @return [void]
|
62
|
+
# @api private
|
63
|
+
def report_errors(*errors)
|
64
|
+
warn error_message(errors)
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
# The command line template as a string
|
69
|
+
# @return [String]
|
70
|
+
# @api private
|
71
|
+
def command_template
|
72
|
+
<<~COMMAND
|
73
|
+
#{File.basename($PROGRAM_NAME)} [--help]
|
74
|
+
COMMAND
|
75
|
+
end
|
76
|
+
|
77
|
+
BANNER = <<~BANNER.freeze
|
78
|
+
Usage:
|
79
|
+
#{File.basename($PROGRAM_NAME)} [--help | --version]
|
80
|
+
|
81
|
+
This script reverts the effect of running the create-github-release script.
|
82
|
+
It must be run in the root directory of the work tree with the release
|
83
|
+
branch checked out (which is the state create-github-release leaves you in).
|
84
|
+
|
85
|
+
This script should be run beefore the release PR is merged.
|
86
|
+
|
87
|
+
This script removes the release branch and release tag both in the local
|
88
|
+
repository and on the remote. Deleting the branch on GitHub will close the
|
89
|
+
GitHub PR automatically.
|
90
|
+
|
91
|
+
Options:
|
92
|
+
BANNER
|
93
|
+
|
94
|
+
# Define the options for OptionParser
|
95
|
+
# @return [void]
|
96
|
+
# @api private
|
97
|
+
def define_options
|
98
|
+
option_parser.banner = BANNER
|
99
|
+
%i[
|
100
|
+
define_help_option define_version_option
|
101
|
+
].each { |m| send(m) }
|
102
|
+
end
|
103
|
+
|
104
|
+
# Define the help option
|
105
|
+
# @return [void]
|
106
|
+
# @api private
|
107
|
+
def define_help_option
|
108
|
+
option_parser.on_tail('-h', '--help', 'Show this message') do
|
109
|
+
puts option_parser
|
110
|
+
exit 0
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Define the version option
|
115
|
+
# @return [void]
|
116
|
+
# @api private
|
117
|
+
def define_version_option
|
118
|
+
option_parser.on_tail('-v', '--version', 'Output the version of this script') do
|
119
|
+
puts CreateGithubRelease::VERSION
|
120
|
+
exit 0
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Parse non-option arguments
|
125
|
+
# @return [void]
|
126
|
+
# @api private
|
127
|
+
def parse_remaining_args(remaining_args)
|
128
|
+
# There should be no remaining args
|
129
|
+
report_errors('Too many args') unless remaining_args.empty?
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def in_work_tree? = `git rev-parse --is-inside-work-tree 2>/dev/null`.chomp == 'true'
|
134
|
+
def in_root_directory? = `git rev-parse --show-toplevel 2>/dev/null`.chomp == Dir.pwd
|
135
|
+
|
136
|
+
def ref_exists?(name)
|
137
|
+
`git rev-parse --verify #{name} >/dev/null 2>&1`
|
138
|
+
$CHILD_STATUS.success?
|
139
|
+
end
|
140
|
+
|
141
|
+
unless in_work_tree? && in_root_directory?
|
142
|
+
warn 'ERROR: Not in the root directory of a Git work tree'
|
143
|
+
exit 1
|
144
|
+
end
|
145
|
+
|
146
|
+
# Parse the command line options
|
147
|
+
options = Parser.new.parse(*ARGV)
|
148
|
+
|
149
|
+
unless options.release_branch == options.current_branch
|
150
|
+
warn "ERROR: The current branch '#{options.current_branch}' is not the release branch for #{options.release_version}"
|
151
|
+
exit 1
|
152
|
+
end
|
153
|
+
|
154
|
+
unless ref_exists?(options.default_branch)
|
155
|
+
warn "ERROR: The default branch '#{options.default_branch}' does not exist"
|
156
|
+
exit 1
|
157
|
+
end
|
158
|
+
|
159
|
+
`git checkout #{options.default_branch} >/dev/null`
|
160
|
+
`git branch -D #{options.release_branch} >/dev/null`
|
161
|
+
`git tag -d #{options.release_tag} >/dev/null`
|
162
|
+
`git push #{options.remote} --delete #{options.release_branch} >/dev/null`
|
163
|
+
`git push #{options.remote} --delete #{options.release_tag} >/dev/null`
|
164
|
+
|
165
|
+
puts "Reverted release #{options.release_version}"
|
@@ -17,7 +17,7 @@ module CreateGithubRelease
|
|
17
17
|
# @example
|
18
18
|
# require 'create_github_release'
|
19
19
|
#
|
20
|
-
# options = CreateGithubRelease::
|
20
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
|
21
21
|
# project = CreateGithubRelease::Project.new(options)
|
22
22
|
# assertion = CreateGithubRelease::Assertions::BundleIsUpToDate.new(project)
|
23
23
|
# begin
|
@@ -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
|
# assertion = CreateGithubRelease::Assertions::GhAuthenticated.new(project)
|
21
21
|
# begin
|
@@ -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
|
# assertion = CreateGithubRelease::Assertions::GhCommandExists.new(project)
|
21
21
|
# begin
|
@@ -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
|
# assertion = CreateGithubRelease::Assertions::GitCommandExists.new(project)
|
21
21
|
# begin
|
@@ -17,7 +17,7 @@ module CreateGithubRelease
|
|
17
17
|
# @example
|
18
18
|
# require 'create_github_release'
|
19
19
|
#
|
20
|
-
# options = CreateGithubRelease::
|
20
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
|
21
21
|
# project = CreateGithubRelease::Project.new(options)
|
22
22
|
# assertion = CreateGithubRelease::Assertions::InGitRepo.new(project)
|
23
23
|
# begin
|
@@ -18,7 +18,7 @@ module CreateGithubRelease
|
|
18
18
|
# @example
|
19
19
|
# require 'create_github_release'
|
20
20
|
#
|
21
|
-
# options = CreateGithubRelease::
|
21
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
|
22
22
|
# project = CreateGithubRelease::Project.new(options)
|
23
23
|
# assertion = CreateGithubRelease::Assertions::InRepoRootDirectory.new(project)
|
24
24
|
# begin
|
@@ -17,7 +17,7 @@ module CreateGithubRelease
|
|
17
17
|
# @example
|
18
18
|
# require 'create_github_release'
|
19
19
|
#
|
20
|
-
# options = CreateGithubRelease::
|
20
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
|
21
21
|
# project = CreateGithubRelease::Project.new(options)
|
22
22
|
# assertion = CreateGithubRelease::Assertions::LocalAndRemoteOnSameCommit.new(project)
|
23
23
|
# begin
|
@@ -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
|
# assertion = CreateGithubRelease::Assertions::LocalReleaseBranchDoesNotExist.new(project)
|
21
21
|
# begin
|
@@ -17,7 +17,7 @@ module CreateGithubRelease
|
|
17
17
|
# @example
|
18
18
|
# require 'create_github_release'
|
19
19
|
#
|
20
|
-
# options = CreateGithubRelease::
|
20
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
|
21
21
|
# project = CreateGithubRelease::Project.new(options)
|
22
22
|
# assertion = CreateGithubRelease::Assertions::NoStagedChanges.new(project)
|
23
23
|
# begin
|
@@ -17,7 +17,7 @@ module CreateGithubRelease
|
|
17
17
|
# @example
|
18
18
|
# require 'create_github_release'
|
19
19
|
#
|
20
|
-
# options = CreateGithubRelease::
|
20
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
|
21
21
|
# project = CreateGithubRelease::Project.new(options)
|
22
22
|
# assertion = CreateGithubRelease::Assertions::NoUncommittedChanges.new(project)
|
23
23
|
# begin
|
@@ -17,7 +17,7 @@ module CreateGithubRelease
|
|
17
17
|
# @example
|
18
18
|
# require 'create_github_release'
|
19
19
|
#
|
20
|
-
# options = CreateGithubRelease::
|
20
|
+
# options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
|
21
21
|
# project = CreateGithubRelease::Project.new(options)
|
22
22
|
# assertion = CreateGithubRelease::Assertions::OnDefaultBranch.new(project)
|
23
23
|
# begin
|
@@ -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
|
# assertion = CreateGithubRelease::Assertions::RemoteReleaseBranchDoesNotExist.new(project)
|
21
21
|
# begin
|
@@ -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
|
# assertion = CreateGithubRelease::Assertions::RemoteReleaseTagDoesNotExist.new(project)
|
21
21
|
# begin
|