Skip to content

Commit

Permalink
Update version in hotfix flow (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshann authored Dec 4, 2024
1 parent f8f3d4d commit a0a9431
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ class UpdateAsanaForReleaseAction < Action
def self.run(params)
params[:platform] ||= Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
options = params.values
options[:version] = Helper::DdgAppleAutomationHelper.current_version

if options[:release_type] == 'internal'
options[:version] = Helper::DdgAppleAutomationHelper.current_version
Helper::AsanaHelper.update_asana_tasks_for_internal_release(options)
else
options[:version] = Helper::DdgAppleAutomationHelper.extract_version_from_tag(options[:tag])
announcement_task_html_notes = Helper::AsanaHelper.update_asana_tasks_for_public_release(options)
Fastlane::Actions::AsanaCreateActionItemAction.run(
asana_access_token: options[:asana_access_token],
Expand Down Expand Up @@ -56,6 +57,10 @@ def self.available_options
FastlaneCore::ConfigItem.github_token,
FastlaneCore::ConfigItem.is_scheduled_release,
FastlaneCore::ConfigItem.platform,
FastlaneCore::ConfigItem.new(key: :tag,
description: "Tagged version from Git releases - format <app-version>-<build-number>",
optional: true,
type: String),
FastlaneCore::ConfigItem.new(key: :github_handle,
description: "Github user handle - required when release_type is 'public'",
optional: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ def self.current_version
current_version
end

def self.extract_version_from_tag(tag)
if tag && !tag.empty?
tag.split('-').first
else
Helper::DdgAppleAutomationHelper.current_version
end
end

def self.prepare_release_branch(platform, version, other_action)
code_freeze_prechecks(other_action) unless Helper.is_ci?
new_version = validate_new_version(version)
Expand All @@ -142,6 +150,8 @@ def self.prepare_hotfix_branch(github_token, platform, other_action, options)
source_version = validate_version_exists(version)
new_version = validate_hotfix_version(source_version)
release_branch_name = create_hotfix_branch(platform, source_version, new_version)
update_version_config(new_version, other_action)
other_action.push_to_git_remote
increment_build_number(platform, options, other_action)
Helper::GitHubActionsHelper.set_output("release_branch_name", release_branch_name)

Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/ddg_apple_automation/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module DdgAppleAutomation
VERSION = "0.12.0"
VERSION = "0.12.1"
end
end
6 changes: 6 additions & 0 deletions spec/ddg_apple_automation_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,16 @@ def load_file(file)
allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:create_hotfix_branch)
.with(platform, source_version, new_version).and_return(release_branch_name)

allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:update_version_config)
.with(new_version, other_action)

allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:increment_build_number)
.with(platform, options, other_action)

allow(Fastlane::Helper::GitHubActionsHelper).to receive(:set_output)

expect(other_action).to receive(:push_to_git_remote)

result_branch, result_version = Fastlane::Helper::DdgAppleAutomationHelper.prepare_hotfix_branch(
github_token, platform, other_action, options
)
Expand All @@ -225,6 +230,7 @@ def load_file(file)
expect(Fastlane::Helper::DdgAppleAutomationHelper).to have_received(:validate_version_exists).with(version)
expect(Fastlane::Helper::DdgAppleAutomationHelper).to have_received(:validate_hotfix_version).with(source_version)
expect(Fastlane::Helper::DdgAppleAutomationHelper).to have_received(:create_hotfix_branch).with(platform, source_version, new_version)
expect(Fastlane::Helper::DdgAppleAutomationHelper).to have_received(:update_version_config).with(new_version, other_action)
expect(Fastlane::Helper::DdgAppleAutomationHelper).to have_received(:increment_build_number).with(platform, options, other_action)
expect(Fastlane::Helper::GitHubActionsHelper).to have_received(:set_output).with("last_release", source_version)
expect(Fastlane::Helper::GitHubActionsHelper).to have_received(:set_output).with("release_branch_name", release_branch_name)
Expand Down
14 changes: 11 additions & 3 deletions spec/update_asana_for_release_action_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
describe Fastlane::Actions::UpdateAsanaForReleaseAction do
describe ".run" do
let(:tag) { nil }
let(:params) do
{
asana_access_token: "secret-token",
Expand All @@ -9,7 +10,8 @@
github_handle: "github_user",
release_task_id: "1234567890",
release_type: release_type,
target_section_id: "987654321"
target_section_id: "987654321",
tag: tag
}
end

Expand All @@ -28,20 +30,26 @@
let(:release_type) { "internal" }

it "updates Asana tasks for internal release" do
expect(Fastlane::Helper::AsanaHelper).to receive(:update_asana_tasks_for_internal_release).with(hash_including(release_task_id: "1234567890"))
expect(Fastlane::Helper::AsanaHelper).to receive(:update_asana_tasks_for_internal_release).with(
hash_including(
release_task_id: "1234567890",
version: "1.1.0"
)
)
subject
end
end

context "when release type is public" do
let(:release_type) { "public" }
let(:tag) { "1.116.1-322" }

before do
allow(Fastlane::Helper::AsanaHelper).to receive(:update_asana_tasks_for_public_release).and_return("Announcement task notes")
end

it "updates Asana tasks for public release" do
expect(Fastlane::Helper::AsanaHelper).to receive(:update_asana_tasks_for_public_release).with(hash_including(release_task_id: "1234567890"))
expect(Fastlane::Helper::AsanaHelper).to receive(:update_asana_tasks_for_public_release).with(hash_including(release_task_id: "1234567890", version: "1.116.1"))
subject
end

Expand Down

0 comments on commit a0a9431

Please sign in to comment.