Skip to content

Commit

Permalink
Fix Rubocop offenses after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
iangmaia committed Oct 26, 2023
1 parent 93d27d7 commit ddad865
Showing 1 changed file with 47 additions and 59 deletions.
106 changes: 47 additions & 59 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ENV['PROJECT_NAME'] = 'pocket-casts-android'
ENV['PROJECT_ROOT_FOLDER'] = './'
ENV['FL_RELEASE_TOOLKIT_DEFAULT_BRANCH'] = 'main'
DEFAULT_BRANCH = 'main'
ENV['SUPPLY_UPLOAD_MAX_RETRIES']='5'
ENV['SUPPLY_UPLOAD_MAX_RETRIES'] = '5'
GH_REPOSITORY = 'automattic/pocket-casts-android'
APPS_APP = 'app'
APPS_AUTOMOTIVE = 'automotive'
Expand All @@ -81,7 +81,7 @@ before_all do |_lane|
end

platform :android do
lane :code_freeze do | options |
lane :code_freeze do |options|
ensure_git_status_clean
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
ensure_git_branch(branch: DEFAULT_BRANCH)
Expand Down Expand Up @@ -133,22 +133,20 @@ platform :android do
setfrozentag(repository: GH_REPOSITORY, milestone: new_version)
end

lane :complete_code_freeze do | options |
lane :complete_code_freeze do |options|
ensure_git_branch(branch: '^release/') # Match branch names that begin with `release/`
ensure_git_status_clean

new_version = current_release_version

UI.important("Completing code freeze for: #{new_version}")

unless options[:skip_confirm]
UI.user_error!('Aborted by user request') unless UI.confirm('Do you want to continue?')
end
UI.user_error!('Aborted by user request') if !options[:skip_confirm] && !UI.confirm('Do you want to continue?')

trigger_release_build(branch_to_build: "release/#{new_version}")
end

lane :new_beta_release do | options |
lane :new_beta_release do |options|
ensure_git_status_clean
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)

Expand All @@ -173,9 +171,7 @@ platform :android do

UI.important(message)

unless options[:skip_confirm]
UI.user_error!('Aborted by user request') unless UI.confirm('Do you want to continue?')
end
UI.user_error!('Aborted by user request') if !options[:skip_confirm] && !UI.confirm('Do you want to continue?')

# Bump the release version and build code
UI.message 'Bumping beta version and build code...'
Expand Down Expand Up @@ -227,9 +223,7 @@ platform :android do

UI.important(message)

unless options[:skip_confirm]
UI.user_error!('Aborted by user request') unless UI.confirm('Do you want to continue?')
end
UI.user_error!('Aborted by user request') if !options[:skip_confirm] && !UI.confirm('Do you want to continue?')

# Check tags
UI.user_error!("The version `#{new_version}` tag already exists!") if git_tag_exists(tag: new_version)
Expand Down Expand Up @@ -257,9 +251,7 @@ platform :android do

UI.important("Triggering hotfix build for version: #{current_release_version}")

unless options[:skip_confirm]
UI.user_error!('Aborted by user request') unless UI.confirm('Do you want to continue?')
end
UI.user_error!('Aborted by user request') if !options[:skip_confirm] && !UI.confirm('Do you want to continue?')

trigger_release_build(branch_to_build: "release/#{current_release_version}")
end
Expand All @@ -283,20 +275,18 @@ platform :android do
# @option [Boolean] skip_prechecks (default: false) If true, skips android_build_preflight
# @option [Boolean] create_gh_release (default: false) If true, creates a draft GitHub release
#
desc "Builds and uploads a new build to Google Play (without releasing it)"
lane :build_and_upload_to_play_store do | options |
desc 'Builds and uploads a new build to Google Play (without releasing it)'
lane :build_and_upload_to_play_store do |options|
version = current_version_name
build_code = current_build_code
is_beta = is_beta_version(version)
unless (options[:skip_prechecks])
unless options[:skip_prechecks]
# Match branch names that begin with `release/`
ensure_git_branch(branch: '^release/') unless is_ci

UI.important("Building version #{current_version_name} (#{current_build_code}) for upload to Google Play Console")

unless options[:skip_confirm]
UI.user_error!('Aborted by user request') unless UI.confirm('Do you want to continue?')
end
UI.user_error!('Aborted by user request') if !options[:skip_confirm] && !UI.confirm('Do you want to continue?')

# Check local repo status
ensure_git_status_clean unless is_ci
Expand All @@ -307,48 +297,46 @@ platform :android do
release_assets = []

APPS.each do |app|
build_bundle(app: app, version: version, build_code: build_code)

aab_artifact_path = aab_artifact_path(app, version)
UI.error("Unable to find a build artifact at #{aab_artifact_path}") unless File.exist? aab_artifact_path

track = if (app == APPS_AUTOMOTIVE)
is_beta ? PLAY_STORE_TRACK_AUTOMOTIVE_BETA : PLAY_STORE_TRACK_AUTOMOTIVE_PRODUCTION
elsif (app == APPS_WEAR)
is_beta ? PLAY_STORE_TRACK_WEAR_BETA : PLAY_STORE_TRACK_WEAR_PRODUCTION
else
is_beta ? PLAY_STORE_TRACK_BETA : PLAY_STORE_TRACK_PRODUCTION
end

upload_to_play_store(
package_name: APP_PACKAGE_NAME,
aab: aab_artifact_path,
track: track,
release_status: 'draft',
skip_upload_apk: true,
skip_upload_metadata: true,
skip_upload_changelogs: true,
skip_upload_images: true,
skip_upload_screenshots: true,
json_key: UPLOAD_TO_PLAY_STORE_JSON_KEY
)

release_assets << aab_artifact_path
build_bundle(app:, version:, build_code:)

aab_artifact_path = aab_artifact_path(app, version)
UI.error("Unable to find a build artifact at #{aab_artifact_path}") unless File.exist? aab_artifact_path

track = if app == APPS_AUTOMOTIVE
is_beta ? PLAY_STORE_TRACK_AUTOMOTIVE_BETA : PLAY_STORE_TRACK_AUTOMOTIVE_PRODUCTION
elsif app == APPS_WEAR
is_beta ? PLAY_STORE_TRACK_WEAR_BETA : PLAY_STORE_TRACK_WEAR_PRODUCTION
else
is_beta ? PLAY_STORE_TRACK_BETA : PLAY_STORE_TRACK_PRODUCTION
end

upload_to_play_store(
package_name: APP_PACKAGE_NAME,
aab: aab_artifact_path,
track:,
release_status: 'draft',
skip_upload_apk: true,
skip_upload_metadata: true,
skip_upload_changelogs: true,
skip_upload_images: true,
skip_upload_screenshots: true,
json_key: UPLOAD_TO_PLAY_STORE_JSON_KEY
)

release_assets << aab_artifact_path
end

create_gh_release(version:, prerelease: is_beta, release_assets: release_assets.compact) if options[:create_gh_release]
end

lane :finalize_release do | options |
lane :finalize_release do |options|
UI.user_error!('Please use `finalize_hotfix_release` lane for hotfixes') if android_current_branch_is_hotfix
ensure_git_branch(branch: '^release/') # Match branch names that begin with `release/`
ensure_git_status_clean

UI.important("Finalizing release: #{current_release_version}")

unless options[:skip_confirm]
UI.user_error!('Aborted by user request') unless UI.confirm('Do you want to continue?')
end
UI.user_error!('Aborted by user request') if !options[:skip_confirm] && !UI.confirm('Do you want to continue?')

configure_apply(force: is_ci)

Expand All @@ -372,10 +360,10 @@ platform :android do
version = current_release_version

# Wrap up
removebranchprotection(repository:GH_REPOSITORY, branch: "release/#{version}")
setfrozentag(repository:GH_REPOSITORY, milestone: version, freeze: false)
create_new_milestone(repository:GH_REPOSITORY, need_appstore_submission: true)
close_milestone(repository:GH_REPOSITORY, milestone: version)
removebranchprotection(repository: GH_REPOSITORY, branch: "release/#{version}")
setfrozentag(repository: GH_REPOSITORY, milestone: version, freeze: false)
create_new_milestone(repository: GH_REPOSITORY, need_appstore_submission: true)
close_milestone(repository: GH_REPOSITORY, milestone: version)

push_to_git_remote(tags: false)
trigger_release_build(branch_to_build: "release/#{version}")
Expand Down Expand Up @@ -450,7 +438,7 @@ platform :android do

create_release(
repository: GH_REPOSITORY,
version: version,
version:,
release_notes_file_path: nil,
prerelease:,
release_assets: release_assets.join(',')
Expand All @@ -476,7 +464,7 @@ platform :android do
end

def is_beta_version(version)
version.include? "-rc-"
version.include? '-rc-'
end

def override_default_release_branch(version)
Expand Down

0 comments on commit ddad865

Please sign in to comment.