Skip to content

Commit

Permalink
Merge branch 'main' into sam/add-ruby-version
Browse files Browse the repository at this point in the history
  • Loading branch information
samsymons committed Jan 28, 2025
2 parents 23ac6f8 + 1f2bd01 commit 69555a7
Show file tree
Hide file tree
Showing 21 changed files with 197 additions and 51 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Test

on:
workflow_dispatch: {}
push:

jobs:
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ gem 'rubocop-require_tools'
# SimpleCov is a code coverage analysis tool for Ruby.
gem 'simplecov'

# Dependencies no longer included in newer Ruby versions
gem 'abbrev'
gem 'logger'
gem 'mutex_m'

gemspec

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def self.run(params)
UI.user_error!("No release task found for version #{latest_marketing_version}") unless release_task_id

release_task_url = Helper::AsanaHelper.asana_task_url(release_task_id)
release_branch = "release/#{latest_marketing_version}"
release_branch = Helper::DdgAppleAutomationHelper.release_branch_name(platform, latest_marketing_version)
UI.success("Found #{latest_marketing_version} release task: #{release_task_url}")

Helper::GitHubActionsHelper.set_output("release_branch", release_branch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def self.setup_constants(platform)
end

def self.run(params)
other_action.ensure_git_branch(branch: "^(:?release|hotfix)/.+$")
platform = params[:platform] || Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
other_action.ensure_git_branch(branch: "^(release|hotfix)/#{platform}/.+$")
Helper::GitHelper.setup_git_user

params[:platform] ||= Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
setup_constants(params[:platform])
setup_constants(platform)

tag_and_release_output = create_tag_and_github_release(params[:is_prerelease], params[:github_token])
Helper::GitHubActionsHelper.set_output("tag", tag_and_release_output[:tag])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<body>
Build <%= tag %> is now available for internal testing through Sparkle and TestFlight.<br>
Build <%= tag %> is now available for internal testing through <% if defined?(dmg_url) && !dmg_url.to_s.strip.empty? %>Sparkle and<% end %> TestFlight.<br>
<br>
Added in this release:
<%= tasks_since_last_internal_release %><br>
<br>
<a href='<%= dmg_url %>'>📥 DMG download link</a>
<% if defined?(dmg_url) && !dmg_url.to_s.strip.empty? %><a href='<%= dmg_url %>'>📥 DMG download link</a><% end %>
</body>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<body>
Build <%= tag %> is now available for internal testing through Sparkle and TestFlight.<br>
<br>
<a href='<%= dmg_url %>'>📥 DMG download link</a>
Build <%= tag %> is now available for internal testing through <% if defined?(dmg_url) && !dmg_url.to_s.strip.empty? %>Sparkle and<% end %> TestFlight.<br>
<% if defined?(dmg_url) && !dmg_url.to_s.strip.empty? %><br><a href='<%= dmg_url %>'>📥 DMG download link</a><% end %>
</body>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<body>
<h2>[ACTION NEEDED] Internal release build <%= tag %> ready</h2>
<ul>
<li>📥 DMG is available from <a href='<%= dmg_url %>'><%= dmg_url %></a>.</li>
<% if defined?(dmg_url) && !dmg_url.to_s.strip.empty? %><li>📥 DMG is available from <a href='<%= dmg_url %>'><%= dmg_url %></a>.</li><% end %>
<li>🏷️ Repository is tagged with <code><%= tag %></code> tag.</li>
<li>🚢 GitHub <a href='<%= release_url %>'><%= tag %> pre-release</a> is created.</li>
<li><b>❗️ Merging <code><%= branch %></code> to <code><%= base_branch %></code> failed.</b>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<body>
<h2>[ACTION NEEDED] Internal release build <%= tag %> ready</h2>
<ul>
<li>📥 DMG is available from <a href='<%= dmg_url %>'><%= dmg_url %></a>.</li>
<% if defined?(dmg_url) && !dmg_url.to_s.strip.empty? %><li>📥 DMG is available from <a href='<%= dmg_url %>'><%= dmg_url %></a>.</li><% end %>
<li><b>❗️ Tagging repository failed.</b></li>
<li><b>⚠️ GitHub release creation was skipped.</b></li>
<li><b>⚠️ Merging <code><%= branch %></code> to <code><%= base_branch %></code> was skipped.</b></li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<body>
<h2>Internal release build <%= tag %> ready ✅</h2>
<ul>
<li>📥 DMG is available from <a href='<%= dmg_url %>'><%= dmg_url %></a>.
<% if defined?(dmg_url) && !dmg_url.to_s.strip.empty? %><li>📥 DMG is available from <a href='<%= dmg_url %>'><%= dmg_url %></a>.
<ul>
<li>If this is a subsequent internal release (started by calling <em>Bump Internal Release</em> workflow), the
DMG will be automatically published to Sparkle in a few minutes. Sit tight.</li>
</ul>
</li>
</li><% end %>
<li>🏷️ Repository is tagged with <code><%= tag %></code> tag.</li>
<li>🚢 GitHub <a href='<%= release_url %>'><%= tag %> pre-release</a> is created.</li>
<li>🔱 <code><%= branch %></code> branch has been successfully merged to <code><%= base_branch %></code>.</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<body>
Build <%= tag %> is now available publicly via App Store.<br>
</body>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<body>
<h2>Public release <%= tag %> has been tagged ✅</h2>
<ul>
<li>📥 DMG is available from <a href='<%= dmg_url %>'><%= dmg_url %></a>.</li>
<% if defined?(dmg_url) && !dmg_url.to_s.strip.empty? %><li>📥 DMG is available from <a href='<%= dmg_url %>'><%= dmg_url %></a>.</li><% end %>
<li>🏷️ Repository is tagged with <code><%= tag %></code> tag.</li>
<li>🚢 GitHub <a href='<%= release_url %>'><%= tag %> release</a> is created.</li>
<li>🔱 <code><%= branch %></code> branch has been deleted.</li>
<li>🚀 The relase will be published to Sparkle in a few minutes (you'll get notified).</li>
<% if defined?(dmg_url) && !dmg_url.to_s.strip.empty? %><li>🚀 The relase will be published to Sparkle in a few minutes (you'll get notified).</li><% end %>
</ul>
<br>
🔗 Workflow URL: <a href='<%= workflow_url %>'><%= workflow_url %></a>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<body>
As the last step of the process, post a message to <a href='https://app.asana.com/0/11984721910118/1204991209236659'>REVIEW / RELEASE</a> Asana project:
<ul>
<li>Set the title to <strong>macOS App Release <%= marketing_version %></strong></li>
<li>Set the title to <strong><%= platform == "ios" ? "iOS App Release" : "macOS App Release" %> <%= marketing_version %></strong></li>
<li>Copy the content below (between separators) and paste as the message body.</li>
</ul>
<hr>
Expand All @@ -14,8 +14,12 @@
<% end %>
</ul>
<strong>Rollout</strong><br>
This is now rolling out to users. New users will receive this release immediately,
<% if platform == "ios" %>This is now rolling out to users. New users will receive this release immediately,
existing users will receive this gradually over the next few days until we reach a 5% threshold.
If there are no problems we will push the release to everyone.
You can force an update now by going to the App Store, finding the Update tab and downloading the latest version.
<% else %>This is now rolling out to users. New users will receive this release immediately,
existing users will receive this gradually over the next few days. You can force an update now
by going to the DuckDuckGo menu in the menu bar and selecting "Check For Updates".
by going to the DuckDuckGo menu in the menu bar and selecting "Check For Updates".<% end %>
<hr>
</body>
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class AsanaHelper # rubocop:disable Metrics/ClassLength
ASANA_TASK_URL_REGEX = %r{https://app.asana.com/[0-9]/[0-9]+/([0-9]+)(:/f)?}
ASANA_WORKSPACE_ID = "137249556945"

IOS_HOTFIX_TASK_TEMPLATE_ID = "1205352950253153"
IOS_RELEASE_TASK_TEMPLATE_ID = "1205355281110338"
IOS_HOTFIX_TASK_TEMPLATE_ID = "1209242676101485"
IOS_RELEASE_TASK_TEMPLATE_ID = "1209175074761732"
MACOS_HOTFIX_TASK_TEMPLATE_ID = "1206724592377782"
MACOS_RELEASE_TASK_TEMPLATE_ID = "1206127427850447"

Expand Down Expand Up @@ -293,7 +293,7 @@ def self.update_asana_tasks_for_public_release(params)

# Construct release announcement task description
UI.message("Preparing release announcement task")
Helper::ReleaseTaskHelper.construct_release_announcement_task_description(params[:version], release_notes, task_ids)
Helper::ReleaseTaskHelper.construct_release_announcement_task_description(params[:version], release_notes, task_ids, params[:platform])
end

def self.fetch_tasks_for_tag(tag_id, asana_access_token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class DdgAppleAutomationHelper
])
}.freeze

def self.release_branch_name(platform, version)
"#{RELEASE_BRANCH}/#{platform}/#{version}"
end

def self.hotfix_branch_name(platform, version)
"#{HOTFIX_BRANCH}/#{platform}/#{version}"
end

def self.code_freeze_prechecks(other_action)
other_action.ensure_git_status_clean
other_action.ensure_git_branch(branch: DEFAULT_BRANCH)
Expand Down Expand Up @@ -131,11 +139,16 @@ def self.extract_version_from_tag(tag)
def self.prepare_release_branch(platform, version, other_action)
code_freeze_prechecks(other_action) unless Helper.is_ci?
new_version = validate_new_version(version)
create_release_branch(new_version)
create_release_branch(platform, new_version)
update_embedded_files(platform, other_action)
update_version_config(new_version, other_action)
if platform == "ios"
# Any time we prepare a release branch for iOS the the build number should be reset to 0
update_version_and_build_number_config(new_version, 0, other_action)
else
update_version_config(new_version, other_action)
end
other_action.push_to_git_remote
release_branch_name = "#{RELEASE_BRANCH}/#{new_version}"
release_branch_name = release_branch_name(platform, new_version)
Helper::GitHubActionsHelper.set_output("release_branch_name", release_branch_name)

return release_branch_name, new_version
Expand All @@ -150,16 +163,20 @@ def self.prepare_hotfix_branch(github_token, platform, other_action, options)
source_version = validate_version_exists(version)
new_version = validate_hotfix_version(source_version)
release_branch_name = create_hotfix_branch(platform, source_version, new_version)
update_version_config(new_version, other_action)
if platform == "ios"
update_version_and_build_number_config(new_version, 0, other_action)
else
update_version_config(new_version, other_action)
end
other_action.push_to_git_remote
increment_build_number(platform, options, other_action)
increment_build_number(platform, options, other_action) if platform == "macos"
Helper::GitHubActionsHelper.set_output("release_branch_name", release_branch_name)

return release_branch_name, new_version
end

def self.create_hotfix_branch(platform, source_version, new_version)
branch_name = "#{HOTFIX_BRANCH}/#{new_version}"
branch_name = hotfix_branch_name(platform, new_version)
UI.message("Creating new hotfix release branch for #{new_version}")

existing_branch = Actions.sh("git", "branch", "--list", branch_name).strip
Expand Down Expand Up @@ -193,9 +210,9 @@ def self.validate_version_exists(version)
existing_tag
end

def self.create_release_branch(version)
def self.create_release_branch(platform, version)
UI.message("Creating new release branch for #{version}")
release_branch = "#{RELEASE_BRANCH}/#{version}"
release_branch = release_branch_name(platform, version)

# Abort if the branch already exists
UI.abort_with_message!("Branch #{release_branch} already exists in this repository. Aborting.") unless Actions.sh(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ def self.construct_release_task_description(release_notes, task_ids)
Helper::AsanaHelper.sanitize_asana_html_notes(html_notes)
end

def self.construct_release_announcement_task_description(version, release_notes, task_ids)
def self.construct_release_announcement_task_description(version, release_notes, task_ids, platform)
template_file = Helper::DdgAppleAutomationHelper.path_for_asset_file("release_task_helper/templates/release_announcement_task_description.html.erb")
html_notes = Helper::DdgAppleAutomationHelper.process_erb_template(template_file, {
marketing_version: version,
release_notes: release_notes,
task_ids: task_ids
task_ids: task_ids,
platform: platform
})
Helper::AsanaHelper.sanitize_asana_html_notes(html_notes)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/ddg_apple_automation/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module DdgAppleAutomation
VERSION = "0.12.1"
VERSION = "1.0.3"
end
end
3 changes: 1 addition & 2 deletions spec/asana_add_comment_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ def test_action(task_id: nil, task_url: nil, comment: nil, template_name: nil, w
expected = <<~EXPECTED
<body>
Build 1.0.0-123 is now available for internal testing through Sparkle and TestFlight.<br>
<br>
<a href='https://cdn.com/bucket/duckduckgo-1.0.0.123.dmg'>📥 DMG download link</a>
<br><a href='https://cdn.com/bucket/duckduckgo-1.0.0.123.dmg'>📥 DMG download link</a>
</body>
EXPECTED

Expand Down
4 changes: 2 additions & 2 deletions spec/asana_find_release_task_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
expect(test_action("ios")).to eq({
release_task_id: "1234567890",
release_task_url: "https://app.asana.com/0/0/1234567890/f",
release_branch: "release/1.0.0"
release_branch: "release/ios/1.0.0"
})

expect(Fastlane::UI).to have_received(:success).with("Found 1.0.0 release task: https://app.asana.com/0/0/1234567890/f")
expect(Fastlane::Helper::GitHubActionsHelper).to have_received(:set_output).with("release_branch", "release/1.0.0")
expect(Fastlane::Helper::GitHubActionsHelper).to have_received(:set_output).with("release_branch", "release/ios/1.0.0")
expect(Fastlane::Helper::GitHubActionsHelper).to have_received(:set_output).with("release_task_id", "1234567890")
expect(Fastlane::Helper::GitHubActionsHelper).to have_received(:set_output).with("release_task_url", "https://app.asana.com/0/0/1234567890/f")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/asana_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def sanitize_asana_html_notes(content)
expect(Fastlane::Helper::AsanaHelper).to receive(:move_tasks_to_section).with(task_ids, params[:target_section_id], params[:asana_access_token])
expect(Fastlane::Helper::AsanaHelper).to receive(:complete_tasks).with(task_ids, params[:asana_access_token])
expect(Fastlane::Helper::AsanaHelper).to receive(:fetch_release_notes).with(params[:release_task_id], params[:asana_access_token])
expect(Fastlane::Helper::ReleaseTaskHelper).to receive(:construct_release_announcement_task_description).with(params[:version], release_notes, task_ids - [params[:release_task_id]])
expect(Fastlane::Helper::ReleaseTaskHelper).to receive(:construct_release_announcement_task_description).with(params[:version], release_notes, task_ids - [params[:release_task_id]], "ios")
Fastlane::Helper::AsanaHelper.update_asana_tasks_for_public_release(params)

expect(Fastlane::UI).to have_received(:message).with("Fetching #{tag_name} Asana tag")
Expand Down
Loading

0 comments on commit 69555a7

Please sign in to comment.