create_github_release 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6346efaa6cdc82095a7e3220d74dd359a10843f24f81c50037d9c85dbdc9dd8
4
- data.tar.gz: 674903481a785730fde4910bd0994f0cbcbed3196e3355e37775058bc1b0215d
3
+ metadata.gz: b7feefb0f3ef554c8aea3c693cdbbed30aab587be5dc44631101898caadfa658
4
+ data.tar.gz: d342cd8c38e03ca012d5b70daf832642a7434c647d4466d9cd0969e9f4278926
5
5
  SHA512:
6
- metadata.gz: bad25c4943faf700f6cb8593e42a5d2b2f879ec9e6f65fdcab120568e0fc4563b8e4972e76a595c8e2bfaabacba8ee5da98a9ab919bbc763a4aafdc889ba8588
7
- data.tar.gz: 61b4028671f28e714cb88cfade742d515f45d7dba45a158865e2d94ea1ec3e609038ae95446274d018839f162a0743f5ae34f954ae1550016ad99b7afa6d07cf
6
+ metadata.gz: 122c8e2198ceb28fa9e429f851e7c6d821cadc71fb5a3ade6749c520d1ae7d427159f7059e1455a3a2b15294d8e1125e75451d4d1996fceef63f07e7b88b4ffb
7
+ data.tar.gz: e6d1a7abe65328fc51161458934709b9ae3e747573398f4ef71bcdfad4023f865b76ebd6836fe7622183a90909da9498ca6ec30b29deac89d9608b0a225e8d7d
data/.markdownlint.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  default: true
2
2
 
3
3
  # Unordered list indentation
4
- MD007: { indent: 4 }
4
+ MD007: { indent: 2 }
5
5
 
6
6
  # Line length
7
7
  MD013: { line_length: 90, tables: false, code_blocks: false }
data/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ 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.0.0 (2023-02-05)
9
+
10
+ [Full Changelog](https://github.com/main-branch/create_github_release/compare/v0.3.0..v1.0.0)
11
+
12
+ Changes since v0.3.0:
13
+
14
+ * bfd40e6 Handle the first release of a gem (#32)
15
+ * 7a76148 Release v0.3.0 (#31)
16
+
8
17
  ## v0.3.0 (2023-01-29)
9
18
 
10
19
  [Full Changelog](https://github.com/main-branch/create_github_release/compare/v0.2.1..v0.3.0)
data/README.md CHANGED
@@ -5,29 +5,47 @@
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
- Create a GitHub release for a new gem version.
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
- The `create-github-release` script does the following:
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
- * Bumps the project's version
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
- You should merge the pull request once it is reviewed and approved.
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
- Pull the changes from the default branch and publish your gem with the `rake release` command.
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
- Here is the command line --help output:
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 'patch'
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
@@ -43,27 +61,216 @@ Options:
43
61
  -h, --help Show this message
44
62
  ```
45
63
 
46
- The following conditions must be met in order to create a release:
64
+ The RELEASE_TYPE should follow [Semantic Versioning](https://semver.org) rules:
47
65
 
48
- * The bundle must be up to date (via bundle update)
49
- * You current directory must be in the top level of the git repository
50
- * The default branch must be checked out
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
- ## Installation
70
+ This script will be used for three different use cases:
59
71
 
60
- Add `create_github_release` as a development dependency in your project's gemspec:
72
+ ### First release using this script when there were NO prior releases
61
73
 
62
- ```ruby
63
- spec.add_development_dependency 'create_github_release', '~> 0.1'
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 `bump current`)
80
+
81
+ If a different first version number is desired, update the version number in the
82
+ source code making sure that `bump 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
- and then install using `bundle update`.
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 `bump 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 `bump 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 `bump 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 `bump current`
186
+ * Determine the next-release version using `bump show-next RELEASE_TYPE`
187
+ * Bump the project's version using `bump 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
 
@@ -8,8 +8,11 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['James']
9
9
  spec.email = ['jcouball@yahoo.com']
10
10
 
11
- spec.summary = 'Create a GitHub release PR for a Ruby Gem'
12
- spec.description = spec.summary
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
18
  spec.required_ruby_version = '>= 2.7.0'
@@ -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
@@ -8,7 +8,7 @@ module CreateGithubRelease
8
8
  # An array of the valid release types
9
9
  # @return [Array<String>]
10
10
  # @api private
11
- VALID_RELEASE_TYPES = %w[major minor patch].freeze
11
+ VALID_RELEASE_TYPES = %w[major minor patch first].freeze
12
12
 
13
13
  # Regex pattern for a [valid git reference](https://git-scm.com/docs/git-check-ref-format)
14
14
  # @return [Regexp]
@@ -34,7 +34,7 @@ module CreateGithubRelease
34
34
  ) do
35
35
  # @attribute release_type [rw] the type of release to create
36
36
  #
37
- # Must be one of 'major', 'minor', or 'patch'
37
+ # Must be one of the VALID_RELEASE_TYPES
38
38
  #
39
39
  # @example
40
40
  # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
@@ -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
  #
@@ -206,12 +211,7 @@ module CreateGithubRelease
206
211
  # @api public
207
212
  #
208
213
  def next_release_version
209
- @next_release_version ||= options.next_release_version || begin
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 || bump_show_next_version
215
215
  end
216
216
 
217
217
  # @!attribute [rw] last_release_tag
@@ -237,7 +237,7 @@ 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
@@ -262,12 +262,7 @@ module CreateGithubRelease
262
262
  # @api public
263
263
  #
264
264
  def last_release_version
265
- @last_release_version ||= options.last_release_version || begin
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 || bump_current_version
271
266
  end
272
267
 
273
268
  # @!attribute [rw] release_branch
@@ -321,7 +316,11 @@ module CreateGithubRelease
321
316
  # @api public
322
317
  #
323
318
  def release_log_url
324
- @release_log_url ||= URI.parse("#{remote_url}/compare/#{last_release_tag}..#{next_release_tag}")
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
@@ -536,7 +535,9 @@ module CreateGithubRelease
536
535
  #
537
536
  def changes
538
537
  @changes ||= begin
539
- command = "git log 'HEAD' '^#{last_release_tag}' --oneline --format='format:%h\t%s'"
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 ||= <<~DESCRIPTION
577
- ## #{next_release_tag} (#{next_release_date.strftime('%Y-%m-%d')})
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
- [Full Changelog](#{release_log_url})
582
+ [Full Changelog](#{release_log_url})
580
583
 
581
- Changes since #{last_release_tag}:
584
+ #{header}
582
585
 
583
- #{list_of_changes}
584
- DESCRIPTION
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 bump
816
+ # @return [String] The current version of the project
817
+ # @api private
818
+ def bump_current_version
819
+ output = `bump current`
820
+ raise 'Could not determine current version using bump' unless $CHILD_STATUS.success?
821
+
822
+ output.lines.last.chomp
823
+ end
824
+
825
+ # The next version of the project as determined by bump and release_type
826
+ # @return [String] The next version of the project
827
+ # @api private
828
+ def bump_show_next_version
829
+ output = `bump show-next #{release_type}`
830
+ raise 'Could not determine next version using bump' 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 || bump_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
@@ -30,11 +30,38 @@ 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
- message, result = Bump::Bump.run(project.release_type, commit: false)
35
- error "Could not bump version: #{message}" unless result.zero?
36
+ bump_version
37
+ stage_version_file
38
+ end
39
+
40
+ private
41
+
42
+ # Update the version using bump
43
+ # @return [void]
44
+ # @api private
45
+ def bump_version
46
+ `bump #{project.release_type} --no-commit`
47
+ error 'Could not bump version' unless $CHILD_STATUS.success?
48
+ end
49
+
50
+ # Return the path the the version file using bump
51
+ # @return [String]
52
+ # @api private
53
+ def bump_version_file
54
+ output = `bump file`
55
+ error 'Bump could determine the version file' unless $CHILD_STATUS.success?
36
56
 
37
- version_file = Bump::Bump.file
57
+ output.lines.last.chomp
58
+ end
59
+
60
+ # Identify the version file using bump and stage the change to it
61
+ # @return [void]
62
+ # @api private
63
+ def stage_version_file
64
+ version_file = bump_version_file
38
65
  `git add "#{version_file}"`
39
66
  if $CHILD_STATUS.success?
40
67
  puts 'OK'
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CreateGithubRelease
4
4
  # The version of this gem
5
- VERSION = '0.3.0'
5
+ VERSION = '1.0.0'
6
6
  end
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: 0.3.0
4
+ version: 1.0.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-01-30 00:00:00.000000000 Z
11
+ date: 2023-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bump
@@ -178,7 +178,9 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0.9'
181
- description: Create a GitHub release PR for a Ruby Gem
181
+ description: |
182
+ A script that manages your gem version and creates a GitHub branch, PR, and
183
+ release for a new gem version.
182
184
  email:
183
185
  - jcouball@yahoo.com
184
186
  executables:
@@ -258,8 +260,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
260
  - !ruby/object:Gem::Version
259
261
  version: '0'
260
262
  requirements: []
261
- rubygems_version: 3.2.3
263
+ rubygems_version: 3.4.1
262
264
  signing_key:
263
265
  specification_version: 4
264
- summary: Create a GitHub release PR for a Ruby Gem
266
+ summary: A script to create a GitHub release for a Ruby Gem
265
267
  test_files: []