class GemHadar
def github_release_task
remote URL, generates a changelog using AI, and creates the release via the
from the environment, derives the repository owner and name from the git
publishing a release message on GitHub. It retrieves the GitHub API token
This method sets up a :github:release task that prompts the user to confirm
release for the current version.
The github_release_task method defines a Rake task that creates a GitHub
def github_release_task namespace :github do unless github_api_token = ENV['GITHUB_API_TOKEN'].full? warn "GITHUB_API_TOKEN not set. => Skipping github release task." task :release return end desc "Create a new GitHub release for the current version with a AI-generated changelog" task :release do yes = ask?( "Do you want to publish a release message on github? (y/n%{default}) ", /\Ay/i, default: ENV['GITHUB_RELEASE_ENABLED'] ) unless yes warn "Skipping publication of a github release message." next end if %r(\A/*(?<owner>[^/]+)/(?<repo>[^/.]+)) =~ github_remote_url&.path rc = GitHub::ReleaseCreator.new(owner:, repo:, token: github_api_token) tag_name = version_tag(version) target_commitish = `git show -s --format=%H #{tag_name.inspect}^{commit}`.chomp body = edit_temp_file(create_git_release_body) if body.present? begin response = rc.perform(tag_name:, target_commitish:, body:) puts "Release created successfully! See #{response.html_url}" rescue => e warn e.message end else warn "Skipping creation of github release message." end else warn "Could not derive github remote url from git remotes. => Skipping github release task." end end end end