diff --git a/lib/fastlane/plugin/ddg_apple_automation/actions/test_do_things_action.rb b/lib/fastlane/plugin/ddg_apple_automation/actions/test_do_things_action.rb new file mode 100644 index 0000000..c69b406 --- /dev/null +++ b/lib/fastlane/plugin/ddg_apple_automation/actions/test_do_things_action.rb @@ -0,0 +1,43 @@ +require "fastlane/action" +require "fastlane_core/configuration/config_item" + +module Fastlane + module Actions + class TestDoThingsAction < Action + def self.run(params) + puts("oh yeah!") unless params[:is_hotfix] + end + + def self.description + "Uploads a file to an Asana task" + end + + def self.authors + ["DuckDuckGo"] + end + + def self.return_value + "" + end + + def self.details + # Optional: + "" + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new(key: :is_hotfix, + description: "Asana task ID", + optional: true, + type: Boolean, + default_value: false) + ] + end + + def self.is_supported?(platform) + true + end + end + end +end 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 a2e6514..f968457 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb @@ -68,7 +68,7 @@ def self.extract_asana_task_assignee(task_id, asana_access_token) client = make_asana_client(asana_access_token) begin - task = client.tasks.get_task(task_gid: task_id, options: { opt_fields: ["assignee"] }) + task = client.tasks.get_task(task_gid: task_id, options: { fields: ["assignee"] }) rescue StandardError => e UI.user_error!("Failed to fetch task assignee: #{e}") return @@ -90,7 +90,7 @@ def self.get_release_automation_subtask_id(task_url, asana_access_token) asana_client = make_asana_client(asana_access_token) begin - subtasks = asana_client.tasks.get_subtasks_for_task(task_gid: task_id, options: { opt_fields: ["name", "created_at"] }) + subtasks = asana_client.tasks.get_subtasks_for_task(task_gid: task_id, options: { fields: ["name", "created_at"] }) rescue StandardError => e UI.user_error!("Failed to fetch 'Automation' subtasks for task #{task_id}: #{e}") return @@ -432,6 +432,28 @@ def self.sanitize_asana_html_notes(content) .gsub(%r{}, "\n") # replace
tags with newlines end + def self.get_task_ids_from_git_log(from_ref, to_ref = "HEAD") + git_log = `git log #{from_ref}..#{to_ref}` + + git_log + .gsub("\n", " ") + .scan(%r{\bTask/Issue URL:.*?https://app\.asana\.com[/0-9f]+\b}) + .map { |task_line| task_line.gsub(/.*(https.*)/, '\1') } + .map { |task_url| extract_asana_task_id(task_url, set_gha_output: false) } + end + + def self.fetch_release_notes(release_task_id, asana_access_token, output_type: "asana") + asana_client = make_asana_client(asana_access_token) + release_task_body = asana_client.tasks.get_task(task_gid: release_task_id, options: { fields: ["notes"] }).notes + ReleaseTaskHelper.extract_release_notes(release_task_body, output_type: output_type) + end + + def self.fetch_release_notes(release_task_id, asana_access_token, output_type: "asana") + asana_client = make_asana_client(asana_access_token) + release_task_body = asana_client.tasks.get_task(task_gid: release_task_id, options: { fields: ["notes"] }).notes + ReleaseTaskHelper.extract_release_notes(release_task_body, output_type: output_type) + end + def self.construct_this_release_includes(task_ids) return '' if task_ids.empty?