Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further Fastlane setup improvements before adding CI release automation #22214

Merged
merged 9 commits into from
Dec 14, 2023
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 it's relevant helpers use environment variables to modify the output.
mokagio marked this conversation as resolved.
Show resolved Hide resolved
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick but also a question. I thought environment variables can only be strings - or not set at all. I guess Ruby might be setting this as a string, I am not sure - but for those who are less familiar with Ruby (like myself) I think it's worth setting this as a string value instead.

Having said that, I might totally be wrong about environment variables, and if so, I'd like to fix that 😅

Copy link
Contributor Author

@mokagio mokagio Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Nah, you are totally right. As the CI failure on this build shows, ENV expects the value passed to it to be a string.

I just assumed it was fine and that Ruby handled the conversion under the hood. My mistake. Thanks for noticing 🙇‍♂️


# 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]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed here, #22191 (comment), reverted the change that printed this information only in user interactive (skip_confirm:false) mode.

# 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
Comment on lines +29 to -32
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to call out in this diff the move from <<- to <<~ and how it affects the indentation once message is printed.

image

cc @spencertransier as (I think) the original author. It's a neat Ruby feature I hope you'll enjoy.

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.")
Comment on lines -104 to +101
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #22191 (comment)

but this message feels a bit off to me. When we run this lane locally, the code freeze is completed at this point - we just didn't push it to remote yet.

It does make sense in CI, because if the change is not pushed, then it's discarded. However, that's not the case for local. 🤷

Changed the verb to "terminating" which I hope removes the impression that the lane is atomic and therefore aborting would discard changes. Also added the second sentence to reinforce the fact that changes have been made and it's up to the user to complete the process.

I considered listing what the remaining steps were, but then decided against it to avoid having to maintain that list as the lane evolves.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works OK as a generic message. Thanks for the improvement!

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