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
- A script to manage your gem version and create a GitHub branch, PR, and release
9
- for a new gem version.
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.
14
-
15
- Tested on Ruby 2.7+
16
-
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 )
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
- * [ How the changelog is updated] ( #how-the-changelog-is-updated )
25
- * [ Limitations] ( #limitations )
26
- * [ Development] ( #development )
27
- * [ Contributing] ( #contributing )
28
- * [ License] ( #license )
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' , ' ~> 0.1 '
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
- ## After Running create-github-release
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 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.
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 ` rake release ` command.
317
+ Finally, publish your gem to rubygems.org with the command:
226
318
227
- ## How the changelog is updated
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 local machine , run ` bundle exec rake install ` .
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 issue tracker ] ( https://github.com/main-branch/create_github_release )
404
+ [ this project's GitHub page ] ( https://github.com/main-branch/create_github_release )
287
405
288
406
## License
289
407
0 commit comments