From 918b608629124436d280ad9658714149ec7a3f99 Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Wed, 2 Oct 2024 06:48:54 -0400 Subject: [PATCH] Add repo_name to git_helper --- .../actions/start_new_release_action.rb | 18 ------------------ .../helper/asana_helper.rb | 16 ++++++++++++++-- .../ddg_apple_automation/helper/git_helper.rb | 11 +++++++++++ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/lib/fastlane/plugin/ddg_apple_automation/actions/start_new_release_action.rb b/lib/fastlane/plugin/ddg_apple_automation/actions/start_new_release_action.rb index f9ffce1..f15ac37 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/actions/start_new_release_action.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/actions/start_new_release_action.rb @@ -9,27 +9,9 @@ module Fastlane module Actions class StartNewReleaseAction < Action - @constants = {} - - def self.setup_constants(platform) - case platform - when "ios" - @constants = { - repo_name: "duckduckgo/ios", - release_tag_prefix: "ios-app-release-" - } - when "macos" - @constants = { - repo_name: "duckduckgo/macos-browser", - release_tag_prefix: "macos-app-release-" - } - end - end - def self.run(params) Helper::GitHelper.setup_git_user params[:platform] ||= Actions.lane_context[Actions::SharedValues::PLATFORM_NAME] - setup_constants(params[:platform]) options = params.values options[:asana_user_id] = Helper::AsanaHelper.get_asana_user_id_for_github_handle(options[:github_handle]) diff --git a/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb b/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb index 0e0e2ee..7107b61 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb @@ -3,6 +3,7 @@ require "httparty" require "octokit" require_relative "ddg_apple_automation_helper" +require_relative "git_helper" require_relative "github_actions_helper" require_relative "release_task_helper" @@ -147,6 +148,17 @@ def self.release_task_name(version, platform, is_hotfix: false) end end + def self.release_tag_name(version, platform) + case platform + when "ios" + "ios-app-release-#{version}" + when "macos" + "macos-app-release-#{version}" + else + UI.user_error!("Unsupported platform: #{platform}") + end + end + def self.release_section_id(platform) case platform when "ios" @@ -205,7 +217,7 @@ def self.create_release_task(platform, version, assignee_id, asana_access_token) def self.update_asana_tasks_for_release(params) UI.message("Checking latest public release in GitHub") client = Octokit::Client.new(access_token: params[:github_token]) - latest_public_release = client.latest_release(@constants[:repo_name]) + latest_public_release = client.latest_release(Helper::GitHelper.repo_name(params[:platform])) UI.success("Latest public release: #{latest_public_release.tag_name}") UI.message("Extracting task IDs from git log since #{latest_public_release.tag_name} release") @@ -230,7 +242,7 @@ def self.update_asana_tasks_for_release(params) move_tasks_to_section(task_ids, params[:validation_section_id], params[:asana_access_token]) UI.success("All tasks moved to Validation section") - tag_name = "#{@constants[:release_tag_prefix]}#{params[:version]}" + tag_name = release_tag_name(params[:version], params[:platform]) UI.message("Fetching or creating #{tag_name} Asana tag") tag_id = find_or_create_asana_release_tag(tag_name, params[:release_task_id], params[:asana_access_token]) UI.success("#{tag_name} tag URL: #{asana_tag_url(tag_id)}") diff --git a/lib/fastlane/plugin/ddg_apple_automation/helper/git_helper.rb b/lib/fastlane/plugin/ddg_apple_automation/helper/git_helper.rb index a2fa77d..e087ca4 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/helper/git_helper.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/helper/git_helper.rb @@ -7,6 +7,17 @@ module Fastlane module Helper class GitHelper + def self.repo_name(platform) + case platform + when "ios" + "duckduckgo/ios" + when "macos" + "duckduckgo/macos-browser" + else + UI.user_error!("Unsupported platform: #{platform}") + end + end + def self.setup_git_user(name: "Dax the Duck", email: "dax@duckduckgo.com") Actions.sh("echo \"git config --global user.name '#{name}'\"") Actions.sh("echo \"git config --global user.email '#{email}'\"")