-
-
Notifications
You must be signed in to change notification settings - Fork 104
Improve release-task dry-run UX and AUTO_CONFIRM docs #981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -367,33 +367,46 @@ def ensure_git_tag_exists!(gem_root:, tag:) | |||||||||||
| abort "❌ Git tag #{tag.inspect} was not found locally or remotely. Verify the tag exists before syncing GitHub release." | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| def github_release_command(gem_root:, release_context:, notes_file_path:) | ||||||||||||
| release_exists = system("gh", "release", "view", release_context[:tag], chdir: gem_root, out: File::NULL, err: File::NULL) | ||||||||||||
| abort "❌ Unable to run `gh`. Ensure GitHub CLI is installed and on PATH." if release_exists.nil? | ||||||||||||
|
|
||||||||||||
| if release_exists | ||||||||||||
| # `gh release edit` accepts `--prerelease=true|false`; there is no `--no-prerelease` flag. | ||||||||||||
| ["gh", "release", "edit", release_context[:tag], "--title", release_context[:title], "--notes-file", notes_file_path, | ||||||||||||
| "--prerelease=#{release_context[:prerelease]}"] | ||||||||||||
| else | ||||||||||||
| command = ["gh", "release", "create", release_context[:tag], "--verify-tag", "--title", release_context[:title], | ||||||||||||
| "--notes-file", notes_file_path] | ||||||||||||
| command << "--prerelease" if release_context[:prerelease] | ||||||||||||
| command | ||||||||||||
| end | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| def publish_or_update_github_release(gem_root:, release_context:, dry_run:) | ||||||||||||
| # Keep this check before the dry-run return so preflight runs catch missing tags. | ||||||||||||
| ensure_git_tag_exists!(gem_root: gem_root, tag: release_context[:tag]) | ||||||||||||
|
|
||||||||||||
| if dry_run | ||||||||||||
| preview_command = github_release_command( | ||||||||||||
| gem_root: gem_root, | ||||||||||||
| release_context: release_context, | ||||||||||||
| notes_file_path: "<release-notes-file>" | ||||||||||||
| ) | ||||||||||||
| puts "DRY RUN: Would create or update GitHub release #{release_context[:tag]}#{release_context[:prerelease] ? ' (prerelease)' : ''}" | ||||||||||||
| puts "DRY RUN: Would run: #{Shellwords.join(preview_command)}" | ||||||||||||
|
Comment on lines
+399
to
+401
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The three-line dry-run block is functional, but the first and third lines express the same caveat in slightly different ways. The third line is the more precise one. Consider collapsing to avoid the redundancy and potential confusion about what the command preview actually represents:
Suggested change
Dropping the first generic "Would create or update" line keeps the output focused on what's actionable — the actual command. |
||||||||||||
| return | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| Tempfile.create(["shakapacker-release-notes-", ".md"]) do |tmp| | ||||||||||||
| tmp.write(release_context[:notes]) | ||||||||||||
| tmp.flush | ||||||||||||
|
|
||||||||||||
| # The view probe only needs a boolean result, so use array-form system to avoid an extra shell layer. | ||||||||||||
| release_exists = system("gh", "release", "view", release_context[:tag], chdir: gem_root, out: File::NULL, err: File::NULL) | ||||||||||||
| abort "❌ Unable to run `gh`. Ensure GitHub CLI is installed and on PATH." if release_exists.nil? | ||||||||||||
|
|
||||||||||||
| release_command = if release_exists | ||||||||||||
| # `gh release edit` accepts `--prerelease=true|false`; there is no `--no-prerelease` flag. | ||||||||||||
| ["gh", "release", "edit", release_context[:tag], "--title", release_context[:title], "--notes-file", tmp.path, | ||||||||||||
| "--prerelease=#{release_context[:prerelease]}"] | ||||||||||||
| else | ||||||||||||
| command = ["gh", "release", "create", release_context[:tag], "--verify-tag", "--title", release_context[:title], | ||||||||||||
| "--notes-file", tmp.path] | ||||||||||||
| command << "--prerelease" if release_context[:prerelease] | ||||||||||||
| command | ||||||||||||
| end | ||||||||||||
| release_command = github_release_command( | ||||||||||||
| gem_root: gem_root, | ||||||||||||
| release_context: release_context, | ||||||||||||
| notes_file_path: tmp.path | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| puts "Publishing GitHub release #{release_context[:tag]}#{release_context[:prerelease] ? ' (prerelease)' : ''}" | ||||||||||||
| success = system(*release_command, chdir: gem_root) | ||||||||||||
|
|
@@ -468,7 +481,11 @@ def perform_release( | |||||||||||
| ) | ||||||||||||
| if requested_gem_version.empty? | ||||||||||||
| puts "Computed next patch version: #{resolved_target_gem_version}" | ||||||||||||
| confirm_or_abort!("Proceed with patch release #{resolved_target_gem_version}?") unless dry_run | ||||||||||||
| if dry_run | ||||||||||||
| puts "DRY RUN: Skipping confirmation prompt for patch release #{resolved_target_gem_version}." | ||||||||||||
| else | ||||||||||||
| confirm_or_abort!("Proceed with patch release #{resolved_target_gem_version}?") | ||||||||||||
| end | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| bump_command = if requested_gem_version.empty? | ||||||||||||
|
|
@@ -564,7 +581,11 @@ task :create_release, %i[gem_version dry_run override_version_policy] do |_t, ar | |||||||||||
|
|
||||||||||||
| if changelog_version && Gem::Version.new(changelog_version) > Gem::Version.new(current_version) | ||||||||||||
| puts "Found CHANGELOG.md version: #{changelog_version} (current: #{current_version})" | ||||||||||||
| confirm_or_abort!("Release #{changelog_version} from CHANGELOG.md?") unless is_dry_run | ||||||||||||
| if is_dry_run | ||||||||||||
| puts "DRY RUN: Skipping confirmation prompt for CHANGELOG.md version #{changelog_version}." | ||||||||||||
| else | ||||||||||||
| confirm_or_abort!("Release #{changelog_version} from CHANGELOG.md?") | ||||||||||||
| end | ||||||||||||
| requested_version = changelog_version | ||||||||||||
| else | ||||||||||||
| puts "No new version found in CHANGELOG.md (latest: #{changelog_version || 'none'}, current: #{current_version})." | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.