create_github_release 1.3.2 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad4b627e248269d5ca7f6b8118c8ec5a1c612b066b091655ef7d0826d395f494
4
- data.tar.gz: bcbeb39161236026fb130678a8539d1bbdf6b363ab5acf40dcacb6b4dbfaa3eb
3
+ metadata.gz: b1b06e7f2c3125675b3b74014f25ed8a3b959d72b4c8f5c0f3740ea233362922
4
+ data.tar.gz: f49f1146fa4e77186582c17cd792a69a3ec6336b438d1a4bbda24d3e6c2bae0c
5
5
  SHA512:
6
- metadata.gz: d851c6e20196cdefd52601d088a4a5d8bb6e2ce687e19e4efb1beba5f10beeb2e0103df378bd4d9ade245a0c95540d8351ee6be8687e5c94f2943de6a2a64d7b
7
- data.tar.gz: 6640d305d84d987b7645fcedb2c2a2b3e17d423d619c256584b442fcfdc44c8354170d96fb07646b32da8d2f496cb48ea9b9bf278591014dadd058f6bdf47975
6
+ metadata.gz: 41c3df4e14cf923a32a6cb8848c219a81ce01a0f4ea766457517028e700e7bdeaa57bbca229313b964c810cded33fe2a036da6c1cdf0bf2821a8dc27e831047f
7
+ data.tar.gz: f7c60f95cfda504347bb13da17938b39a2844df6092e722880bb5b62fe6ec6c50cfe19d500eb5bb5162fbfd25aece3fe13eb27876cb3ade24c6301f97c235ba6
data/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## v1.3.4 (2024-01-09)
9
+
10
+ [Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.3.3..v1.3.4)
11
+
12
+ Changes since v1.3.3:
13
+
14
+ * 23a5db6 Document the revert-github-release script in the project README (#59)
15
+ * 0ed4549 Format the output so next steps are easier to read (#58)
16
+ * 5442745 Wait for some time between creating the release PR and searching for it (#56)
17
+
18
+ ## v1.3.3 (2024-01-08)
19
+
20
+ [Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.3.2..v1.3.3)
21
+
22
+ Changes since v1.3.2:
23
+
24
+ * 69c7a3f Show release PR URL and other minor changes in the output. (#54)
25
+
8
26
  ## v1.3.2 (2024-01-08)
9
27
 
10
28
  [Full Changelog](https://github.com/main-branch/create_github_release/compare/v1.3.1..v1.3.2)
data/README.md CHANGED
@@ -32,8 +32,8 @@ Tested on Ruby 3.0+
32
32
  * [Changing the pre-release type](#changing-the-pre-release-type)
33
33
  * [Creating the release after pre-releases](#creating-the-release-after-pre-releases)
34
34
  * [After Running create-github-release](#after-running-create-github-release)
35
+ * [Reverting `create-github-release`](#reverting-create-github-release)
35
36
  * [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
37
  * [How is the changelog updated?](#how-is-the-changelog-updated)
38
38
  * [Development](#development)
39
39
  * [Contributing](#contributing)
@@ -320,33 +320,28 @@ Finally, publish your gem to rubygems.org with the command:
320
320
  rake release:rubygem_push
321
321
  ```
322
322
 
323
- ## FAQ
323
+ ### Reverting `create-github-release`
324
324
 
325
- ### What if I want to reverse the changes made by this script?
325
+ Should you decide that `create-github-release` was run in error, the `revert-github-release`
326
+ script is provided by this gem to revert the changes made.
326
327
 
327
- You will need to delete the Git tag and branch created by this script both remotely and locally.
328
+ This script must be run before the release PR is merged to the default branch.
328
329
 
329
- In your worktree run the following commands:
330
+ This script must be run in the root directory of the work tree with the release
331
+ branch checked out. This is the state that the `create-github-release` script leaves
332
+ you in.
330
333
 
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
- ```
334
+ This script does the following:
335
+
336
+ * Adds a comment to the release PR noting that it will be reverted
337
+ * Switches the work tree to the default branch so the release branch can be deleted
338
+ * Deletes the local release branch and release tag
339
+ * Deletes the remote release branch and release tag
340
+ * Deletes the release object created in GitHub for this release
341
+
342
+ Deleting the release branch on the remote will automatically close the release PR.
343
+
344
+ ## FAQ
350
345
 
351
346
  ### How is the changelog updated?
352
347
 
@@ -3,6 +3,28 @@
3
3
 
4
4
  require 'create_github_release'
5
5
 
6
+ # Call method up to max_attempts times until it returns a non-nil value
7
+ #
8
+ # @param method [Proc] the method to call
9
+ # @param max_attempts [Integer] the maximum number of attempts to make
10
+ # @param sleep_time [Float] the number of seconds to sleep between attempts
11
+ #
12
+ # @return [Object] the result of the method call or nil
13
+ #
14
+ # @api public
15
+ #
16
+ def wait_for_non_nil(method, max_attempts: 10, sleep_time: 0.5)
17
+ result = nil
18
+
19
+ max_attempts.times do |n|
20
+ sleep sleep_time unless n.zero?
21
+
22
+ break if (result = method.call)
23
+ end
24
+
25
+ result
26
+ end
27
+
6
28
  options = CreateGithubRelease::CommandLine::Parser.new.parse(*ARGV)
7
29
  pp options if options.verbose
8
30
 
@@ -13,18 +35,29 @@ puts unless options.quiet
13
35
  CreateGithubRelease::ReleaseTasks.new(project).run
14
36
 
15
37
  puts <<~MESSAGE unless project.quiet
16
- Release '#{project.next_release_tag}' created successfully
17
- See the release notes at #{project.release_url}
38
+
39
+ SUCCESS: created release '#{project.next_release_tag}'
18
40
 
19
41
  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:
22
42
 
23
- git checkout #{project.default_branch}
24
- git merge --ff-only #{project.release_branch}
25
- git push
43
+ * Review the release notes:
44
+
45
+ #{project.release_url}
46
+
47
+ * Get someone to review and approve the release pull request:
48
+
49
+ #{wait_for_non_nil(-> { project.release_pr_url }, max_attempts: 10, sleep_time: 0.5)}
50
+
51
+ * Merge the pull request manually from the command line with the following
52
+ commands:
53
+
54
+ git checkout #{project.default_branch}
55
+ git merge --ff-only #{project.release_branch}
56
+ git push
57
+
58
+ * Wait for the CI build to pass on the default branch and then release the
59
+ gem with the following command:
26
60
 
27
- Wait for the CI build to pass and then release the gem with the following command:
61
+ rake release:rubygem_push
28
62
 
29
- rake release:rubygem_push
30
63
  MESSAGE
@@ -86,11 +86,13 @@ class Parser
86
86
  It must be run in the root directory of the work tree with the release
87
87
  branch checked out (which is the state create-github-release leaves you in).
88
88
 
89
- This script should be run beefore the release PR is merged.
89
+ This script should be run before the release PR is merged.
90
90
 
91
- This script removes the release branch and release tag both in the local
92
- repository and on the remote. Deleting the branch on GitHub will close the
93
- 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
94
96
 
95
97
  Options:
96
98
  BANNER
@@ -172,4 +174,4 @@ end
172
174
 
173
175
  revert_release!(options)
174
176
 
175
- 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.2'
5
+ VERSION = '1.3.4'
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.2
4
+ version: 1.3.4
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.2/file/CHANGELOG.md
254
- documentation_uri: https://rubydoc.info/gems/create_github_release/1.3.2
253
+ changelog_uri: https://rubydoc.info/gems/create_github_release/1.3.4/file/CHANGELOG.md
254
+ documentation_uri: https://rubydoc.info/gems/create_github_release/1.3.4
255
255
  rubygems_mfa_required: 'true'
256
256
  post_install_message:
257
257
  rdoc_options: []