class CreateGithubRelease::Tasks::CreateReleasePullRequest


@api public
Create a pull request in Github with a list of changes

def command(tag, path, default_branch)

Other tags:
    Api: - private

Returns:
  • (String) - The command to create the release pull request

Parameters:
  • default_branch (String) -- The default branch for the repository
  • path (String) -- The path to the file with the PR body
  • tag (String) -- The tag for the release
def command(tag, path, default_branch)
  command = [
    'gh', 'pr', 'create',
    '--title', "'Release #{tag}'",
    '--body-file', "'#{path}'",
    '--base', "'#{default_branch}'"
  ]
  command += ['--label', "'#{project.release_pr_label}'"] if project.release_pr_label
  command.join(' ')
end

def create_release_pr(path)

Other tags:
    Api: - private

Raises:
  • (SystemExit) - if the gh command fails

Returns:
  • (void) -
def create_release_pr(path)
  print 'Creating GitHub pull request...'
  tag = project.next_release_tag
  default_branch = project.default_branch
  `#{command(tag, path, default_branch)}`
  if $CHILD_STATUS.success?
    puts 'OK'
  else
    error 'Could not create release pull request'
  end
end

def run

Raises:
  • (SystemExit) - if the task fails

Returns:
  • (void) -
def run
  tmp_path = write_pr_body_to_tmp_file
  begin
    create_release_pr(tmp_path)
  ensure
    File.unlink(tmp_path)
  end
end

def write_pr_body_to_tmp_file

Other tags:
    Api: - private

Raises:
  • (SystemExit) - if the temp could not be created

Returns:
  • (String) - the path to the temporary file
def write_pr_body_to_tmp_file
  begin
    f = Tempfile.create
  rescue StandardError => e
    error "Could not create a temporary file: #{e.message}"
  end
  f.write("# Release PR\n\n#{project.next_release_description}")
  f.close
  f.path
end