-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
199 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
lib/fastlane/plugin/ddg_apple_automation/actions/asana_create_action_item_action.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
require "fastlane/action" | ||
require "fastlane_core/configuration/config_item" | ||
require "asana" | ||
require "yaml" | ||
require_relative "../helper/ddg_apple_automation_helper" | ||
require_relative "../helper/github_actions_helper" | ||
require_relative "asana_add_comment_action" | ||
require_relative "asana_get_release_automation_subtask_id_action" | ||
require_relative "asana_get_user_id_for_github_handle_action" | ||
require_relative "asana_extract_task_id_action" | ||
require_relative "asana_extract_task_assignee_action" | ||
|
||
module Fastlane | ||
module Actions | ||
class AsanaCreateActionItemAction < Action | ||
def self.run(params) | ||
token = params[:asana_access_token] | ||
task_url = params[:task_url] | ||
task_name = params[:task_name] | ||
notes = params[:notes] | ||
html_notes = params[:html_notes] | ||
template_name = params[:template_name] | ||
is_scheduled_release = params[:is_scheduled_release] | ||
github_handle = params[:github_handle] | ||
|
||
task_id = AsanaExtractTaskIdAction.run(task_url: task_url) | ||
if is_scheduled_release | ||
assignee_id = AsanaExtractTaskAssigneeAction.run(task_id: task_id, asana_access_token: token) | ||
else | ||
if github_handle.to_s.empty? | ||
UI.user_error!("Github handle cannot be empty for manual release") | ||
return | ||
end | ||
assignee_id = AsanaGetUserIdForGithubHandleAction.run(github_handle: github_handle, asana_access_token: token) | ||
end | ||
|
||
Helper::GitHubActionsHelper.set_output("asana_assignee_id", assignee_id) | ||
|
||
asana_client = Asana::Client.new do |c| | ||
c.authentication(:access_token, token) | ||
end | ||
|
||
if template_name | ||
template_file = Helper::DdgAppleAutomationHelper.path_for_asset_file("asana_create_action_item/templates/#{template_name}.yml") | ||
template_content = Helper::DdgAppleAutomationHelper.load_file(template_file) | ||
template_content = YAML.safe_load(template_content) | ||
|
||
task_name = Helper::DdgAppleAutomationHelper.sanitize_and_replace_env_vars(template_content["name"]) | ||
html_notes = Helper::DdgAppleAutomationHelper.sanitize_and_replace_env_vars(template_content["html_notes"]) | ||
subtask = asana_client.tasks.create_subtask_for_task(task_gid: task_id, assignee: assignee_id, name: task_name, html_notes: html_notes) | ||
elsif notes | ||
subtask = asana_client.tasks.create_subtask_for_task(task_gid: task_id, assignee: assignee_id, name: task_name, notes: notes) | ||
elsif html_notes | ||
subtask = asana_client.tasks.create_subtask_for_task(task_gid: task_id, assignee: assignee_id, name: task_name, html_notes: html_notes) | ||
end | ||
|
||
puts(subtask&.gid) | ||
Helper::GitHubActionsHelper.set_output("new_task_id", subtask.gid) | ||
end | ||
|
||
def self.description | ||
"Add a subtask to Asana Release Automation Task" | ||
end | ||
|
||
def self.authors | ||
["DuckDuckGo"] | ||
end | ||
|
||
def self.return_value | ||
"" | ||
end | ||
|
||
def self.details | ||
"Adds a task with an action item to the Asana release task's 'Automation' subtask" | ||
end | ||
|
||
def self.available_options | ||
[ | ||
FastlaneCore::ConfigItem.asana_access_token, | ||
FastlaneCore::ConfigItem.new(key: :task_url, | ||
description: "Asana release task URL", | ||
optional: false, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :task_name, | ||
description: "Task name", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :notes, | ||
description: "Task notes", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :html_notes, | ||
description: "Task HTML notes", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :template_name, | ||
description: "Name of a template file (without extension) for the task content. Templates can be found in assets/asana_create_action_item/templates subdirectory. | ||
The file is processed before being sent to Asana", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :github_handle, | ||
description: "Github user handle", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :is_scheduled_release, | ||
description: "Indicates whether the release was scheduled or started manually", | ||
optional: true, | ||
type: Boolean, | ||
default_value: false) | ||
] | ||
end | ||
|
||
def self.is_supported?(platform) | ||
true | ||
end | ||
end | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
.../ddg_apple_automation/assets/asana_create_action_item/templates/appcast_failed_hotfix.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Generate appcast2.xml for ${TAG} hotfix release and upload assets to S3 | ||
html_notes: | | ||
<body> | ||
Publishing ${TAG} hotfix release failed in CI. Please follow the steps to generate the appcast file and upload files to S3 from your local machine. | ||
<ol> | ||
<li>Create a new file called <code>release-notes.txt</code> on your disk. | ||
<ul> | ||
<li>Add each release note as a separate line and don't add bullet points (•) – the script will add them automatically.</li> | ||
</ul></li> | ||
<li>Run <code>appcastManager</code>: | ||
<ul> | ||
<li><code>./scripts/appcast_manager/appcastManager.swift --release-hotfix-to-public-channel --dmg ~/Downloads/${DMG_NAME} --release-notes release-notes.txt</code></li> | ||
</ul></li> | ||
<li>Verify that the new build is in the appcast file with the latest release notes and no internal channel tag. The phased rollout tag should <em>not</em> be present: | ||
<ul> | ||
<li><code><sparkle:phasedRolloutInterval>43200</sparkle:phasedRolloutInterval></code></li> | ||
</ul></li> | ||
<li>Run <code>upload_to_s3.sh</code> script: | ||
<ul> | ||
<li><code>./scripts/upload_to_s3/upload_to_s3.sh --run --overwrite-duckduckgo-dmg ${VERSION}</code></li> | ||
</ul></li> | ||
</ol> | ||
When done, please verify that "Check for Updates" works correctly: | ||
<ol> | ||
<li>Launch a debug version of the app with an old version number.</li> | ||
<li>Make sure you're not identified as an internal user in the app.</li> | ||
<li>Go to Main Menu → DuckDuckGo → Check for Updates...</li> | ||
<li>Verify that you're being offered to update to ${TAG}.</li> | ||
<li>Verify that the update works.</li> | ||
</ol><br> | ||
🔗 Workflow URL: <a href='${WORKFLOW_URL}'>${WORKFLOW_URL}</a>. | ||
</body> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters