Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _None_

### New Features

_None_
- Added optional `name` parameter to `create_github_release` action, allowing a custom release title independent of the git tag. Defaults to `version` for backward compatibility. [#703]

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def self.run(params)
url = github_helper.create_release(
repository: repository,
version: version,
name: params[:name],
target: params[:target],
description: release_notes,
assets: assets,
Expand Down Expand Up @@ -64,9 +65,13 @@ def self.available_options
type: String),
FastlaneCore::ConfigItem.new(key: :version,
env_name: 'GHHELPER_CREATE_RELEASE_VERSION',
description: 'The version of the release',
description: 'The version of the release. Used as the git tag name',
optional: false,
type: String),
FastlaneCore::ConfigItem.new(key: :name,
description: 'The display name (title) of the GitHub release. Defaults to the version if not provided',
optional: true,
type: String),
FastlaneCore::ConfigItem.new(key: :target,
env_name: 'GHHELPER_TARGET_COMMITISH',
description: 'The branch name or commit SHA the new tag should point to - if that tag does not exist yet when publishing the release. If omitted, will default to the current HEAD commit at the time of this call',
Expand Down
7 changes: 4 additions & 3 deletions lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def create_milestone(repository:, title:, due_date:, days_until_submission:, day
# Creates a Release on GitHub as a Draft
#
# @param [String] repository The repository to create the GitHub release on. Typically a repo slug (<org>/<repo>).
# @param [String] version The version for which to create this release. Will be used both as the name of the tag and the name of the release.
# @param [String] version The version for which to create this release. Will be used as the git tag name.
# @param [String?] name The display name (title) of the GitHub release. Defaults to the version if not provided.
# @param [String?] target The commit SHA or branch name that this release will point to when it's published and creates the tag.
# If nil (the default), will use the repo's current HEAD commit at the time this method is called.
# Unused if the tag already exists.
Expand All @@ -175,11 +176,11 @@ def create_milestone(repository:, title:, due_date:, days_until_submission:, day
# @param [TrueClass|FalseClass] prerelease Indicates if this should be created as a pre-release (i.e. for alpha/beta)
# @param [TrueClass|FalseClass] is_draft Indicates if this should be created as a draft release
#
def create_release(repository:, version:, description:, assets:, prerelease:, is_draft:, target: nil)
def create_release(repository:, version:, description:, assets:, prerelease:, is_draft:, target: nil, name: nil)
release = client.create_release(
repository,
version, # tag name
name: version, # release name
name: name || version, # release name
target_commitish: target || Git.open(Dir.pwd).log.first.sha,
prerelease: prerelease,
draft: is_draft,
Expand Down
12 changes: 11 additions & 1 deletion spec/github_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,21 @@ def create_milestone(due_date:, days_until_submission:, days_until_release:)
expect(url).to eq(release_url)
end

def create_release(is_draft:, assets: [])
it 'uses a custom name when provided' do
custom_name = 'Version 1.0'
options = { body: test_description, draft: true, name: custom_name, prerelease: false, target_commitish: test_target }
expect(client).to receive(:create_release).with(test_repo, test_tag, options)
allow(client).to receive(:create_release).and_return(html_url: release_url)
url = create_release(is_draft: true, name: custom_name)
expect(url).to eq(release_url)
end

def create_release(is_draft:, assets: [], name: nil)
helper = described_class.new(github_token: 'Fake-GitHubToken-123')
helper.create_release(
repository: test_repo,
version: test_tag,
name: name,
target: test_target,
description: test_description,
assets: assets,
Expand Down