create_github_release 0.3.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.markdownlint.yml +1 -1
- data/.rubocop.yml +4 -1
- data/.solargraph.yml +23 -0
- data/.vscode/launch.json +19 -0
- data/CHANGELOG.md +27 -0
- data/README.md +237 -30
- data/Rakefile +8 -5
- data/create_github_release.gemspec +11 -5
- data/exe/create-github-release +4 -0
- data/lib/create_github_release/assertion_base.rb +0 -2
- data/lib/create_github_release/assertions/last_release_tag_exists.rb +2 -0
- data/lib/create_github_release/command_line_options.rb +31 -20
- data/lib/create_github_release/command_line_parser.rb +8 -4
- data/lib/create_github_release/project.rb +114 -33
- data/lib/create_github_release/release_assertions.rb +2 -1
- data/lib/create_github_release/release_tasks.rb +2 -1
- data/lib/create_github_release/tasks/update_version.rb +31 -5
- data/lib/create_github_release/version.rb +1 -1
- metadata +44 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c7135b3a301cc4504b3eb3b5bbb68f8f22d095e7f3edcf95044aa24ce0810b3
|
4
|
+
data.tar.gz: 4a59c7be79e6b571b3bafa683213c03b283468dc36e4e5766e0d9264ea70aa6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f40d6c1141f6e3ff94b5fc2532dd1c73149b2ae5f2c4fba6a7ea2a79597a592080327ae749f9373c45ae0c9c82ef286455b4265b1949575e95f640f47e64dd53
|
7
|
+
data.tar.gz: 124bf8d9ed03b6d82d902e63acae142298000062bfb4ff9409e3e31f98f4d83f8c24de85263de788478213c567c6cbf08308003b5d6d846ac044884ef7188dd2
|
data/.markdownlint.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -7,7 +7,7 @@ AllCops:
|
|
7
7
|
SuggestExtensions: false
|
8
8
|
# RuboCop enforces rules depending on the oldest version of Ruby which
|
9
9
|
# your project supports:
|
10
|
-
TargetRubyVersion:
|
10
|
+
TargetRubyVersion: 3.0
|
11
11
|
|
12
12
|
# The default max line length is 80 characters
|
13
13
|
Layout/LineLength:
|
@@ -18,3 +18,6 @@ Metrics/BlockLength:
|
|
18
18
|
Exclude:
|
19
19
|
- "spec/**/*_spec.rb"
|
20
20
|
- "*.gemspec"
|
21
|
+
|
22
|
+
Gemspec/DevelopmentDependencies:
|
23
|
+
EnforcedStyle: gemspec
|
data/.solargraph.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
include:
|
3
|
+
- "**/*.rb"
|
4
|
+
exclude:
|
5
|
+
- spec/**/*
|
6
|
+
- test/**/*
|
7
|
+
- vendor/**/*
|
8
|
+
- ".bundle/**/*"
|
9
|
+
require: []
|
10
|
+
domains: []
|
11
|
+
reporters:
|
12
|
+
- rubocop
|
13
|
+
- require_not_found
|
14
|
+
- typecheck:strict
|
15
|
+
formatter:
|
16
|
+
rubocop:
|
17
|
+
cops: safe
|
18
|
+
except: []
|
19
|
+
only: []
|
20
|
+
extra_args: []
|
21
|
+
require_paths: []
|
22
|
+
plugins: []
|
23
|
+
max_files: 5000
|
data/.vscode/launch.json
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
// Test
|
3
|
+
"version": "0.2.0",
|
4
|
+
"configurations": [
|
5
|
+
{
|
6
|
+
"type": "rdbg",
|
7
|
+
"name": "Debug current file with rdbg",
|
8
|
+
"request": "launch",
|
9
|
+
"script": "${file}",
|
10
|
+
"args": [],
|
11
|
+
"askParameters": false
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"type": "rdbg",
|
15
|
+
"name": "Attach with rdbg",
|
16
|
+
"request": "attach"
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,33 @@ 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.1.0 (2023-10-15)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.0.0..v1.1.0)
|
11
|
+
|
12
|
+
Changes since v1.0.0:
|
13
|
+
|
14
|
+
* 5088cd0 Add instruction for publishing the resulting gem (#41)
|
15
|
+
* 60553b0 Integrate solargraph:typecheck into Rake and fix any problems (#40)
|
16
|
+
* c0dd2d8 Improve reporting of code not covered by tests (#38)
|
17
|
+
* 5dff0b5 Tell rubocop development dependencies go in the gemspec (#39)
|
18
|
+
* d55f2f4 Merge pull request #37 from main-branch/debugging_support
|
19
|
+
* 4a28c4c Allow the build to continue if the Ruby head build fails
|
20
|
+
* 2814761 Add launch.json to run the ruby debugger in VS Code
|
21
|
+
* c3de36d Require 'debug' in spec_helper so `binding.break` can be used
|
22
|
+
* 3f3276d Add gems needed for debugging
|
23
|
+
* e299d97 Replace 'bump' with 'semverify' (#35)
|
24
|
+
* 68fa672 Drop support for Ruby 2.7 and require at least Ruby 3.0 (#36)
|
25
|
+
|
26
|
+
## v1.0.0 (2023-02-05)
|
27
|
+
|
28
|
+
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v0.3.0..v1.0.0)
|
29
|
+
|
30
|
+
Changes since v0.3.0:
|
31
|
+
|
32
|
+
* bfd40e6 Handle the first release of a gem (#32)
|
33
|
+
* 7a76148 Release v0.3.0 (#31)
|
34
|
+
|
8
35
|
## v0.3.0 (2023-01-29)
|
9
36
|
|
10
37
|
[Full Changelog](https://github.com/main-branch/create_github_release/compare/v0.2.1..v0.3.0)
|
data/README.md
CHANGED
@@ -5,65 +5,272 @@
|
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/b8c0af10b15a0ffeb1a1/maintainability)](https://codeclimate.com/github/main-branch/create_github_release/maintainability)
|
6
6
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/b8c0af10b15a0ffeb1a1/test_coverage)](https://codeclimate.com/github/main-branch/create_github_release/test_coverage)
|
7
7
|
|
8
|
-
|
8
|
+
A script to manage your gem version and create a GitHub branch, PR, and release
|
9
|
+
for a new gem version.
|
9
10
|
|
10
|
-
|
11
|
+
Since this script builds a changelog by listing the commits on the default branch,
|
12
|
+
it works best if you are disciplined about squashing PR commits to the
|
13
|
+
minimum number of commits necessary (usually one) in order to avoid a noisy changelog.
|
11
14
|
|
12
|
-
|
13
|
-
* Updates the project's changelog
|
14
|
-
* Creates a release branch
|
15
|
-
* Commits the version change and changelog update
|
16
|
-
* Creates a version tag
|
17
|
-
* Pushes the release branch to GitHub
|
18
|
-
* Creates a GitHub release and GitHub pull request for the release
|
15
|
+
Tested on Ruby 2.7+
|
19
16
|
|
20
|
-
|
17
|
+
* [The create\_github\_release Gem](#the-create_github_release-gem)
|
18
|
+
* [Installation](#installation)
|
19
|
+
* [Usage](#usage)
|
20
|
+
* [First release using this script when there were NO prior releases](#first-release-using-this-script-when-there-were-no-prior-releases)
|
21
|
+
* [First release using this script when there were prior releases](#first-release-using-this-script-when-there-were-prior-releases)
|
22
|
+
* [Subsequent releases using this script](#subsequent-releases-using-this-script)
|
23
|
+
* [After Running create-github-release](#after-running-create-github-release)
|
24
|
+
* [How the changelog is updated](#how-the-changelog-is-updated)
|
25
|
+
* [Limitations](#limitations)
|
26
|
+
* [Development](#development)
|
27
|
+
* [Contributing](#contributing)
|
28
|
+
* [License](#license)
|
21
29
|
|
22
|
-
|
30
|
+
## Installation
|
31
|
+
|
32
|
+
Add `create_github_release` as a development dependency in your project's gemspec:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
spec.add_development_dependency 'create_github_release', '~> 0.1'
|
36
|
+
```
|
37
|
+
|
38
|
+
and then install using `bundle update`.
|
39
|
+
|
40
|
+
## Usage
|
23
41
|
|
24
|
-
|
42
|
+
This gem installs the `create-guthub-release` command line tool:
|
25
43
|
|
26
44
|
```text
|
27
45
|
Usage:
|
28
46
|
create-github-release --help | RELEASE_TYPE [options]
|
29
47
|
|
30
|
-
RELEASE_TYPE must be 'major', 'minor', or '
|
48
|
+
RELEASE_TYPE must be 'major', 'minor', 'patch', or 'first'
|
31
49
|
|
32
50
|
Options:
|
33
51
|
--default-branch=BRANCH_NAME Override the default branch
|
34
52
|
--release-branch=BRANCH_NAME Override the release branch to create
|
35
53
|
--remote=REMOTE_NAME Use this remote name instead of 'origin'
|
36
54
|
--last-release-version=VERSION
|
37
|
-
Use this version instead `
|
55
|
+
Use this version instead `semverify current`
|
38
56
|
--next-release-version=VERSION
|
39
|
-
Use this version instead `
|
57
|
+
Use this version instead `semverify RELEASE_TYPE`
|
40
58
|
--changelog-path=PATH Use this file instead of CHANGELOG.md
|
41
59
|
-q, --[no-]quiet Do not show output
|
42
60
|
-v, --[no-]verbose Show extra output
|
43
61
|
-h, --help Show this message
|
44
62
|
```
|
45
63
|
|
46
|
-
The
|
64
|
+
The RELEASE_TYPE should follow [Semantic Versioning](https://semver.org) rules:
|
47
65
|
|
48
|
-
*
|
49
|
-
*
|
50
|
-
*
|
51
|
-
* There are no uncommitted changes
|
52
|
-
* The local and remote must be on the same commit
|
53
|
-
* The last release tag must exist
|
54
|
-
* The new release tag must not already exist either locally or remotely
|
55
|
-
* The new release branch must not already exist either locally or remotely
|
56
|
-
* The gh command must be installed
|
66
|
+
* A **major** release includes incompatible API changes
|
67
|
+
* A **minor** release includes added functionality in a backwards compatible manner
|
68
|
+
* A **patch** release includes backwards compatible bug fixes or other inconsequential changes
|
57
69
|
|
58
|
-
|
70
|
+
This script will be used for three different use cases:
|
59
71
|
|
60
|
-
|
72
|
+
### First release using this script when there were NO prior releases
|
61
73
|
|
62
|
-
|
63
|
-
|
74
|
+
If this is to be the first release of this gem follow these instructions.
|
75
|
+
|
76
|
+
For this use case, let's assume the following:
|
77
|
+
|
78
|
+
* the default branch is `main` (this is the HEAD branch returned by `git remote show origin`)
|
79
|
+
* the current version of the gem is `0.1.0` (as returned by `semverify current`)
|
80
|
+
|
81
|
+
If a different first version number is desired, update the version number in the
|
82
|
+
source code making sure that `semverify current` returns the desired version number.
|
83
|
+
Then commit the change to the default branch on the remote before running this
|
84
|
+
script.
|
85
|
+
|
86
|
+
You should start with a CHANGELOG.md that just has frontmatter. An empty file or
|
87
|
+
no file is also acceptable. It is not recommended to go with the CHANGELOG.md generated
|
88
|
+
by `bundle gem`. Here are suggested CHANGELOG.md contents prior to the first release:
|
89
|
+
|
90
|
+
```markdown
|
91
|
+
# Change Log
|
92
|
+
|
93
|
+
Changes for each release are listed in this file.
|
94
|
+
|
95
|
+
This project adheres to [Semantic Versioning](https://semver.org/) for its releases.
|
64
96
|
```
|
65
97
|
|
66
|
-
|
98
|
+
See [How the changelog is updated](#how-the-changelog-is-updated) for more information.
|
99
|
+
|
100
|
+
The following prerequisites are checked by this script:
|
101
|
+
|
102
|
+
* The current directory must be in the top level of the git repository
|
103
|
+
* The HEAD commit of the default branch (`main`) must be checked out
|
104
|
+
* The HEAD commit of the default branch of the local repository must match the
|
105
|
+
HEAD commit of the default branch of the remote repository
|
106
|
+
* There are no uncommitted or unstaged changes
|
107
|
+
* The bundle must be up to date (the script will attempt to update the bundle if needed)
|
108
|
+
* The next-release tag (`v0.1.0`) must NOT already exist
|
109
|
+
* The next-release branch (`release-v0.1.0`) must NOT already exist
|
110
|
+
* The gh command must be installed and authenticated via `gh auth`
|
111
|
+
|
112
|
+
You should run:
|
113
|
+
|
114
|
+
```shell
|
115
|
+
create-github-release first
|
116
|
+
```
|
117
|
+
|
118
|
+
The `create-github-release` script will do the following:
|
119
|
+
|
120
|
+
* Determine the next-release version (`v0.1.0`) using `semverify current`
|
121
|
+
* Update the project's changelog file `CHANGELOG.md`
|
122
|
+
* Create a release branch `release-v0.1.0`
|
123
|
+
* Commit the changes to the changelog and create a release tag (`v0.1.0`) pointing
|
124
|
+
to that commit
|
125
|
+
* Push the release branch to GitHub
|
126
|
+
* Create a GitHub release and pull request for the release
|
127
|
+
|
128
|
+
See [After running create-github-release](#after-running-create-github-release)
|
129
|
+
for instructions for completing your release.
|
130
|
+
|
131
|
+
### First release using this script when there were prior releases
|
132
|
+
|
133
|
+
In order to start using `create-github-release` after you have used some other
|
134
|
+
method for managing the gem version and creating releases, you need to ensure the
|
135
|
+
following prerequisites are met:
|
136
|
+
|
137
|
+
1. that `semverify current` is the version of the last release (let's use `1.3.1` as an
|
138
|
+
example).
|
139
|
+
2. that there is a corresponding release tag that points to the last commit on the
|
140
|
+
default branch of the previous release. If the last version was `1.3.1`, then
|
141
|
+
the last-release tag should be `v1.3.1`.
|
142
|
+
|
143
|
+
Changes to the changelog file to ensure the next-release description is added correctly
|
144
|
+
may need to be done. See [How the changelog is updated](#how-the-changelog-is-updated)
|
145
|
+
for details.
|
146
|
+
|
147
|
+
Any changes needed to make sure these prerequisites are met should merged or pushed
|
148
|
+
to the default branch on the remote.
|
149
|
+
|
150
|
+
Once these prerequisites are met and any adjustments have been done, follow the
|
151
|
+
directions in [Subserquent releases using this script](#subsequent-releases-using-this-script).
|
152
|
+
|
153
|
+
See [After running create-github-release](#after-running-create-github-release)
|
154
|
+
for instructions for completing your release.
|
155
|
+
|
156
|
+
### Subsequent releases using this script
|
157
|
+
|
158
|
+
For this use case, let's assume the following:
|
159
|
+
|
160
|
+
* you want to create a `major` release
|
161
|
+
* the default branch is `main` (this is the HEAD branch returned by `git remote show origin`)
|
162
|
+
* the current version of the gem is `0.1.0` (as returned by `semverify current`)
|
163
|
+
|
164
|
+
The following prerequisites must be met:
|
165
|
+
|
166
|
+
* The current directory must be in the top level of the git repository
|
167
|
+
* The HEAD commit of the default branch (`main`) must be checked out
|
168
|
+
* The HEAD commit of the default branch of the local repository must match the
|
169
|
+
HEAD commit of the default branch of the remote repository
|
170
|
+
* There are no uncommitted or unstaged changes
|
171
|
+
* The bundle must be up to date (the script will attempt to update the bundle if needed)
|
172
|
+
* The last-release tag (`v0.1.0`) must already exist
|
173
|
+
* The next-release tag (`v1.0.0`) must NOT already exist
|
174
|
+
* The next-release branch (`release-v1.0.0`) must NOT already exist
|
175
|
+
* The gh command must be installed and authenticated via `gh auth`
|
176
|
+
|
177
|
+
You should run:
|
178
|
+
|
179
|
+
```shell
|
180
|
+
create-github-release major
|
181
|
+
```
|
182
|
+
|
183
|
+
The `create-github-release` script will do the following:
|
184
|
+
|
185
|
+
* Determine the last-release version using `semverify current`
|
186
|
+
* Determine the next-release version using `semverify RELEASE_TYPE --dry-run`
|
187
|
+
* Increment the project's version using `semverify RELEASE_TYPE`
|
188
|
+
* Update the project's changelog file `CHANGELOG.md`
|
189
|
+
* Create a release branch `release-v1.0.0`
|
190
|
+
* Commit the changes to the version and changelog AND create a release tag (`v1.0.0`) pointing
|
191
|
+
to that commit
|
192
|
+
* Push the release branch to GitHub
|
193
|
+
* Create a GitHub release and pull request for the release
|
194
|
+
|
195
|
+
See [After running create-github-release](#after-running-create-github-release)
|
196
|
+
for instructions for completing your release.
|
197
|
+
|
198
|
+
## After Running create-github-release
|
199
|
+
|
200
|
+
If you want to make additional updates to the ChangeLog or make changes as
|
201
|
+
part of the release PR, it is best to do them before running this script. If
|
202
|
+
you must make changes after running this script, you should do so in additional
|
203
|
+
commits on the release branch. Before merging to the default branch, you should
|
204
|
+
squash all commits down to ONE commit on the release branch and make sure that
|
205
|
+
the new release tag (`v1.0.0` in this example) points to this commit.
|
206
|
+
|
207
|
+
If you are happy with the PR, you should approve it in GitHub.
|
208
|
+
|
209
|
+
Next, merge the release branch into the default branch **MANUALLY AT THE COMMAND
|
210
|
+
LINE** using a fast forward merge with the following commands:
|
211
|
+
|
212
|
+
```shell
|
213
|
+
git checkout main
|
214
|
+
git merge --ff-only release-v1.0.0
|
215
|
+
git push
|
216
|
+
```
|
217
|
+
|
218
|
+
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 ;)
|
220
|
+
|
221
|
+
It is important to use a fast foward marge to ensure that the release tag points
|
222
|
+
to the right commit after the merge. GitHub does not allow fast forward merges when
|
223
|
+
merging a PR.
|
224
|
+
|
225
|
+
Finally, publish your gem to rubygems.org with the `rake release` command.
|
226
|
+
|
227
|
+
## How the changelog is updated
|
228
|
+
|
229
|
+
A release description is generated by listing the commits between the last release
|
230
|
+
and the next release.
|
231
|
+
|
232
|
+
As an example, let's assume the following:
|
233
|
+
|
234
|
+
* the last release version was `0.1.0`
|
235
|
+
* the next release version will be `1.0.0`
|
236
|
+
* there were two changes in the next release:
|
237
|
+
* The first commit has sha `1111111` and a commit message starting with the
|
238
|
+
line 'Add feature 1'
|
239
|
+
* The second commit has sha `2222222` and a commit message starting with the
|
240
|
+
line 'Add feature 2'
|
241
|
+
|
242
|
+
The release description will look like this:
|
243
|
+
|
244
|
+
```text
|
245
|
+
## Release v1.0.0
|
246
|
+
|
247
|
+
Full Changelog
|
248
|
+
|
249
|
+
Changes since v0.1.0:
|
250
|
+
|
251
|
+
* 2222222 Add feature 2
|
252
|
+
* 1111111 Add feature 1
|
253
|
+
```
|
254
|
+
|
255
|
+
The existing changelog file is read and split into two parts: front matter and
|
256
|
+
body.
|
257
|
+
|
258
|
+
The front matter is everything before the first markdown H2 header. If there is
|
259
|
+
no H2 header, the entire file is considered front matter.
|
260
|
+
|
261
|
+
The body is everything else in the file (if the file contains an H2 header)
|
262
|
+
|
263
|
+
The resulting updated changelog file has the following sections:
|
264
|
+
|
265
|
+
1. front matter
|
266
|
+
2. next release description
|
267
|
+
3. body (including past release descriptions)
|
268
|
+
|
269
|
+
## Limitations
|
270
|
+
|
271
|
+
* Does not work on Windows
|
272
|
+
* Has only been tested on MRI Ruby
|
273
|
+
*
|
67
274
|
|
68
275
|
## Development
|
69
276
|
|
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 bundle:audit build]
|
6
|
+
task default: %w[spec rubocop yard yard:audit yard:coverage solargraph:typecheck bundle:audit build]
|
7
7
|
|
8
8
|
# Bundler Audit
|
9
9
|
|
@@ -26,10 +26,6 @@ end
|
|
26
26
|
CLEAN << 'pkg'
|
27
27
|
CLOBBER << 'Gemfile.lock'
|
28
28
|
|
29
|
-
# Bump
|
30
|
-
|
31
|
-
require 'bump/tasks'
|
32
|
-
|
33
29
|
# RSpec
|
34
30
|
|
35
31
|
require 'rspec/core/rake_task'
|
@@ -79,6 +75,13 @@ Yardstick::Rake::Verify.new(:'yard:coverage') do |verify|
|
|
79
75
|
verify.threshold = 100
|
80
76
|
end
|
81
77
|
|
78
|
+
# Solargraph typecheck
|
79
|
+
|
80
|
+
desc 'Run the solargraph type checker'
|
81
|
+
task :'solargraph:typecheck' do
|
82
|
+
sh 'bundle exec solargraph typecheck --level=typed'
|
83
|
+
end
|
84
|
+
|
82
85
|
# Additional cleanup
|
83
86
|
|
84
87
|
CLEAN << 'tmp'
|
@@ -8,11 +8,14 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['James']
|
9
9
|
spec.email = ['jcouball@yahoo.com']
|
10
10
|
|
11
|
-
spec.summary = '
|
12
|
-
spec.description =
|
11
|
+
spec.summary = 'A script to create a GitHub release for a Ruby Gem'
|
12
|
+
spec.description = <<~DESCRIPTION
|
13
|
+
A script that manages your gem version and creates a GitHub branch, PR, and
|
14
|
+
release for a new gem version.
|
15
|
+
DESCRIPTION
|
13
16
|
spec.homepage = 'https://github.com/main-branch/create_github_release'
|
14
17
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = '>=
|
18
|
+
spec.required_ruby_version = '>= 3.0.0'
|
16
19
|
|
17
20
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
21
|
|
@@ -31,15 +34,18 @@ Gem::Specification.new do |spec|
|
|
31
34
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
35
|
spec.require_paths = ['lib']
|
33
36
|
|
34
|
-
spec.
|
37
|
+
spec.add_runtime_dependency 'semverify', '~> 0.3'
|
38
|
+
|
35
39
|
spec.add_development_dependency 'bundler-audit', '~> 0.9'
|
40
|
+
spec.add_development_dependency 'debug', '~> 1.7'
|
36
41
|
spec.add_development_dependency 'rake', '~> 13.0'
|
37
42
|
spec.add_development_dependency 'redcarpet', '~> 3.5'
|
38
43
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
39
44
|
spec.add_development_dependency 'rubocop', '~> 1.36'
|
45
|
+
spec.add_development_dependency 'ruby-debug-ide', '~> 0.7'
|
40
46
|
spec.add_development_dependency 'simplecov', '~> 0.21'
|
41
47
|
spec.add_development_dependency 'simplecov-lcov', '~> 0.8'
|
42
|
-
spec.add_development_dependency 'solargraph', '~> 0.
|
48
|
+
spec.add_development_dependency 'solargraph', '~> 0.49'
|
43
49
|
spec.add_development_dependency 'timecop', '~> 0.9'
|
44
50
|
spec.add_development_dependency 'yard', '~> 0.9'
|
45
51
|
spec.add_development_dependency 'yardstick', '~> 0.9'
|
data/exe/create-github-release
CHANGED
@@ -23,4 +23,8 @@ puts <<~MESSAGE unless project.quiet
|
|
23
23
|
git checkout #{project.default_branch}
|
24
24
|
git merge --ff-only #{project.release_branch}
|
25
25
|
git push
|
26
|
+
|
27
|
+
Wait for the CI build to pass and then release the gem with the following command:
|
28
|
+
|
29
|
+
rake release:rubygem_push
|
26
30
|
MESSAGE
|
@@ -29,6 +29,8 @@ module CreateGithubRelease
|
|
29
29
|
# @raise [SystemExit] if the assertion fails
|
30
30
|
#
|
31
31
|
def assert
|
32
|
+
return if project.first_release?
|
33
|
+
|
32
34
|
print "Checking that last release tag '#{project.last_release_tag}' exists..."
|
33
35
|
|
34
36
|
tags = `git tag --list "#{project.last_release_tag}"`.chomp
|
@@ -2,18 +2,23 @@
|
|
2
2
|
|
3
3
|
require 'uri'
|
4
4
|
|
5
|
-
# rubocop:disable Metrics/ModuleLength
|
6
|
-
|
7
5
|
module CreateGithubRelease
|
8
6
|
# An array of the valid release types
|
9
7
|
# @return [Array<String>]
|
10
8
|
# @api private
|
11
|
-
VALID_RELEASE_TYPES = %w[major minor patch].freeze
|
9
|
+
VALID_RELEASE_TYPES = %w[major minor patch first].freeze
|
12
10
|
|
13
11
|
# Regex pattern for a [valid git reference](https://git-scm.com/docs/git-check-ref-format)
|
14
12
|
# @return [Regexp]
|
15
13
|
# @api private
|
16
|
-
VALID_REF_PATTERN = /^(?:(?:[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*)|(?:[a-zA-Z0-9-]+))
|
14
|
+
VALID_REF_PATTERN = /^(?:(?:[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*)|(?:[a-zA-Z0-9-]+))$/
|
15
|
+
|
16
|
+
# An array of the allowed options that can be passed to `.new`
|
17
|
+
# @return [Array<Symbol>]
|
18
|
+
ALLOWED_OPTIONS = %i[
|
19
|
+
release_type default_branch release_branch remote last_release_version
|
20
|
+
next_release_version changelog_path quiet verbose
|
21
|
+
].freeze
|
17
22
|
|
18
23
|
# rubocop:disable Metrics/ClassLength
|
19
24
|
|
@@ -27,14 +32,12 @@ module CreateGithubRelease
|
|
27
32
|
#
|
28
33
|
# @api public
|
29
34
|
#
|
30
|
-
CommandLineOptions
|
31
|
-
|
32
|
-
|
33
|
-
keyword_init: true
|
34
|
-
) do
|
35
|
+
class CommandLineOptions
|
36
|
+
ALLOWED_OPTIONS.each { |option| attr_accessor option }
|
37
|
+
|
35
38
|
# @attribute release_type [rw] the type of release to create
|
36
39
|
#
|
37
|
-
# Must be one of
|
40
|
+
# Must be one of the VALID_RELEASE_TYPES
|
38
41
|
#
|
39
42
|
# @example
|
40
43
|
# options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
|
@@ -129,11 +132,14 @@ module CreateGithubRelease
|
|
129
132
|
# @yieldparam self [CreateGithubRelease::CommandLineOptions] the instance being initialized
|
130
133
|
# @yieldreturn [void] the return value is ignored
|
131
134
|
#
|
132
|
-
def initialize(
|
133
|
-
|
135
|
+
def initialize(**options)
|
136
|
+
assert_no_unknown_options(options)
|
137
|
+
options.each { |k, v| instance_variable_set("@#{k}", v) }
|
138
|
+
|
134
139
|
self.quiet ||= false
|
135
140
|
self.verbose ||= false
|
136
141
|
@errors = []
|
142
|
+
|
137
143
|
yield(self) if block_given?
|
138
144
|
end
|
139
145
|
|
@@ -192,6 +198,17 @@ module CreateGithubRelease
|
|
192
198
|
|
193
199
|
private
|
194
200
|
|
201
|
+
# Raise ArgumentError if options has a key not in ALLOWED_OPTIONS
|
202
|
+
# @return [void]
|
203
|
+
# @api private
|
204
|
+
def assert_no_unknown_options(options)
|
205
|
+
unknown_options = options.keys - ALLOWED_OPTIONS
|
206
|
+
return if unknown_options.empty?
|
207
|
+
|
208
|
+
message = "Unknown keywords: #{unknown_options.join(', ')}"
|
209
|
+
raise ArgumentError, message
|
210
|
+
end
|
211
|
+
|
195
212
|
# Returns `true` if the given name is a valid git reference
|
196
213
|
# @return [Boolean]
|
197
214
|
# @api private
|
@@ -229,19 +246,13 @@ module CreateGithubRelease
|
|
229
246
|
false
|
230
247
|
end
|
231
248
|
|
232
|
-
# Returns a string representation of the valid release types
|
233
|
-
# @return [String]
|
234
|
-
# @api private
|
235
|
-
def valid_release_types
|
236
|
-
"'#{VALID_RELEASE_TYPES.join("', '")}'"
|
237
|
-
end
|
238
|
-
|
239
249
|
# Returns `true` if the `#release_type` is not nil
|
240
250
|
# @return [Boolean]
|
241
251
|
# @api private
|
242
252
|
def validate_release_type_given
|
243
253
|
return true unless release_type.nil?
|
244
254
|
|
255
|
+
valid_release_types = "'#{VALID_RELEASE_TYPES.join("', '")}'"
|
245
256
|
@errors << "RELEASE_TYPE must be given and be one of #{valid_release_types}"
|
246
257
|
false
|
247
258
|
end
|
@@ -252,6 +263,7 @@ module CreateGithubRelease
|
|
252
263
|
def validate_release_type
|
253
264
|
return true if release_type.nil? || VALID_RELEASE_TYPES.include?(release_type)
|
254
265
|
|
266
|
+
valid_release_types = "'#{VALID_RELEASE_TYPES.join("', '")}'"
|
255
267
|
@errors << "RELEASE_TYPE '#{release_type}' is not valid. Must be one of #{valid_release_types}"
|
256
268
|
false
|
257
269
|
end
|
@@ -364,4 +376,3 @@ module CreateGithubRelease
|
|
364
376
|
end
|
365
377
|
# rubocop:enable Metrics/ClassLength
|
366
378
|
end
|
367
|
-
# rubocop:enable Metrics/ModuleLength
|
@@ -46,7 +46,7 @@ module CreateGithubRelease
|
|
46
46
|
#
|
47
47
|
# @param args [Array<String>] the command line arguments
|
48
48
|
#
|
49
|
-
# @return [CreateGithubRelease::
|
49
|
+
# @return [CreateGithubRelease::CommandLineOptions] the options
|
50
50
|
#
|
51
51
|
def parse(*args)
|
52
52
|
begin
|
@@ -72,7 +72,7 @@ module CreateGithubRelease
|
|
72
72
|
# options = parser.options
|
73
73
|
# options.release_type # => 'major'
|
74
74
|
#
|
75
|
-
# @return [CreateGithubRelease::
|
75
|
+
# @return [CreateGithubRelease::CommandLineOptions] the options
|
76
76
|
#
|
77
77
|
# @api private
|
78
78
|
#
|
@@ -128,6 +128,7 @@ module CreateGithubRelease
|
|
128
128
|
# @return [void]
|
129
129
|
# @api private
|
130
130
|
def define_options
|
131
|
+
# @sg-ignore
|
131
132
|
option_parser.banner = "Usage:\n#{command_template}"
|
132
133
|
option_parser.separator ''
|
133
134
|
option_parser.separator "RELEASE_TYPE must be 'major', 'minor', or 'patch'"
|
@@ -199,7 +200,7 @@ module CreateGithubRelease
|
|
199
200
|
# @return [void]
|
200
201
|
# @api private
|
201
202
|
def define_last_release_version_option
|
202
|
-
option_parser.on('--last-release-version=VERSION', 'Use this version instead `
|
203
|
+
option_parser.on('--last-release-version=VERSION', 'Use this version instead `semverify current`') do |version|
|
203
204
|
options.last_release_version = version
|
204
205
|
end
|
205
206
|
end
|
@@ -208,7 +209,10 @@ module CreateGithubRelease
|
|
208
209
|
# @return [void]
|
209
210
|
# @api private
|
210
211
|
def define_next_release_version_option
|
211
|
-
option_parser.on(
|
212
|
+
option_parser.on(
|
213
|
+
'--next-release-version=VERSION',
|
214
|
+
'Use this version instead `semverify next-RELEASE_TYPE`'
|
215
|
+
) do |version|
|
212
216
|
options.next_release_version = version
|
213
217
|
end
|
214
218
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'semverify'
|
4
4
|
require 'uri'
|
5
5
|
|
6
6
|
module CreateGithubRelease
|
@@ -22,7 +22,8 @@ module CreateGithubRelease
|
|
22
22
|
#
|
23
23
|
# The recommended way to set the attributes is to use method 2 to override values
|
24
24
|
# and otherwise method 3 to use the default value. Method 1 is only recommended for testing
|
25
|
-
# or if there is no other way to accomplish what you need.
|
25
|
+
# or if there is no other way to accomplish what you need. Method 1 should ONLY be
|
26
|
+
# used in the block passed to the initializer.
|
26
27
|
#
|
27
28
|
# @example calling `.new` without a block
|
28
29
|
# options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'minor' }
|
@@ -45,6 +46,8 @@ module CreateGithubRelease
|
|
45
46
|
def initialize(options)
|
46
47
|
@options = options
|
47
48
|
yield self if block_given?
|
49
|
+
|
50
|
+
setup_first_release if release_type == 'first'
|
48
51
|
end
|
49
52
|
|
50
53
|
# @!attribute options [r]
|
@@ -65,7 +68,9 @@ module CreateGithubRelease
|
|
65
68
|
:last_release_tag, :last_release_version, :release_branch, :release_log_url,
|
66
69
|
:release_type, :release_url, :remote, :remote_base_url, :remote_repository, :remote_url,
|
67
70
|
:changelog_path, :changes, :next_release_description, :last_release_changelog,
|
68
|
-
:next_release_changelog, :verbose, :quiet
|
71
|
+
:next_release_changelog, :first_commit, :verbose, :quiet
|
72
|
+
|
73
|
+
# attr_writer :first_release
|
69
74
|
|
70
75
|
# @!attribute [rw] default_branch
|
71
76
|
#
|
@@ -188,7 +193,7 @@ module CreateGithubRelease
|
|
188
193
|
#
|
189
194
|
# The version of the next release
|
190
195
|
#
|
191
|
-
# @example By default, `next_release_version` is based on the value returned by `
|
196
|
+
# @example By default, `next_release_version` is based on the value returned by `semverify <release_type> --dry-run`
|
192
197
|
# options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
|
193
198
|
# project = CreateGithubRelease::Project.new(options)
|
194
199
|
# project.next_release_version #=> '1.0.0'
|
@@ -201,17 +206,12 @@ module CreateGithubRelease
|
|
201
206
|
#
|
202
207
|
# @return [String]
|
203
208
|
#
|
204
|
-
# @raise [RuntimeError] if the
|
209
|
+
# @raise [RuntimeError] if the semverify command fails
|
205
210
|
#
|
206
211
|
# @api public
|
207
212
|
#
|
208
213
|
def next_release_version
|
209
|
-
@next_release_version ||= options.next_release_version ||
|
210
|
-
output = `bump show-next #{release_type}`
|
211
|
-
raise 'Could not determine next version using bump' unless $CHILD_STATUS.success?
|
212
|
-
|
213
|
-
output.lines.last.chomp
|
214
|
-
end
|
214
|
+
@next_release_version ||= options.next_release_version || next_version
|
215
215
|
end
|
216
216
|
|
217
217
|
# @!attribute [rw] last_release_tag
|
@@ -237,14 +237,14 @@ module CreateGithubRelease
|
|
237
237
|
# @api public
|
238
238
|
#
|
239
239
|
def last_release_tag
|
240
|
-
@last_release_tag ||= "v#{last_release_version}"
|
240
|
+
@last_release_tag ||= (first_release? ? '' : "v#{last_release_version}")
|
241
241
|
end
|
242
242
|
|
243
243
|
# @!attribute [rw] last_release_version
|
244
244
|
#
|
245
245
|
# The version of the last release
|
246
246
|
#
|
247
|
-
# @example By default, `last_release_version` is based on the value returned by `
|
247
|
+
# @example By default, `last_release_version` is based on the value returned by `semverify current`
|
248
248
|
# options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
|
249
249
|
# project = CreateGithubRelease::Project.new(options)
|
250
250
|
# project.last_release_version #=> '0.0.1'
|
@@ -257,17 +257,12 @@ module CreateGithubRelease
|
|
257
257
|
#
|
258
258
|
# @return [String]
|
259
259
|
#
|
260
|
-
# @raise [RuntimeError] if the
|
260
|
+
# @raise [RuntimeError] if the semverify command fails
|
261
261
|
#
|
262
262
|
# @api public
|
263
263
|
#
|
264
264
|
def last_release_version
|
265
|
-
@last_release_version ||= options.last_release_version ||
|
266
|
-
output = `bump current`
|
267
|
-
raise 'Could not determine current version using bump' unless $CHILD_STATUS.success?
|
268
|
-
|
269
|
-
output.lines.last.chomp
|
270
|
-
end
|
265
|
+
@last_release_version ||= options.last_release_version || current_version
|
271
266
|
end
|
272
267
|
|
273
268
|
# @!attribute [rw] release_branch
|
@@ -288,7 +283,7 @@ module CreateGithubRelease
|
|
288
283
|
#
|
289
284
|
# @return [String]
|
290
285
|
#
|
291
|
-
# @raise [RuntimeError] if the
|
286
|
+
# @raise [RuntimeError] if the semverify command fails
|
292
287
|
#
|
293
288
|
# @api public
|
294
289
|
#
|
@@ -316,19 +311,23 @@ module CreateGithubRelease
|
|
316
311
|
#
|
317
312
|
# @return [URI]
|
318
313
|
#
|
319
|
-
# @raise [RuntimeError] if the
|
314
|
+
# @raise [RuntimeError] if the semverify command fails
|
320
315
|
#
|
321
316
|
# @api public
|
322
317
|
#
|
323
318
|
def release_log_url
|
324
|
-
@release_log_url ||=
|
319
|
+
@release_log_url ||= begin
|
320
|
+
from = first_release? ? first_commit : last_release_tag
|
321
|
+
to = next_release_tag
|
322
|
+
URI.parse("#{remote_url}/compare/#{from}..#{to}")
|
323
|
+
end
|
325
324
|
end
|
326
325
|
|
327
326
|
# @!attribute [rw] release_type
|
328
327
|
#
|
329
328
|
# The type of the release being created (e.g. 'major', 'minor', 'patch')
|
330
329
|
#
|
331
|
-
# @note this must be one of the values accepted by the `
|
330
|
+
# @note this must be one of the values accepted by the `semverify` command
|
332
331
|
#
|
333
332
|
# @example By default, this value comes from the options object
|
334
333
|
# options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
|
@@ -368,7 +367,7 @@ module CreateGithubRelease
|
|
368
367
|
# project.release_url = URI.parse('https://github.com/org/repo/releases/tag/v1.0.0')
|
369
368
|
# project.release_url #=> #<URI::HTTPS https://github.com/org/repo/releases/tag/v1.0.0>
|
370
369
|
#
|
371
|
-
# @return [URI]
|
370
|
+
# @return [URI::Generic]
|
372
371
|
#
|
373
372
|
# @api public
|
374
373
|
#
|
@@ -420,7 +419,7 @@ module CreateGithubRelease
|
|
420
419
|
# project.remote_base_url = URI.parse('https://github.com/')
|
421
420
|
# project.remote_base_url #=> #<URI::HTTPS https://github.com/>
|
422
421
|
#
|
423
|
-
# @return [URI]
|
422
|
+
# @return [URI::Generic]
|
424
423
|
#
|
425
424
|
# @api public
|
426
425
|
#
|
@@ -536,7 +535,9 @@ module CreateGithubRelease
|
|
536
535
|
#
|
537
536
|
def changes
|
538
537
|
@changes ||= begin
|
539
|
-
|
538
|
+
tip = "'HEAD'"
|
539
|
+
base = first_release? ? '' : "'^#{last_release_tag}' "
|
540
|
+
command = "git log #{tip} #{base}--oneline --format='format:%h\t%s'"
|
540
541
|
git_log = `#{command}`
|
541
542
|
raise "Could not determine changes since #{last_release_tag}" unless $CHILD_STATUS.success?
|
542
543
|
|
@@ -573,15 +574,18 @@ module CreateGithubRelease
|
|
573
574
|
# @api public
|
574
575
|
#
|
575
576
|
def next_release_description
|
576
|
-
@next_release_description ||=
|
577
|
-
|
577
|
+
@next_release_description ||= begin
|
578
|
+
header = first_release? ? 'Changes:' : "Changes since #{last_release_tag}:"
|
579
|
+
<<~DESCRIPTION
|
580
|
+
## #{next_release_tag} (#{next_release_date.strftime('%Y-%m-%d')})
|
578
581
|
|
579
|
-
|
582
|
+
[Full Changelog](#{release_log_url})
|
580
583
|
|
581
|
-
|
584
|
+
#{header}
|
582
585
|
|
583
|
-
|
584
|
-
|
586
|
+
#{list_of_changes}
|
587
|
+
DESCRIPTION
|
588
|
+
end
|
585
589
|
end
|
586
590
|
|
587
591
|
# @!attribute [rw] last_release_changelog
|
@@ -689,6 +693,7 @@ module CreateGithubRelease
|
|
689
693
|
#
|
690
694
|
def to_s
|
691
695
|
<<~OUTPUT
|
696
|
+
first_release: #{first_release}
|
692
697
|
default_branch: #{default_branch}
|
693
698
|
next_release_tag: #{next_release_tag}
|
694
699
|
next_release_date: #{next_release_date}
|
@@ -758,8 +763,84 @@ module CreateGithubRelease
|
|
758
763
|
|
759
764
|
alias quiet? quiet
|
760
765
|
|
766
|
+
# @!attribute [rw] last_release_changelog
|
767
|
+
#
|
768
|
+
# true if release_type is 'first' otherwise false
|
769
|
+
#
|
770
|
+
# @example Returns true if release_type is 'first'
|
771
|
+
# options = CreateGithubRelease::CommandLineOptions.new(release_type: 'first')
|
772
|
+
# project = CreateGithubRelease::Project.new(options)
|
773
|
+
# project.first_release? #=> true
|
774
|
+
#
|
775
|
+
# @example Returnss false if release_type is not 'first'
|
776
|
+
# options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
|
777
|
+
# project = CreateGithubRelease::Project.new(options)
|
778
|
+
# project.first_release? #=> false
|
779
|
+
#
|
780
|
+
# @return [Boolean]
|
781
|
+
#
|
782
|
+
# @api public
|
783
|
+
#
|
784
|
+
def first_release
|
785
|
+
@first_release ||= release_type == 'first'
|
786
|
+
end
|
787
|
+
|
788
|
+
alias first_release? first_release
|
789
|
+
|
790
|
+
# @!attribute [rw] first_commit
|
791
|
+
#
|
792
|
+
# The SHA of the oldest commit that is an ancestor of HEAD
|
793
|
+
#
|
794
|
+
# @example
|
795
|
+
# options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
|
796
|
+
# project = CreateGithubRelease::Project.new(options)
|
797
|
+
# project.first_commit? #=> '1234567'
|
798
|
+
#
|
799
|
+
# @return [String]
|
800
|
+
#
|
801
|
+
# @api public
|
802
|
+
#
|
803
|
+
def first_commit
|
804
|
+
@first_commit ||= begin
|
805
|
+
command = "git log 'HEAD' --oneline --format='format:%h'"
|
806
|
+
git_log = `#{command}`
|
807
|
+
raise "Could not list changes from first commit up to #{last_release_tag}" unless $CHILD_STATUS.success?
|
808
|
+
|
809
|
+
git_log.split("\n").last.chomp
|
810
|
+
end
|
811
|
+
end
|
812
|
+
|
761
813
|
private
|
762
814
|
|
815
|
+
# The current version of the project as determined by semverify
|
816
|
+
# @return [String] The current version of the project
|
817
|
+
# @api private
|
818
|
+
def current_version
|
819
|
+
output = `semverify current`
|
820
|
+
raise 'Could not determine current version using semverify' unless $CHILD_STATUS.success?
|
821
|
+
|
822
|
+
output.lines.last.chomp
|
823
|
+
end
|
824
|
+
|
825
|
+
# The next version of the project as determined by semverify and release_type
|
826
|
+
# @return [String] The next version of the project
|
827
|
+
# @api private
|
828
|
+
def next_version
|
829
|
+
output = `semverify next-#{release_type} --dry-run`
|
830
|
+
raise 'Could not determine next version using semverify' unless $CHILD_STATUS.success?
|
831
|
+
|
832
|
+
output.lines.last.chomp
|
833
|
+
end
|
834
|
+
|
835
|
+
# Setup versions and tags for a first release
|
836
|
+
# @return [void]
|
837
|
+
# @api private
|
838
|
+
def setup_first_release
|
839
|
+
self.next_release_version = @next_release_version || current_version
|
840
|
+
self.last_release_version = ''
|
841
|
+
self.last_release_tag = ''
|
842
|
+
end
|
843
|
+
|
763
844
|
# The list of changes in the release as a string
|
764
845
|
# @return [String] The list of changes in the release as a string
|
765
846
|
# @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::CommandLineOptions]
|
28
28
|
attr_reader :options
|
29
29
|
|
30
30
|
# Create a new instance of ReleaseAssertions
|
@@ -79,6 +79,7 @@ module CreateGithubRelease
|
|
79
79
|
#
|
80
80
|
def make_assertions
|
81
81
|
ASSERTIONS.each do |assertion_class|
|
82
|
+
# @sg-ignore
|
82
83
|
assertion_class.new(options).assert
|
83
84
|
end
|
84
85
|
end
|
@@ -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::CommandLineOptions]
|
28
28
|
attr_reader :options
|
29
29
|
|
30
30
|
# Create a new instance of ReleaseTasks
|
@@ -71,6 +71,7 @@ module CreateGithubRelease
|
|
71
71
|
#
|
72
72
|
def run
|
73
73
|
TASKS.each do |task_class|
|
74
|
+
# @sg-ignore
|
74
75
|
task_class.new(options).run
|
75
76
|
end
|
76
77
|
end
|
@@ -5,12 +5,12 @@ require 'create_github_release/task_base'
|
|
5
5
|
|
6
6
|
module CreateGithubRelease
|
7
7
|
module Tasks
|
8
|
-
# Update the gem version using
|
8
|
+
# Update the gem version using semverify
|
9
9
|
#
|
10
10
|
# @api public
|
11
11
|
#
|
12
12
|
class UpdateVersion < TaskBase
|
13
|
-
# Update the gem version using
|
13
|
+
# Update the gem version using semverify
|
14
14
|
#
|
15
15
|
# @example
|
16
16
|
# require 'create_github_release'
|
@@ -30,11 +30,37 @@ module CreateGithubRelease
|
|
30
30
|
# @raise [SystemExit] if the task fails
|
31
31
|
#
|
32
32
|
def run
|
33
|
+
return if project.first_release?
|
34
|
+
|
33
35
|
print 'Updating version...'
|
34
|
-
|
35
|
-
|
36
|
+
increment_version
|
37
|
+
stage_version_file
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# Increment the version using semverify
|
43
|
+
# @return [void]
|
44
|
+
# @api private
|
45
|
+
def increment_version
|
46
|
+
`semverify next-#{project.release_type}`
|
47
|
+
error 'Could not increment version' unless $CHILD_STATUS.success?
|
48
|
+
end
|
49
|
+
|
50
|
+
# Return the path the the version file using semverify
|
51
|
+
# @return [String]
|
52
|
+
# @api private
|
53
|
+
def version_file
|
54
|
+
output = `semverify file`
|
55
|
+
error 'Semverify could determine the version file' unless $CHILD_STATUS.success?
|
36
56
|
|
37
|
-
|
57
|
+
output.lines.last.chomp
|
58
|
+
end
|
59
|
+
|
60
|
+
# Identify the version file using semverify and stage the change to it
|
61
|
+
# @return [void]
|
62
|
+
# @api private
|
63
|
+
def stage_version_file
|
38
64
|
`git add "#{version_file}"`
|
39
65
|
if $CHILD_STATUS.success?
|
40
66
|
puts 'OK'
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: create_github_release
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: semverify
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
20
|
-
type: :
|
19
|
+
version: '0.3'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler-audit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: debug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '1.36'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: ruby-debug-ide
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.7'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: simplecov
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +156,14 @@ dependencies:
|
|
128
156
|
requirements:
|
129
157
|
- - "~>"
|
130
158
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
159
|
+
version: '0.49'
|
132
160
|
type: :development
|
133
161
|
prerelease: false
|
134
162
|
version_requirements: !ruby/object:Gem::Requirement
|
135
163
|
requirements:
|
136
164
|
- - "~>"
|
137
165
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
166
|
+
version: '0.49'
|
139
167
|
- !ruby/object:Gem::Dependency
|
140
168
|
name: timecop
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,7 +206,9 @@ dependencies:
|
|
178
206
|
- - "~>"
|
179
207
|
- !ruby/object:Gem::Version
|
180
208
|
version: '0.9'
|
181
|
-
description:
|
209
|
+
description: |
|
210
|
+
A script that manages your gem version and creates a GitHub branch, PR, and
|
211
|
+
release for a new gem version.
|
182
212
|
email:
|
183
213
|
- jcouball@yahoo.com
|
184
214
|
executables:
|
@@ -189,6 +219,8 @@ files:
|
|
189
219
|
- ".markdownlint.yml"
|
190
220
|
- ".rspec"
|
191
221
|
- ".rubocop.yml"
|
222
|
+
- ".solargraph.yml"
|
223
|
+
- ".vscode/launch.json"
|
192
224
|
- ".yardopts"
|
193
225
|
- CHANGELOG.md
|
194
226
|
- Gemfile
|
@@ -251,15 +283,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
283
|
requirements:
|
252
284
|
- - ">="
|
253
285
|
- !ruby/object:Gem::Version
|
254
|
-
version:
|
286
|
+
version: 3.0.0
|
255
287
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
288
|
requirements:
|
257
289
|
- - ">="
|
258
290
|
- !ruby/object:Gem::Version
|
259
291
|
version: '0'
|
260
292
|
requirements: []
|
261
|
-
rubygems_version: 3.
|
293
|
+
rubygems_version: 3.4.14
|
262
294
|
signing_key:
|
263
295
|
specification_version: 4
|
264
|
-
summary:
|
296
|
+
summary: A script to create a GitHub release for a Ruby Gem
|
265
297
|
test_files: []
|