Skip to content

Commit

Permalink
Add repo_name to git_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Oct 2, 2024
1 parent 1d48310 commit 918b608
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,9 @@
module Fastlane
module Actions
class StartNewReleaseAction < Action
@constants = {}

def self.setup_constants(platform)
case platform
when "ios"
@constants = {
repo_name: "duckduckgo/ios",
release_tag_prefix: "ios-app-release-"
}
when "macos"
@constants = {
repo_name: "duckduckgo/macos-browser",
release_tag_prefix: "macos-app-release-"
}
end
end

def self.run(params)
Helper::GitHelper.setup_git_user
params[:platform] ||= Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
setup_constants(params[:platform])

options = params.values
options[:asana_user_id] = Helper::AsanaHelper.get_asana_user_id_for_github_handle(options[:github_handle])
Expand Down
16 changes: 14 additions & 2 deletions lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "httparty"
require "octokit"
require_relative "ddg_apple_automation_helper"
require_relative "git_helper"
require_relative "github_actions_helper"
require_relative "release_task_helper"

Expand Down Expand Up @@ -147,6 +148,17 @@ def self.release_task_name(version, platform, is_hotfix: false)
end
end

def self.release_tag_name(version, platform)
case platform
when "ios"
"ios-app-release-#{version}"
when "macos"
"macos-app-release-#{version}"
else
UI.user_error!("Unsupported platform: #{platform}")
end
end

def self.release_section_id(platform)
case platform
when "ios"
Expand Down Expand Up @@ -205,7 +217,7 @@ def self.create_release_task(platform, version, assignee_id, asana_access_token)
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])
latest_public_release = client.latest_release(Helper::GitHelper.repo_name(params[:platform]))
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")
Expand All @@ -230,7 +242,7 @@ def self.update_asana_tasks_for_release(params)
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]}"
tag_name = release_tag_name(params[:version], params[:platform])
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)}")
Expand Down
11 changes: 11 additions & 0 deletions lib/fastlane/plugin/ddg_apple_automation/helper/git_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ module Fastlane

module Helper
class GitHelper
def self.repo_name(platform)
case platform
when "ios"
"duckduckgo/ios"
when "macos"
"duckduckgo/macos-browser"
else
UI.user_error!("Unsupported platform: #{platform}")
end
end

def self.setup_git_user(name: "Dax the Duck", email: "[email protected]")
Actions.sh("echo \"git config --global user.name '#{name}'\"")
Actions.sh("echo \"git config --global user.email '#{email}'\"")
Expand Down

0 comments on commit 918b608

Please sign in to comment.