create_github_release 1.3.1 → 1.3.3

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: b8dd471fba24b22c130b2d03d534e44b46753300a3e41ff08bb8d68b93e6cdee
4
- data.tar.gz: 51d08847e10a5856b3a94fd7ee774ca104e47db954bdf73ea1fc4749529600b9
3
+ metadata.gz: aaae536c7d44e9ced42bb4598ebf91b3e803766c3a9b6283185fee4c7327c3db
4
+ data.tar.gz: bbbb70f42b368e513d419b2c16490b8ef48d4f6269df342f5d23db6e3088927c
5
5
  SHA512:
6
- metadata.gz: f926991f50c625bdbef00025bdb7f618268c1e1eba763bd320ef38e94885ea3da8a626e5f3b3747e6def444653fa33cb88bcc751cf0fa1403dee518a704afa7c
7
- data.tar.gz: e520e45d0015579988f9bbb554afe065e2169905be3dcf6fd36d8bf0191f157eb865080db6205d12acccbc390e23543ca7fbcbffa324c75e99bda61e3bc7b9b9
6
+ metadata.gz: c3b4a8e4380a61ade20ea5833f7016bed6c5e056b37e78fb2cc6f589fcdce575d0cdd998c1d920507a3b2e6bca16837f99a02724e8d88e01ef9f00e1c9d066ff
7
+ data.tar.gz: df667078c1f6b9baccb7736a715343c8271dd3054ec42b96fa5bfb1115f955014a3f59f297e2d9cbdd15546dc787383e663c9eb0f756651e8ac812d5d4c35c32
data/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ 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.3 (2024-01-08)
9
+
10
+ [Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.3.2..v1.3.3)
11
+
12
+ Changes since v1.3.2:
13
+
14
+ * 69c7a3f Show release PR URL and other minor changes in the output. (#54)
15
+
16
+ ## v1.3.2 (2024-01-08)
17
+
18
+ [Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.3.1..v1.3.2)
19
+
20
+ Changes since v1.3.1:
21
+
22
+ * 6b0e295 Delete the release in GitHub and add a comment to the release PR (#52)
23
+
8
24
  ## v1.3.1 (2024-01-08)
9
25
 
10
26
  [Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.3.0..v1.3.1)
@@ -13,18 +13,28 @@ puts unless options.quiet
13
13
  CreateGithubRelease::ReleaseTasks.new(project).run
14
14
 
15
15
  puts <<~MESSAGE unless project.quiet
16
- Release '#{project.next_release_tag}' created successfully
17
- See the release notes at #{project.release_url}
16
+ SUCCESS: created release '#{project.next_release_tag}'
18
17
 
19
18
  Next steps:
20
- * Get someone to review and approve the release pull request
21
- * Merge the pull request manually from the command line with the following commands:
19
+
20
+ * Review the release notes:
21
+
22
+ #{project.release_url}
23
+
24
+ * Get someone to review and approve the release pull request:
25
+
26
+ #{project.release_pr_url}
27
+
28
+ * Merge the pull request manually from the command line with the following
29
+ commands:
22
30
 
23
31
  git checkout #{project.default_branch}
24
32
  git merge --ff-only #{project.release_branch}
25
33
  git push
26
34
 
27
- Wait for the CI build to pass and then release the gem with the following command:
35
+ * Wait for the CI build to pass on the default branch and then release the
36
+ gem with the following command:
28
37
 
29
38
  rake release:rubygem_push
39
+
30
40
  MESSAGE
@@ -19,6 +19,7 @@ class Options
19
19
  def release_tag = @release_tag ||= "v#{release_version}"
20
20
  def release_branch = @release_branch ||= "release-#{release_tag}"
21
21
  def current_branch = @current_branch ||= `git rev-parse --abbrev-ref HEAD`.chomp
22
+ def release_pr = @release_pr ||= `gh pr list --search "head:#{release_branch}" --json number --jq ".[].number"`.chomp
22
23
  def remote = @remote ||= 'origin'
23
24
  end
24
25
 
@@ -79,15 +80,19 @@ class Parser
79
80
  Usage:
80
81
  #{File.basename($PROGRAM_NAME)} [--help | --version]
81
82
 
83
+ Version #{CreateGithubRelease::VERSION}
84
+
82
85
  This script reverts the effect of running the create-github-release script.
83
86
  It must be run in the root directory of the work tree with the release
84
87
  branch checked out (which is the state create-github-release leaves you in).
85
88
 
86
- This script should be run beefore the release PR is merged.
89
+ This script should be run before the release PR is merged.
87
90
 
88
- This script removes the release branch and release tag both in the local
89
- repository and on the remote. Deleting the branch on GitHub will close the
90
- GitHub PR automatically.
91
+ This script does the following:
92
+ * Deletes the local and remote release branch
93
+ * Deletes the local and remote release tag
94
+ * Deletes the GitHub release object
95
+ * Closes the GitHub release PR
91
96
 
92
97
  Options:
93
98
  BANNER
@@ -139,6 +144,16 @@ def ref_exists?(name)
139
144
  $CHILD_STATUS.success?
140
145
  end
141
146
 
147
+ def revert_release!(options)
148
+ `gh pr comment #{options.release_pr} --body="Reverting this release using revert-github-release"`
149
+ `git checkout #{options.default_branch} >/dev/null`
150
+ `git branch -D #{options.release_branch} >/dev/null`
151
+ `git tag -d #{options.release_tag} >/dev/null`
152
+ `git push #{options.remote} --delete #{options.release_branch} >/dev/null`
153
+ `git push #{options.remote} --delete #{options.release_tag} >/dev/null`
154
+ `gh release delete #{options.release_tag} --yes >/dev/null`
155
+ end
156
+
142
157
  unless in_work_tree? && in_root_directory?
143
158
  warn 'ERROR: Not in the root directory of a Git work tree'
144
159
  exit 1
@@ -157,10 +172,6 @@ unless ref_exists?(options.default_branch)
157
172
  exit 1
158
173
  end
159
174
 
160
- `git checkout #{options.default_branch} >/dev/null`
161
- `git branch -D #{options.release_branch} >/dev/null`
162
- `git tag -d #{options.release_tag} >/dev/null`
163
- `git push #{options.remote} --delete #{options.release_branch} >/dev/null`
164
- `git push #{options.remote} --delete #{options.release_tag} >/dev/null`
175
+ revert_release!(options)
165
176
 
166
- puts "Reverted release #{options.release_version}"
177
+ puts "SUCCESS: reverted release '#{options.release_version}'"
@@ -69,7 +69,7 @@ module CreateGithubRelease
69
69
  :release_type, :pre, :pre_type, :release_url, :remote, :remote_base_url,
70
70
  :remote_repository, :remote_url, :changelog_path, :changes,
71
71
  :next_release_description, :last_release_changelog, :next_release_changelog,
72
- :first_commit, :verbose, :quiet
72
+ :first_commit, :verbose, :quiet, :release_pr_number, :release_pr_url
73
73
 
74
74
  # attr_writer :first_release
75
75
 
@@ -324,6 +324,47 @@ module CreateGithubRelease
324
324
  end
325
325
  end
326
326
 
327
+ # @!attribute [rw] release_pr_number
328
+ #
329
+ # The number of the pull request created for the release or nil
330
+ #
331
+ # The PR must already exist.
332
+ #
333
+ # @example
334
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
335
+ # project = CreateGithubRelease::Project.new(options)
336
+ # project.release_pr_number #=> '123'
337
+ #
338
+ # @return [String, nil]
339
+ #
340
+ # @api public
341
+ #
342
+ def release_pr_number
343
+ @release_pr_number ||= begin
344
+ pr_number = `gh pr list --search "head:#{release_branch}" --json number --jq ".[].number"`.chomp
345
+ pr_number.empty? ? nil : pr_number
346
+ end
347
+ end
348
+
349
+ # @!attribute [rw] release_pr_url
350
+ #
351
+ # The url of the pull request created for the release or nil
352
+ #
353
+ # The PR must already exist.
354
+ #
355
+ # @example
356
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
357
+ # project = CreateGithubRelease::Project.new(options)
358
+ # project.release_pr_url #=> 'https://github.com/org/repo/pull/123'
359
+ #
360
+ # @return [String]
361
+ #
362
+ # @api public
363
+ #
364
+ def release_pr_url
365
+ @release_pr_url ||= release_pr_number.nil? ? nil : URI.parse("#{remote_url}/pull/#{release_pr_number}")
366
+ end
367
+
327
368
  # @!attribute [rw] release_type
328
369
  #
329
370
  # The type of the release being created (e.g. 'major', 'minor', 'patch')
@@ -713,12 +754,15 @@ module CreateGithubRelease
713
754
  CreateGithubRelease::Changelog.new(last_release_changelog, next_release_description).to_s
714
755
  end
715
756
 
757
+ # rubocop:disable Metrics/AbcSize
758
+
716
759
  # Show the project details as a string
717
760
  #
718
761
  # @example
719
762
  # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
720
763
  # project = CreateGithubRelease::Project.new(options)
721
764
  # puts projects.to_s
765
+ # first_release: false
722
766
  # default_branch: main
723
767
  # next_release_tag: v1.0.0
724
768
  # next_release_date: 2023-02-01
@@ -733,6 +777,8 @@ module CreateGithubRelease
733
777
  # remote_base_url: https://github.com/
734
778
  # remote_repository: org/repo
735
779
  # remote_url: https://github.com/org/repo
780
+ # release_pr_number: 123
781
+ # release_pr_url: https://github.com/org/repo/pull/123
736
782
  # changelog_path: CHANGELOG.md
737
783
  # verbose?: false
738
784
  # quiet?: false
@@ -758,11 +804,16 @@ module CreateGithubRelease
758
804
  remote_base_url: #{remote_base_url}
759
805
  remote_repository: #{remote_repository}
760
806
  remote_url: #{remote_url}
807
+ release_pr_number: #{release_pr_number}
808
+ release_pr_url: #{release_pr_url}
809
+ changelog_path: #{changelog_path}
761
810
  verbose?: #{verbose?}
762
811
  quiet?: #{quiet?}
763
812
  OUTPUT
764
813
  end
765
814
 
815
+ # rubocop:enable Metrics/AbcSize
816
+
766
817
  # @!attribute [rw] verbose
767
818
  #
768
819
  # If `true` enables verbose output
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CreateGithubRelease
4
4
  # The version of this gem
5
- VERSION = '1.3.1'
5
+ VERSION = '1.3.3'
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: 1.3.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semverify
@@ -250,8 +250,8 @@ metadata:
250
250
  allowed_push_host: https://rubygems.org
251
251
  homepage_uri: https://github.com/main-branch/create_github_release
252
252
  source_code_uri: https://github.com/main-branch/create_github_release
253
- changelog_uri: https://rubydoc.info/gems/create_github_release/1.3.1/file/CHANGELOG.md
254
- documentation_uri: https://rubydoc.info/gems/create_github_release/1.3.1
253
+ changelog_uri: https://rubydoc.info/gems/create_github_release/1.3.3/file/CHANGELOG.md
254
+ documentation_uri: https://rubydoc.info/gems/create_github_release/1.3.3
255
255
  rubygems_mfa_required: 'true'
256
256
  post_install_message:
257
257
  rdoc_options: []