From 846484e5d077d5bf28c8f62cb2579997934b791e Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Wed, 2 Oct 2024 06:06:45 -0400 Subject: [PATCH] Move update_asana_tasks_for_release into asana helper --- .../actions/bump_internal_release_action.rb | 15 +++++-- .../actions/start_new_release_action.rb | 40 +------------------ .../helper/asana_helper.rb | 39 ++++++++++++++++++ 3 files changed, 52 insertions(+), 42 deletions(-) diff --git a/lib/fastlane/plugin/ddg_apple_automation/actions/bump_internal_release_action.rb b/lib/fastlane/plugin/ddg_apple_automation/actions/bump_internal_release_action.rb index 9fbe368..e5e8428 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/actions/bump_internal_release_action.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/actions/bump_internal_release_action.rb @@ -1,5 +1,6 @@ require "fastlane/action" require "fastlane_core/configuration/config_item" +require_relative "../helper/asana_helper" require_relative "../helper/ddg_apple_automation_helper" require_relative "../helper/git_helper" @@ -10,10 +11,12 @@ def self.run(params) Helper::GitHelper.setup_git_user params[:platform] ||= Actions.lane_context[Actions::SharedValues::PLATFORM_NAME] Helper::DdgAppleAutomationHelper.bump_version_and_build_number(params[:platform], params, other_action) + + Helper::AsanaHelper.update_asana_tasks_for_release(options) end def self.description - "Bumps the project build number (and optionally sets a new version) and pushes the changes to the remote repository" + "Starts a new internal release" end def self.authors @@ -25,8 +28,14 @@ def self.return_value end def self.details - # Optional: - "" + <<-DETAILS +This action performs the following tasks: +* finds the git branch and Asana task for the current internal release, +* checks for are changes to the release branch, +* ensures that release notes aren't empty or placeholder, +* increments the project build number, +* pushes the changes to the remote repository. + DETAILS end def self.available_options 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 43b7587..f9ffce1 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 @@ -43,45 +43,7 @@ def self.run(params) release_task_id = Helper::AsanaHelper.create_release_task(options[:platform], options[:version], options[:asana_user_id], options[:asana_access_token]) options[:release_task_id] = release_task_id - update_asana_tasks_for_release(options) - end - - 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]) - 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") - task_ids = Helper::AsanaHelper.get_task_ids_from_git_log(latest_public_release.tag_name) - UI.success("#{task_ids.count} task(s) found.") - - UI.message("Fetching release notes from Asana release task (#{Helper::AsanaHelper.asana_task_url(params[:release_task_id])})") - release_notes = Helper::AsanaHelper.fetch_release_notes(params[:release_task_id], params[:asana_access_token]) - UI.success("Release notes: #{release_notes}") - - UI.message("Generating release task description using fetched release notes and task IDs") - html_notes = Helper::ReleaseTaskHelper.construct_release_task_description(release_notes, task_ids) - - UI.message("Updating release task") - asana_client = Helper::AsanaHelper.make_asana_client(params[:asana_access_token]) - asana_client.tasks.update_task(task_gid: params[:release_task_id], html_notes: html_notes) - UI.success("Release task content updated: #{Helper::AsanaHelper.asana_task_url(params[:release_task_id])}") - - task_ids.append(params[:release_task_id]) - - UI.message("Moving tasks to Validation section") - Helper::AsanaHelper.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]}" - UI.message("Fetching or creating #{tag_name} Asana tag") - tag_id = Helper::AsanaHelper.find_or_create_asana_release_tag(tag_name, params[:release_task_id], params[:asana_access_token]) - UI.success("#{tag_name} tag URL: #{Helper::AsanaHelper.asana_tag_url(tag_id)}") - - UI.message("Tagging tasks with #{tag_name} tag") - Helper::AsanaHelper.tag_tasks(tag_id, task_ids, params[:asana_access_token]) - UI.success("All tasks tagged with #{tag_name} tag") + Helper::AsanaHelper.update_asana_tasks_for_release(options) end def self.description 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 76eb2af..2659845 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb @@ -1,6 +1,7 @@ require "fastlane_core/ui/ui" require "asana" require "httparty" +require "octokit" require_relative "ddg_apple_automation_helper" require_relative "github_actions_helper" require_relative "release_task_helper" @@ -193,6 +194,44 @@ def self.create_release_task(platform, version, assignee_id, asana_access_token) task_id end + 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]) + 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") + task_ids = get_task_ids_from_git_log(latest_public_release.tag_name) + UI.success("#{task_ids.count} task(s) found.") + + UI.message("Fetching release notes from Asana release task (#{asana_task_url(params[:release_task_id])})") + release_notes = fetch_release_notes(params[:release_task_id], params[:asana_access_token]) + UI.success("Release notes: #{release_notes}") + + UI.message("Generating release task description using fetched release notes and task IDs") + html_notes = Helper::ReleaseTaskHelper.construct_release_task_description(release_notes, task_ids) + + UI.message("Updating release task") + asana_client = make_asana_client(params[:asana_access_token]) + asana_client.tasks.update_task(task_gid: params[:release_task_id], html_notes: html_notes) + UI.success("Release task content updated: #{asana_task_url(params[:release_task_id])}") + + task_ids.append(params[:release_task_id]) + + UI.message("Moving tasks to Validation section") + 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]}" + 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)}") + + UI.message("Tagging tasks with #{tag_name} tag") + tag_tasks(tag_id, task_ids, params[:asana_access_token]) + UI.success("All tasks tagged with #{tag_name} tag") + end + def self.move_tasks_to_section(task_ids, section_id, asana_access_token) asana_client = make_asana_client(asana_access_token)