diff --git a/lib/discharger/steps/release.rb b/lib/discharger/steps/release.rb index 955cabb..e8b53f1 100644 --- a/lib/discharger/steps/release.rb +++ b/lib/discharger/steps/release.rb @@ -77,35 +77,82 @@ def push_to_production @task.sysecho <<~MSG Version #{current_version} released to production. + MSG - Preparing to bump the version for the next release. + prepare_next_version + end + end + def prepare_next_version + if mono_repo + @task.sysecho <<~MSG.bg(:yellow).black + Would you like to tag and release #{gem_tag} of the #{gem_name} gem? + + Type 'y' to tag and release, or just press Enter to continue without. MSG - @tasker["reissue"].invoke - new_version = Object.const_get(@task.version_constant) - new_version_branch = "bump/begin-#{new_version.tr(".", "-")}" - continue = @task.syscall(["git checkout -b #{new_version_branch}"]) + input = $stdin.gets + should_tag_gem = input.chomp.match?(/^y/i) - abort "Bump failed." unless continue + if should_tag_gem + if @task.syscall( + ["git tag #{gem_tag}"], + ["git push --tags"] + ) + @task.sysecho "Successfully tagged and pushed #{gem_tag}" + else + manually_push_tag_warning + end + end + end - pr_url = "#{@task.pull_request_url}/compare/#{@task.working_branch}...#{new_version_branch}?expand=1&title=Begin%20#{current_version}" + @task.sysecho <<~MSG + Preparing to bump the version for the next release. - @task.syscall(["git push origin #{new_version_branch} --force"]) do - @task.sysecho <<~MSG - Branch #{new_version_branch} created. + MSG - Open a PR to #{@task.working_branch} to mark the version and update the chaneglog - for the next release. + @tasker["reissue"].invoke + new_version = Object.const_get(@task.version_constant) + new_version_branch = "bump/begin-#{new_version.tr(".", "-")}" + continue = @task.syscall(["git checkout -b #{new_version_branch}"]) - Opening PR: #{pr_url} - MSG - end.then do |success| - @task.syscall ["open #{pr_url}"] if success - end + abort "Bump failed." unless continue + + pr_url = "#{@task.pull_request_url}/compare/#{@task.working_branch}...#{new_version_branch}?expand=1&title=Begin%20#{current_version}" + @task.syscall(["git push origin #{new_version_branch} --force"]) do + @task.sysecho <<~MSG + Branch #{new_version_branch} created. + + Open a PR to #{@task.working_branch} to mark the version and update the chaneglog + for the next release. + + Opening PR: #{pr_url} + MSG + end.then do |success| + @task.syscall ["open #{pr_url}"] if success end end + def manually_push_tag_warning + @task.sysecho <<~MSG.bg(:red) + Warning: Failed to tag and push #{gem_tag} + + Release flow must continue, and tagging will need to be done manually. + Follow these steps: + 1) Manually push the tags. + `git tag #{gem_tag}` + `git push --tags` + 2) Verify + - go to the workflows page + - go to the gem page that lists versions + - confirm that the tag released + 3) Prepare for the next release + - update the gem version file to the next version + - `bundle install` + - PR + MSG + end + def establish_config @task.desc "Echo the configuration settings." @task.task "#{@task.name}:config" do