From 9d1a394291ae95c7d982ade9f1bbebe137ce3744 Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Sun, 15 Sep 2024 11:16:02 +0200 Subject: [PATCH] Add process_erb_template in DdgAppleAutomationHelper and improve parsing ERB templates --- .../actions/asana_add_comment_action.rb | 6 +--- .../asana_create_action_item_action.rb | 7 +---- .../templates/appcast-failed-hotfix.html.erb | 8 +++--- .../appcast-failed-internal.html.erb | 8 +++--- .../templates/appcast-failed-public.html.erb | 8 +++--- .../templates/debug-symbols-uploaded.html.erb | 4 +-- .../templates/dmg-uploaded.html.erb | 4 +-- .../templates/hotfix-branch-ready.html.erb | 6 ++-- ...ernal-release-complete-with-tasks.html.erb | 6 ++-- .../internal-release-complete.html.erb | 4 +-- ...ternal-release-ready-merge-failed.html.erb | 14 +++++----- ...internal-release-ready-tag-failed.html.erb | 10 +++---- .../templates/internal-release-ready.html.erb | 12 ++++---- .../public-release-complete.html.erb | 4 +-- .../public-release-tag-failed.html.erb | 10 +++---- ...lease-tagged-delete-branch-failed.html.erb | 14 +++++----- .../templates/public-release-tagged.html.erb | 12 ++++---- ...lidate-check-for-updates-internal.html.erb | 8 +++--- ...validate-check-for-updates-public.html.erb | 8 +++--- .../templates/appcast-failed-hotfix.yml.erb | 12 ++++---- .../templates/appcast-failed-internal.yml.erb | 12 ++++---- .../templates/appcast-failed-public.yml.erb | 12 ++++---- .../templates/delete-branch-failed.yml.erb | 10 +++---- .../internal-release-tag-failed.yml.erb | 28 +++++++++---------- .../templates/merge-failed.yml.erb | 20 ++++++------- .../public-release-tag-failed.yml.erb | 20 ++++++------- .../templates/run-publish-dmg-release.yml.erb | 10 +++---- .../update-asana-for-public-release.yml.erb | 4 +-- ...alidate-check-for-updates-internal.yml.erb | 18 ++++++------ .../validate-check-for-updates-public.yml.erb | 18 ++++++------ .../helper/asana_helper.rb | 1 + .../helper/ddg_apple_automation_helper.rb | 11 ++++++++ spec/asana_create_action_item_action_spec.rb | 7 ++--- spec/ddg_apple_automation_helper_spec.rb | 20 +++++++++++++ 34 files changed, 189 insertions(+), 167 deletions(-) diff --git a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_add_comment_action.rb b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_add_comment_action.rb index 3ae5d84..37b6879 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_add_comment_action.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_add_comment_action.rb @@ -39,11 +39,7 @@ def self.run(params) def self.process_template(template_name, args) template_file = Helper::DdgAppleAutomationHelper.path_for_asset_file("asana_add_comment/templates/#{template_name}.html.erb") - template_content = Helper::DdgAppleAutomationHelper.load_file(template_file) - return unless template_content - - erb_template = ERB.new(template_content) - erb_template.result(binding) + Helper::DdgAppleAutomationHelper.process_erb_template(template_file, args) end def self.description diff --git a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_create_action_item_action.rb b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_create_action_item_action.rb index a94f94f..e255a26 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_create_action_item_action.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_create_action_item_action.rb @@ -68,13 +68,8 @@ def self.fetch_assignee_id(task_id:, github_handle:, asana_access_token:, is_sch def self.process_yaml_template(template_name, args) template_file = Helper::DdgAppleAutomationHelper.path_for_asset_file("asana_create_action_item/templates/#{template_name}.yml.erb") - template_content = Helper::DdgAppleAutomationHelper.load_file(template_file) - - erb_template = ERB.new(template_content) - yaml = erb_template.result(binding) - + yaml = Helper::DdgAppleAutomationHelper.process_erb_template(template_file, args) task_data = YAML.safe_load(yaml) - return task_data["name"], task_data["html_notes"] end diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-hotfix.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-hotfix.html.erb index 71780dc..bbfaaab 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-hotfix.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-hotfix.html.erb @@ -1,7 +1,7 @@ -

[ACTION NEEDED] Publishing <%= args['tag'] %> hotfix release to Sparkle failed

- ' />, please proceed with generating appcast2.xml and uploading files to S3 from your - local machine, ' data-asana-dynamic='false'>according to instructions.
+

[ACTION NEEDED] Publishing <%= tag %> hotfix release to Sparkle failed

+ , please proceed with generating appcast2.xml and uploading files to S3 from your + local machine, according to instructions.

- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-internal.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-internal.html.erb index 0159735..088ca41 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-internal.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-internal.html.erb @@ -1,7 +1,7 @@ -

[ACTION NEEDED] Publishing <%= args['tag'] %> internal release to Sparkle failed

- ' />, please proceed with generating appcast2.xml and uploading files to S3 from your - local machine, ' data-asana-dynamic='false'>according to instructions.
+

[ACTION NEEDED] Publishing <%= tag %> internal release to Sparkle failed

+ , please proceed with generating appcast2.xml and uploading files to S3 from your + local machine, according to instructions.

- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-public.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-public.html.erb index b442285..e963d1d 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-public.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/appcast-failed-public.html.erb @@ -1,7 +1,7 @@ -

[ACTION NEEDED] Publishing <%= args['tag'] %> release to Sparkle failed

- ' />, please proceed with generating appcast2.xml and uploading files to S3 from your - local machine, ' data-asana-dynamic='false'>according to instructions.
+

[ACTION NEEDED] Publishing <%= tag %> release to Sparkle failed

+ , please proceed with generating appcast2.xml and uploading files to S3 from your + local machine, according to instructions.

- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/debug-symbols-uploaded.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/debug-symbols-uploaded.html.erb index 0327571..8df6953 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/debug-symbols-uploaded.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/debug-symbols-uploaded.html.erb @@ -1,5 +1,5 @@ - πŸ› Debug symbols archive for <%= args['tag'] %> build is uploaded to <%= args['dsym_s3_path'] %>.
+ πŸ› Debug symbols archive for <%= tag %> build is uploaded to <%= dsym_s3_path %>.

- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/dmg-uploaded.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/dmg-uploaded.html.erb index 31ccd64..af14f18 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/dmg-uploaded.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/dmg-uploaded.html.erb @@ -1,5 +1,5 @@ - πŸ“₯ DMG for <%= args['tag'] %> is available from '><%= args['dmg_url'] %>.
+ πŸ“₯ DMG for <%= tag %> is available from <%= dmg_url %>.

- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/hotfix-branch-ready.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/hotfix-branch-ready.html.erb index 574b55c..e8d5a0f 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/hotfix-branch-ready.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/hotfix-branch-ready.html.erb @@ -1,9 +1,9 @@ -

Hotfix branch <%= args['branch'] %> ready βš™οΈ

+

Hotfix branch <%= branch %> ready βš™οΈ


- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-complete-with-tasks.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-complete-with-tasks.html.erb index 8c8e727..d03e051 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-complete-with-tasks.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-complete-with-tasks.html.erb @@ -1,8 +1,8 @@ - Build <%= args['tag'] %> is now available for internal testing through Sparkle and TestFlight.
+ Build <%= tag %> is now available for internal testing through Sparkle and TestFlight.

Added in this release: - <%= args['tasks_since_last_internal_release'] %>
+ <%= tasks_since_last_internal_release %>

- '>πŸ“₯ DMG download link + πŸ“₯ DMG download link \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-complete.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-complete.html.erb index 38f2cdc..9055d2a 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-complete.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-complete.html.erb @@ -1,5 +1,5 @@ - Build <%= args['tag'] %> is now available for internal testing through Sparkle and TestFlight.
+ Build <%= tag %> is now available for internal testing through Sparkle and TestFlight.

- '>πŸ“₯ DMG download link + πŸ“₯ DMG download link \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready-merge-failed.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready-merge-failed.html.erb index d693662..52de680 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready-merge-failed.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready-merge-failed.html.erb @@ -1,16 +1,16 @@ -

[ACTION NEEDED] Internal release build <%= args['tag'] %> ready

+

[ACTION NEEDED] Internal release build <%= tag %> ready


- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready-tag-failed.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready-tag-failed.html.erb index 12a335d..4ebf597 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready-tag-failed.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready-tag-failed.html.erb @@ -1,13 +1,13 @@ -

[ACTION NEEDED] Internal release build <%= args['tag'] %> ready

+

[ACTION NEEDED] Internal release build <%= tag %> ready

- ' />, please proceed with manual tagging and merging ' + , please proceed with manual tagging and merging according to instructions.

- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready.html.erb index f821b45..3dc4489 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/internal-release-ready.html.erb @@ -1,16 +1,16 @@ -

Internal release build <%= args['tag'] %> ready βœ…

+

Internal release build <%= tag %> ready βœ…


- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-complete.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-complete.html.erb index a235428..ec67e7e 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-complete.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-complete.html.erb @@ -1,5 +1,5 @@ - Build <%= args['tag'] %> is now available publicly through Sparkle and TestFlight.
+ Build <%= tag %> is now available publicly through Sparkle and TestFlight.

- '>πŸ“₯ DMG download link + πŸ“₯ DMG download link \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tag-failed.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tag-failed.html.erb index 81d7fb6..621c4cc 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tag-failed.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tag-failed.html.erb @@ -1,13 +1,13 @@ -

[ACTION NEEDED] Failed to publish <%= args['tag'] %> release – tagging failed

+

[ACTION NEEDED] Failed to publish <%= tag %> release – tagging failed


- ' />, please proceed with the release ' + , please proceed with the release according to instructions.

- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tagged-delete-branch-failed.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tagged-delete-branch-failed.html.erb index 6916e35..9704b8d 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tagged-delete-branch-failed.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tagged-delete-branch-failed.html.erb @@ -1,15 +1,15 @@ -

[ACTION NEEDED] Public release <%= args['tag'] %> tagged

+

[ACTION NEEDED] Public release <%= tag %> tagged


- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tagged.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tagged.html.erb index 493a697..a832d22 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tagged.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/public-release-tagged.html.erb @@ -1,12 +1,12 @@ -

Public release <%= args['tag'] %> has been tagged βœ…

+

Public release <%= tag %> has been tagged βœ…


- πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/validate-check-for-updates-internal.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/validate-check-for-updates-internal.html.erb index 1d7d2e3..c7526e0 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/validate-check-for-updates-internal.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/validate-check-for-updates-internal.html.erb @@ -1,10 +1,10 @@ -

Build <%= args['tag'] %> is available for internal testing through Sparkle πŸš€

+

Build <%= tag %> is available for internal testing through Sparkle πŸš€


- πŸ”— Workflow URL:
'><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/validate-check-for-updates-public.html.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/validate-check-for-updates-public.html.erb index 8999969..477c714 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/validate-check-for-updates-public.html.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_add_comment/templates/validate-check-for-updates-public.html.erb @@ -1,11 +1,11 @@ -

Build <%= args['tag'] %> is available publicly through Sparkle πŸš€

+

Build <%= tag %> is available publicly through Sparkle πŸš€


- πŸ”— Workflow URL:
'><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-hotfix.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-hotfix.yml.erb index 7815492..359bcbc 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-hotfix.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-hotfix.yml.erb @@ -1,7 +1,7 @@ -name: Generate appcast2.xml for <%= args['tag'] %> hotfix release and upload assets to S3 +name: Generate appcast2.xml for <%= tag %> hotfix release and upload assets to S3 html_notes: | - Publishing <%= args['tag'] %> hotfix release failed in CI. Please follow the steps to generate the appcast file and upload files to S3 from your local machine.
+ 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.
  1. Create a new file called release-notes.txt on your disk.
      @@ -9,7 +9,7 @@ html_notes: |
  2. Run appcastManager:
      -
    • ./scripts/appcast_manager/appcastManager.swift --release-hotfix-to-public-channel --dmg ~/Downloads/<%= args['dmg_name'] %> --release-notes release-notes.txt
    • +
    • ./scripts/appcast_manager/appcastManager.swift --release-hotfix-to-public-channel --dmg ~/Downloads/<%= dmg_name %> --release-notes release-notes.txt
  3. 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 not be present:
      @@ -17,7 +17,7 @@ html_notes: |
  4. Run upload_to_s3.sh script:
      -
    • ./scripts/upload_to_s3/upload_to_s3.sh --run --overwrite-duckduckgo-dmg <%= args['version'] %>
    • +
    • ./scripts/upload_to_s3/upload_to_s3.sh --run --overwrite-duckduckgo-dmg <%= version %>
When done, please verify that "Check for Updates" works correctly: @@ -25,9 +25,9 @@ html_notes: |
  • Launch a debug version of the app with an old version number.
  • Make sure you're not identified as an internal user in the app.
  • Go to Main Menu β†’ DuckDuckGo β†’ Check for Updates...
  • -
  • Verify that you're being offered to update to <%= args['tag'] %>.
  • +
  • Verify that you're being offered to update to <%= tag %>.
  • Verify that the update works.

  • - πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-internal.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-internal.yml.erb index 8f44717..ca6370b 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-internal.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-internal.yml.erb @@ -1,16 +1,16 @@ -name: Generate appcast2.xml for <%= args['tag'] %> internal release and upload assets to S3 +name: Generate appcast2.xml for <%= tag %> internal release and upload assets to S3 html_notes: | - Publishing <%= args['tag'] %> internal release failed in CI. Please follow the steps to generate the appcast file and upload files to S3 from your local machine.
    + Publishing <%= tag %> internal release failed in CI. Please follow the steps to generate the appcast file and upload files to S3 from your local machine.
      -
    1. Download '>the DMG for <%= args['tag'] %> release.
    2. +
    3. Download the DMG for <%= tag %> release.
    4. Create a new file called release-notes.txt on your disk.
      • Add each release note as a separate line and don't add bullet points (β€’) – the script will add them automatically.
    5. Run appcastManager:
        -
      • ./scripts/appcast_manager/appcastManager.swift --release-to-internal-channel --dmg ~/Downloads/<%= args['dmg_name'] %> --release-notes release-notes.txt
      • +
      • ./scripts/appcast_manager/appcastManager.swift --release-to-internal-channel --dmg ~/Downloads/<%= dmg_name %> --release-notes release-notes.txt
    6. Verify that the new build is in the appcast file with the following internal channel tag:
        @@ -26,9 +26,9 @@ html_notes: |
      • Launch a debug version of the app with an old version number.
      • Identify as an internal user in the app.
      • Go to Main Menu β†’ DuckDuckGo β†’ Check for Updates...
      • -
      • Verify that you're being offered to update to <%= args['tag'] %>.
      • +
      • Verify that you're being offered to update to <%= tag %>.
      • Verify that the update works.

    - πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. \ No newline at end of file diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-public.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-public.yml.erb index a8055d7..39f8d65 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-public.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/appcast-failed-public.yml.erb @@ -1,7 +1,7 @@ -name: Generate appcast2.xml for <%= args['tag'] %> public release and upload assets to S3 +name: Generate appcast2.xml for <%= tag %> public release and upload assets to S3 html_notes: | - Publishing <%= args['tag'] %> release failed in CI. Please follow the steps to generate the appcast file and upload files to S3 from your local machine.
    + Publishing <%= tag %> release failed in CI. Please follow the steps to generate the appcast file and upload files to S3 from your local machine.
    1. Create a new file called release-notes.txt on your disk.
        @@ -9,7 +9,7 @@ html_notes: |
    2. Run appcastManager:
        -
      • ./scripts/appcast_manager/appcastManager.swift --release-to-public-channel --version <%= args['version'] %> --release-notes release-notes.txt
      • +
      • ./scripts/appcast_manager/appcastManager.swift --release-to-public-channel --version <%= version %> --release-notes release-notes.txt
    3. Verify that the new build is in the appcast file with the latest release notes, the phased rollout tag (below) and no internal channel tag:
        @@ -17,7 +17,7 @@ html_notes: |
    4. Run upload_to_s3.sh script:
        -
      • ./scripts/upload_to_s3/upload_to_s3.sh --run --overwrite-duckduckgo-dmg <%= args['version'] %>
      • +
      • ./scripts/upload_to_s3/upload_to_s3.sh --run --overwrite-duckduckgo-dmg <%= version %>
    When done, please verify that "Check for Updates" works correctly: @@ -25,8 +25,8 @@ html_notes: |
  • Launch a debug version of the app with an old version number.
  • Make sure you're not identified as an internal user in the app.
  • Go to Main Menu β†’ DuckDuckGo β†’ Check for Updates...
  • -
  • Verify that you're being offered to update to <%= args['tag'] %>.
  • +
  • Verify that you're being offered to update to <%= tag %>.
  • Verify that the update works.

  • - πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/delete-branch-failed.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/delete-branch-failed.yml.erb index a4ff53c..ba366b3 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/delete-branch-failed.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/delete-branch-failed.yml.erb @@ -1,12 +1,12 @@ -name: Delete <%= args['branch'] %> branch +name: Delete <%= branch %> branch html_notes: | - The <%= args['tag'] %> public release has been successfully tagged and published in GitHub releases, - but deleting <%= args['branch'] %> branch failed. Please delete it manually: + The <%= tag %> public release has been successfully tagged and published in GitHub releases, + but deleting <%= branch %> branch failed. Please delete it manually: Complete this task when ready, or if the release branch has already been deleted.

    - πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/internal-release-tag-failed.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/internal-release-tag-failed.yml.erb index ff0e121..6650220 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/internal-release-tag-failed.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/internal-release-tag-failed.yml.erb @@ -1,19 +1,19 @@ -name: Tag <%= args['branch'] %> branch and create GitHub release +name: Tag <%= branch %> branch and create GitHub release html_notes: | - Failed to tag the release with <%= args['tag'] %> tag.
    - Please follow instructions below to tag the branch, make GitHub release and merge release branch to <%= args['base_branch'] %> manually.
    + Failed to tag the release with <%= tag %> tag.
    + Please follow instructions below to tag the branch, make GitHub release and merge release branch to <%= base_branch %> manually.

    Issue the following git commands to tag the release and merge the branch: -
  • git push origin <%= args['base_branch'] %> push merged branch
  • +
  • git push origin <%= base_branch %> push merged branch

  • To create GitHub release:
    Complete this task when ready and proceed with testing the build. If you're bumping an internal release, you should get another task asking you to publish the release in Sparkle. - Look for other tasks in
    '/> task and handle them as needed.
    + Look for other tasks in
    task and handle them as needed.

    - πŸ”— Workflow URL:
    '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/merge-failed.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/merge-failed.yml.erb index ea72382..62cc402 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/merge-failed.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/merge-failed.yml.erb @@ -1,17 +1,17 @@ -name: Merge <%= args['branch'] %> to <%= args['base_branch'] %> +name: Merge <%= branch %> to <%= base_branch %> html_notes: | - The <%= args['tag'] %> release has been successfully tagged and published in GitHub releases, - but merging to <%= args['base_branch'] %> failed. Please resolve conflicts and merge <%= args['branch'] %> to <%= args['base_branch'] %> manually.
    + The <%= tag %> release has been successfully tagged and published in GitHub releases, + but merging to <%= base_branch %> failed. Please resolve conflicts and merge <%= branch %> to <%= base_branch %> manually.

    Issue the following git commands: -
  • git push origin <%= args['base_branch'] %> push merged branch
  • +
  • git push origin <%= base_branch %> push merged branch
  • Complete this task when ready and proceed with testing the build.

    - πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/public-release-tag-failed.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/public-release-tag-failed.yml.erb index 84dc98d..bb877f5 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/public-release-tag-failed.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/public-release-tag-failed.yml.erb @@ -1,7 +1,7 @@ -name: Tag <%= args['branch'] %> branch, delete it, and create GitHub release +name: Tag <%= branch %> branch, delete it, and create GitHub release html_notes: | - Failed to tag the release with <%= args['tag'] %> tag.
    + Failed to tag the release with <%= tag %> tag.
    Please follow instructions below to tag the branch, make GitHub release and delete the release branch manually.
    Complete this task when ready and proceed with testing the build. If GitHub Actions is unavailable, you'll find manual instructions in the Run Publish DMG Release GitHub Actions workflow subtask of Make Internal Release task.

    - πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/update-asana-for-public-release.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/update-asana-for-public-release.yml.erb index 6e15e62..702004d 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/update-asana-for-public-release.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/update-asana-for-public-release.yml.erb @@ -3,7 +3,7 @@ html_notes: | Automation failed to update Asana for the public release. Please follow the steps below.
      -
    1. Open '/> and select the List view
    2. +
    3. Open and select the List view
    4. Scroll to the "Validation" section.
    5. Select all the tasks in that section.
    6. Drag and drop all the selected tasks to the "Done" section
    7. @@ -11,5 +11,5 @@ html_notes: |

    Complete this task when ready.

    - πŸ”— Workflow URL:
    '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/validate-check-for-updates-internal.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/validate-check-for-updates-internal.yml.erb index c256a0c..5384f21 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/validate-check-for-updates-internal.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/validate-check-for-updates-internal.yml.erb @@ -1,37 +1,37 @@ -name: Validate that 'Check For Updates' upgrades to <%= args['tag'] %> for internal users +name: Validate that 'Check For Updates' upgrades to <%= tag %> for internal users html_notes: | -

    Build <%= args['tag'] %> has been released internally via Sparkle πŸŽ‰

    +

    Build <%= tag %> has been released internally via Sparkle πŸŽ‰

    Please verify that "Check for Updates" works correctly:
    1. Launch a debug version of the app with an old version number.
    2. Identify as an internal user in the app.
    3. Go to Main Menu β†’ DuckDuckGo β†’ Check for Updates...
    4. -
    5. Verify that you're being offered to update to <%= args['tag'] %>.
    6. +
    7. Verify that you're being offered to update to <%= tag %>.
    8. Verify that the update works.

    🚨In case "Check for Updates" is broken

    You can restore previous version of the appcast2.xml:
      -
    1. Download the <%= args['old_appcast_name'] %> file attached to this task.
    2. +
    3. Download the <%= old_appcast_name %> file attached to this task.
    4. Log in to AWS session:
      • aws --profile ddg-macos sso login
    5. Overwrite appcast2.xml with the old version:
        -
      • aws --profile ddg-macos s3 cp <%= args['old_appcast_name'] %> s3://<%= args['release_bucket_name'] %>/<%= args['release_bucket_prefix'] %>/appcast2.xml --acl public-read
      • +
      • aws --profile ddg-macos s3 cp <%= old_appcast_name %> s3://<%= release_bucket_name %>/<%= release_bucket_prefix %>/appcast2.xml --acl public-read


    Summary of automated changes

    Changes to appcast2.xml

    - See the attached <%= args['appcast_patch_name'] %> file. + See the attached <%= appcast_patch_name %> file.

    Release notes

    - See the attached <%= args['release_notes_file'] %> file for release notes extracted automatically from ' data-asana-dynamic='false'>the release task description. + See the attached <%= release_notes_file %> file for release notes extracted automatically from the release task description.

    List of files uploaded to S3

      - <%= args['files_uploaded'] %> + <%= files_uploaded %>

    - πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. diff --git a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/validate-check-for-updates-public.yml.erb b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/validate-check-for-updates-public.yml.erb index 6f93b13..0b46c13 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/validate-check-for-updates-public.yml.erb +++ b/lib/fastlane/plugin/ddg_apple_automation/assets/asana_create_action_item/templates/validate-check-for-updates-public.yml.erb @@ -1,37 +1,37 @@ -name: Validate that 'Check For Updates' upgrades to <%= args['tag'] %> +name: Validate that 'Check For Updates' upgrades to <%= tag %> html_notes: | -

    Build <%= args['tag'] %> has been released publicly via Sparkle πŸŽ‰

    +

    Build <%= tag %> has been released publicly via Sparkle πŸŽ‰

    Please verify that "Check for Updates" works correctly:
    1. Launch a debug version of the app with an old version number.
    2. Make sure you're not identified as an internal user in the app.
    3. Go to Main Menu β†’ DuckDuckGo β†’ Check for Updates...
    4. -
    5. Verify that you're being offered to update to <%= args['tag'] %>.
    6. +
    7. Verify that you're being offered to update to <%= tag %>.
    8. Verify that the update works.

    🚨In case "Check for Updates" is broken

    You can restore previous version of the appcast2.xml:
      -
    1. Download the <%= args['old_appcast_name'] %> file attached to this task.
    2. +
    3. Download the <%= old_appcast_name %> file attached to this task.
    4. Log in to AWS session:
      • aws --profile ddg-macos sso login
    5. Overwrite appcast2.xml with the old version:
        -
      • aws --profile ddg-macos s3 cp <%= args['old_appcast_name'] %> s3://<%= args['release_bucket_name'] %>/<%= args['release_bucket_prefix'] %>/appcast2.xml --acl public-read
      • +
      • aws --profile ddg-macos s3 cp <%= old_appcast_name %> s3://<%= release_bucket_name %>/<%= release_bucket_prefix %>/appcast2.xml --acl public-read


    Summary of automated changes

    Changes to appcast2.xml

    - See the attached <%= args['appcast_patch_name'] %> file. + See the attached <%= appcast_patch_name %> file.

    Release notes

    - See the attached <%= args['release_notes_file'] %> file for release notes extracted automatically from ' data-asana-dynamic='false'>the release task description. + See the attached <%= release_notes_file %> file for release notes extracted automatically from the release task description.

    List of files uploaded to S3

      - <%= args['files_uploaded'] %> + <%= files_uploaded %>

    - πŸ”— Workflow URL: '><%= args['workflow_url'] %>. + πŸ”— Workflow URL: <%= workflow_url %>. 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 329393f..f97227a 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb @@ -1,5 +1,6 @@ require "fastlane_core/ui/ui" require "asana" +require_relative "ddg_apple_automation_helper" require_relative "github_actions_helper" module Fastlane diff --git a/lib/fastlane/plugin/ddg_apple_automation/helper/ddg_apple_automation_helper.rb b/lib/fastlane/plugin/ddg_apple_automation/helper/ddg_apple_automation_helper.rb index 5e09a2c..0b0e364 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/helper/ddg_apple_automation_helper.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/helper/ddg_apple_automation_helper.rb @@ -99,6 +99,17 @@ def self.upload_file_to_asana_task(task_id, file_path, asana_access_token) end end + def self.process_erb_template(erb_file_path, args) + template_content = load_file(erb_file_path) + unless template_content + UI.user_error!("Template file not found: #{erb_file_path}") + return + end + + erb_template = ERB.new(template_content) + erb_template.result_with_hash(args) + end + def self.path_for_asset_file(file) File.expand_path("../assets/#{file}", __dir__) end diff --git a/spec/asana_create_action_item_action_spec.rb b/spec/asana_create_action_item_action_spec.rb index 5343c56..11d9b68 100644 --- a/spec/asana_create_action_item_action_spec.rb +++ b/spec/asana_create_action_item_action_spec.rb @@ -7,8 +7,6 @@ let(:task_name) { "example name" } describe "#run" do - let(:parsed_yaml_content) { { 'name' => 'test task', 'html_notes' => '

    Some notes

    ' } } - before do @asana_client_tasks = double asana_client = double("Asana::Client") @@ -45,9 +43,10 @@ end it "correctly builds payload if template_name input is given" do - allow(File).to receive(:read) + parsed_yaml_content = { 'name' => 'test task', 'html_notes' => '

    Some notes

    ' } + allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:path_for_asset_file) + allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:process_erb_template) allow(YAML).to receive(:safe_load).and_return(parsed_yaml_content) - allow(ERB).to receive(:new).and_return(double('erb', result: "yaml")) test_action(task_url: task_url, task_name: task_name, template_name: "template_name", is_scheduled_release: true) expect(@asana_client_tasks).to have_received(:create_subtask_for_task).with( task_gid: automation_subtask_id, diff --git a/spec/ddg_apple_automation_helper_spec.rb b/spec/ddg_apple_automation_helper_spec.rb index 24078d8..7fcdc78 100644 --- a/spec/ddg_apple_automation_helper_spec.rb +++ b/spec/ddg_apple_automation_helper_spec.rb @@ -1,4 +1,24 @@ describe Fastlane::Helper::DdgAppleAutomationHelper do + describe "#process_erb_template" do + it "processes ERB template" do + template = "

    Hello, <%= x %>!

    " + allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:load_file).and_return(template) + expect(process_erb_template("template.erb", { 'x' => "World" })).to eq("

    Hello, World!

    ") + end + + it "shows error if provided template file does not exist" do + allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:load_file).and_return(nil) + allow(Fastlane::UI).to receive(:user_error!) + expect(ERB).not_to receive(:new) + process_erb_template("file.erb", {}) + expect(Fastlane::UI).to have_received(:user_error!).with("Template file not found: file.erb") + end + + def process_erb_template(erb_file_path, args) + Fastlane::Helper::DdgAppleAutomationHelper.process_erb_template(erb_file_path, args) + end + end + describe "#load_file" do it "shows error if provided file does not exist" do allow(Fastlane::UI).to receive(:user_error!)