Skip to content

Commit

Permalink
Further Fastlane improvements before CI release automation (#22214)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Dec 14, 2023
2 parents 180169c + 42156ab commit 48de6b7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 36 deletions.
6 changes: 6 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ ENV['PUBLIC_CONFIG_FILE'] = PUBLIC_CONFIG_FILE
INTERNAL_CONFIG_FILE = File.join(PROJECT_ROOT_FOLDER, 'config', 'Version.internal.xcconfig')
ENV['FASTLANE_WWDR_USE_HTTP1_AND_RETRIES'] = 'true'

# Fastlane's `git_branch` action and its relevant helpers use environment variables to modify the output.
# That means if we change the branch as part of an action, it'll return the incorrect branch.
# This environment variable disables that behavior.
# See https://github.com/fastlane/fastlane/pull/21597
ENV['FL_GIT_BRANCH_DONT_USE_ENV_VARS'] = 'true'

# Instanstiate versioning classes
VERSION_CALCULATOR = Fastlane::Wpmreleasetoolkit::Versioning::MarketingVersionCalculator.new
VERSION_FORMATTER = Fastlane::Wpmreleasetoolkit::Versioning::FourPartVersionFormatter.new
Expand Down
68 changes: 32 additions & 36 deletions fastlane/lanes/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,25 @@

release_branch_name = compute_release_branch_name(options:, version: release_version_next)

skip_user_confirmation = options[:skip_confirm]
# The `release_version_next` is used as the `new internal release version` value because the external and internal
# release versions are always the same.
message = <<~MESSAGE
Code Freeze:
• New release branch from #{DEFAULT_BRANCH}: #{release_branch_name}
unless skip_user_confirmation
# The `release_version_next` is used as the `new internal release version` value because the external and internal
# release versions are always the same.
message = <<-MESSAGE
Code Freeze:
• New release branch from #{DEFAULT_BRANCH}: #{release_branch_name}
• Current release version and build code: #{release_version_current} (#{build_code_current}).
• New release version and build code: #{release_version_next} (#{build_code_code_freeze}).
• Current release version and build code: #{release_version_current} (#{build_code_current}).
• New release version and build code: #{release_version_next} (#{build_code_code_freeze}).
• Current internal release version and build code: #{release_version_current_internal} (#{build_code_current_internal})
• New internal release version and build code: #{release_version_next} (#{build_code_code_freeze_internal})
MESSAGE

• Current internal release version and build code: #{release_version_current_internal} (#{build_code_current_internal})
• New internal release version and build code: #{release_version_next} (#{build_code_code_freeze_internal})
MESSAGE
UI.important(message)

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

UI.user_error!('Aborted by user request') unless skip_user_confirmation || UI.confirm('Do you want to continue?')

# Create the release branch
release_branch_name = compute_release_branch_name(options:, version: release_version_next)
UI.message 'Creating release branch...'
Fastlane::Helper::GitHelper.create_branch(release_branch_name, from: DEFAULT_BRANCH)
UI.success "Done! New release branch is: #{git_branch}"
Expand Down Expand Up @@ -101,7 +98,7 @@
)

unless skip_user_confirmation || UI.confirm('Ready to push changes to remote to let the automation configure it on GitHub?')
UI.message('Aborting code freeze as requested.')
UI.message("Terminating as requested. Don't forget to run the remainder of this automation manually.")
next
end

Expand Down Expand Up @@ -137,7 +134,7 @@
generate_strings_file_for_glotpress

unless skip_user_confirmation || UI.confirm('Ready to push changes to remote and trigger the beta build?')
UI.message('Aborting code freeze completion. See you later.')
UI.message("Terminating as requested. Don't forget to run the remainder of this automation manually.")
next
end

Expand All @@ -158,22 +155,21 @@

git_pull

skip_user_confirmation = options[:skip_confirm]
# The `release_version_next` is used as the `new internal release version` value because the external and internal
# release versions are always the same.
message = <<~MESSAGE
• Current build code: #{build_code_current}
• New build code: #{build_code_next}
• Current internal build code: #{build_code_current_internal}
• New internal build code: #{build_code_next_internal}
MESSAGE

unless skip_user_confirmation
# The `release_version_next` is used as the `new internal release version` value because the external and internal
# release versions are always the same.
message = <<-MESSAGE
• Current build code: #{build_code_current}
• New build code: #{build_code_next}
UI.important(message)

• Current internal build code: #{build_code_current_internal}
• New internal build code: #{build_code_next_internal}
MESSAGE
skip_user_confirmation = options[:skip_confirm]

UI.important(message)
UI.user_error!('Aborted by user request') unless UI.confirm('Do you want to continue?')
end
UI.user_error!('Aborted by user request') unless skip_user_confirmation || UI.confirm('Do you want to continue?')

generate_strings_file_for_glotpress
download_localized_strings_and_metadata(options)
Expand All @@ -182,7 +178,7 @@
bump_build_codes

unless skip_user_confirmation || UI.confirm('Ready to push changes to remote and trigger the beta build?')
UI.message('Aborting beta deployment.')
UI.message("Terminating as requested. Don't forget to run the remainder of this automation manually.")
next
end

Expand Down Expand Up @@ -213,7 +209,7 @@
previous_version = VERSION_FORMATTER.release_version(VERSION_CALCULATOR.previous_patch_version(version: parsed_version))

# Check versions
message = <<-MESSAGE
message = <<~MESSAGE
New Hotfix:
• Current release version and build code: #{release_version_current} (#{build_code_current}).
Expand Down Expand Up @@ -308,7 +304,7 @@

# Wrap up
version = release_version_current
removebranchprotection(repository: GITHUB_REPO, branch: release_branch_name)
remove_branch_protection(repository: GITHUB_REPO, branch: release_branch_name)
setfrozentag(repository: GITHUB_REPO, milestone: version, freeze: false)
create_new_milestone(repository: GITHUB_REPO)
close_milestone(repository: GITHUB_REPO, milestone: version)
Expand All @@ -320,7 +316,7 @@
push_to_git_remote(tags: false)
trigger_release_build
else
UI.message('Aborting release finalization. See you later.')
UI.message("Terminating as requested. Don't forget to run the remainder of this automation manually.")
next
end
end
Expand Down

0 comments on commit 48de6b7

Please sign in to comment.