Skip to content

Various clean-ups and configuration improvements #489

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

Merged
merged 31 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bb24fcb
Remove legacy iOS localization actions and related helpers
mokagio Jun 2, 2022
ffe1c84
Remove download_metadata.swift references
iangmaia Jan 24, 2023
d730f13
Use get_from_env util method instead of accessing environment var dir…
iangmaia Jan 29, 2023
94ebda7
Update changelog
iangmaia Jan 29, 2023
9cfb2fd
Add PR reference to changelog
iangmaia Jan 30, 2023
88d5052
Update CHANGELOG.md
iangmaia Jan 31, 2023
c812d3d
Add ConfigItem for .xcconfig to replace env var on ios_get_app_version
iangmaia Jan 26, 2023
6949034
Add unit tests for the ios_get_app_version action
iangmaia Jan 27, 2023
38b979b
Update changelog
iangmaia Jan 27, 2023
4bb51f3
Fix unit test that broke due changes in `Ios::VersionHelper`
iangmaia Feb 1, 2023
c94634e
Change `ios_get_app_version` environment var to a more generic one, s…
iangmaia Feb 1, 2023
000862d
Remove Deliverfile related functionality and references
iangmaia Jan 29, 2023
d4eb27d
Update changelog
iangmaia Jan 29, 2023
b484171
Update CHANGELOG.md
iangmaia Feb 10, 2023
6767f91
Update PR reference on change log
iangmaia Feb 10, 2023
00ad6c0
Improve the version parsing code to better handle error cases
iangmaia Jan 27, 2023
e95f0fb
Add unit tests for ios_get_app_version error cases
iangmaia Jan 27, 2023
accfbc6
Make ios_get_app_version_spec unit tests to work with an actual file …
iangmaia Feb 1, 2023
0c497cd
Improve method to read .xcconfig file to use Xcodeproj::Config instea…
iangmaia Feb 1, 2023
0b21773
Add explicit dependency to xcodeproj
iangmaia Feb 3, 2023
e920a74
Remove unnecessary mock of File existence check
iangmaia Feb 3, 2023
ff58e3d
Add more test cases for different .xcconfig file formats
iangmaia Feb 3, 2023
a9446cb
Fix dependency to xcodeproj to allow for minor updates
iangmaia Feb 4, 2023
df28741
Update change log with mention to `xcodeproj` dependency
iangmaia Feb 11, 2023
384de80
Fix unit tests broken due to better xcconfig parsing and improved err…
iangmaia Jun 2, 2023
14d8d5e
Remove already released entry from CHANGELOG
iangmaia Jun 2, 2023
ba20e9b
Update MIGRATION.md with details on how to handle the latest breaking…
iangmaia Jun 2, 2023
0585de3
Use next major version instead of trunk on MIGRATION.md
iangmaia Jun 2, 2023
2011fde
Move MIGRATION.md entry under the 7.0.0 section, as it was already re…
iangmaia Jun 2, 2023
ea183a8
Remove parenthesis from call without parameters
iangmaia Jun 15, 2023
01f73eb
Remove empty files
iangmaia Jun 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

### Breaking Changes

_None_
- Add the `public_version_xcconfig_file` parameter to the `ios_get_app_version` action to replace the need for an environment variable [#445]
- Remove the `ios_localize_project` and `ios_update_metadata` actions [#447]
- Remove the `skip_deliver` parameter from `ios_bump_version_hotfix` and `ios_bump_version_release` actions [#450]

### New Features

Expand Down Expand Up @@ -85,6 +87,7 @@ _None_
### Internal Changes

- Updates `activesupport` to `6.1.7.1`, addressing [a security issue](https://github.com/advisories/GHSA-j6gc-792m-qgm2). This is a major version change, but as the dependency is internal-only, it shouldn't be a breaking change for clients. [#441]
- Add the explicit dependency to `xcodeproj (~> 1.22)`, used in this case to replace the previous manual parsing of `.xcconfig` files. [#451]

## 6.3.0

Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ PATH
progress_bar (~> 1.3)
rake (>= 12.3, < 14.0)
rake-compiler (~> 1.0)
xcodeproj (~> 1.22)

GEM
remote: https://rubygems.org/
Expand Down
20 changes: 19 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
# Migration Instructions for Major Releases

### From `7.0.0` to `8.0.0`
## From `8.0.0` to `9.0.0`

- The deprecated actions `ios_localize_project` and `ios_update_metadata` were now completely removed. If your project is still using them, please use the new tooling instead.
- See `ios_generate_strings_file_from_code`, `ios_extract_keys_from_strings_files`, `ios_download_strings_files_from_glotpress` and `ios_merge_strings_files` for typical replacements.
- The action `ios_get_app_version` now requires a parameter `public_version_xcconfig_file` with the public `.xcconfig` file path instead of relying on the environment variable `PUBLIC_CONFIG_FILE`. While the complete removal of this environment variable is our goal, at this point it is still required by other actions such as `ios_bump_version_release` and `ios_codefreeze_prechecks`.
- The usage of a `Deliverfile` (including its `app_version`) is discouraged -- please use `upload_to_app_store` directly from your `Fastfile` instead. Therefore, the parameter `skip_deliver` from the actions `ios_bump_version_hotfix` and `ios_bump_version_release` has been removed.

### Clean-ups

- You can now delete the `ENV['APP_STORE_STRINGS_FILE_NAME']` from your Fastfile, as it isn't being used anymore.

## From `7.0.0` to `8.0.0`

We are no longer pushing to remote after creating a new commit or a branch. That means, developers need to manually push the changes or add push commands in the project's `Fastfile`. Most importantly, we can no longer immediately trigger beta/final builds after creating a new commit because the changes will not be in remote yet. If you want to keep the existing behavior, you'll need to add a push command before these triggers.

For example, in [WordPress-Android's `new_beta_release` lane](https://github.com/wordpress-mobile/WordPress-Android/blob/0c64cb84c256e004473e97d72b4ac6682ebc140b/fastlane/lanes/release.rb#L86), we download translations, bump the beta version and then trigger a new build in CI. After migrating to `8.0.0` of `release-toolkit`, we'll need to add [`push_to_git_remote`](https://docs.fastlane.tools/actions/push_to_git_remote/) command before this trigger to keep the existing behavior.

## From `6.0.0` to `7.0.0`

Ensure that calls to `ios_bump_version_release` already passed `skip_glotpress: true`.
In case of passing false as parameter or not providing a value (false being the default for this ConfigItem), you'll have to ensure that:
- `download_metadata.swift` isn't being used; if it is, it's a good time to migrate to the new tooling
- You're not relying on `ios_bump_version_release` for commiting the `.po/.pot` file
1 change: 1 addition & 0 deletions fastlane-plugin-wpmreleasetoolkit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'progress_bar', '~> 1.3'
spec.add_dependency 'rake', '>= 12.3', '< 14.0'
spec.add_dependency 'rake-compiler', '~> 1.0'
spec.add_dependency 'xcodeproj', '~> 1.22'

# `google-cloud-storage` is required by fastlane, but we pin it in case it's not in the future
spec.add_dependency 'google-cloud-storage', '~> 1.31'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.run(params)
Fastlane::Helper::Ios::VersionHelper.update_xc_configs(@new_beta_version, @short_version, @new_internal_version)
UI.message 'Done!'

Fastlane::Helper::Ios::GitHelper.commit_version_bump(include_deliverfile: false, include_metadata: false)
Fastlane::Helper::Ios::GitHelper.commit_version_bump
end

#####################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@ def self.run(params)
create_config(params[:previous_version], params[:version])
show_config

update_deliverfile = params[:skip_deliver] == false
if update_deliverfile
UI.message 'Updating Fastlane deliver file...'
Fastlane::Helper::Ios::VersionHelper.update_fastlane_deliver(@new_short_version)
UI.message 'Done!'
end

UI.message 'Updating XcConfig...'
Fastlane::Helper::Ios::VersionHelper.update_xc_configs(@new_version, @new_short_version, @new_version_internal)
UI.message 'Done!'

Fastlane::Helper::Ios::GitHelper.commit_version_bump(include_deliverfile: update_deliverfile, include_metadata: false)
Fastlane::Helper::Ios::GitHelper.commit_version_bump

UI.message 'Done.'
end
Expand Down Expand Up @@ -51,16 +44,6 @@ def self.available_options
description: 'The version to branch from',
type: String
),
FastlaneCore::ConfigItem.new(
key: :skip_deliver,
env_name: 'FL_IOS_BUMP_VERSION_HOTFIX_SKIP_DELIVER',
description: 'Skips Deliverfile key update',
type: Boolean,
optional: true,
# Don't skip the Deliverfile by default. At the time of writing, 2 out of 3 consumers
# still have a Deliverfile.
default_value: false
),
]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,11 @@ def self.run(params)
Fastlane::Helper::GitHelper.create_branch(@new_release_branch, from: default_branch)
UI.message 'Done!'

UI.message 'Updating Fastlane deliver file...' unless params[:skip_deliver]
Fastlane::Helper::Ios::VersionHelper.update_fastlane_deliver(@new_short_version) unless params[:skip_deliver]
UI.message 'Done!' unless params[:skip_deliver]

UI.message 'Updating XcConfig...'
Fastlane::Helper::Ios::VersionHelper.update_xc_configs(@new_version, @new_short_version, @new_version_internal)
UI.message 'Done!'

Fastlane::Helper::Ios::GitHelper.commit_version_bump(
include_deliverfile: !params[:skip_deliver],
include_metadata: false
)
Fastlane::Helper::Ios::GitHelper.commit_version_bump

UI.message 'Done.'
end
Expand All @@ -51,11 +44,6 @@ def self.details

def self.available_options
[
FastlaneCore::ConfigItem.new(key: :skip_deliver,
env_name: 'FL_IOS_CODEFREEZE_BUMP_SKIPDELIVER',
description: 'Skips Deliver key update',
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :default_branch,
env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH',
description: 'Default branch of the repository',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ class IosGetAppVersionAction < Action
def self.run(params)
require_relative '../../helper/ios/ios_version_helper'

UI.user_error!('You need to set at least the PUBLIC_CONFIG_FILE env var to the path to the public xcconfig file') unless ENV['PUBLIC_CONFIG_FILE']

Fastlane::Helper::Ios::VersionHelper.get_public_version
public_version_xcconfig_file = params[:public_version_xcconfig_file]
Fastlane::Helper::Ios::VersionHelper.get_xcconfig_public_version(xcconfig_file: public_version_xcconfig_file)
end

#####################################################
Expand All @@ -22,7 +21,15 @@ def self.details
end

def self.available_options
# Define all options your action supports.
[
FastlaneCore::ConfigItem.new(
key: :public_version_xcconfig_file,
env_name: 'FL_IOS_PUBLIC_VERSION_XCCONFIG_FILE',
description: 'Path to the .xcconfig file containing the public app version',
type: String,
optional: false
),
]
end

def self.output
Expand Down

This file was deleted.

This file was deleted.

57 changes: 2 additions & 55 deletions lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,15 @@ module GitHelper
#
# This typically commits:
# - The files in `./config/*` – especially `Version.*.xcconfig` files
# - The `fastlane/Deliverfile` file (which contains the `app_version` line)
# - The `<ProjectRoot>/<ProjectName>/Resources/AppStoreStrings.pot` file, containing a key for that version's release notes
#
# @env PROJECT_ROOT_FOLDER The path to the git root of the project
# @env PROJECT_NAME The name of the directory containing the project code (especially containing the Resources/ subfolder)
#
# @param [Bool] include_deliverfile If true (the default), includes the `fastlane/Deliverfile` in files being commited
# @param [Bool] include_metadata If true (the default), includes the `fastlane/download_metadata.swift` file and the `.pot` file (which typically contains an entry or release notes for the new version)
#
def self.commit_version_bump(include_deliverfile: true, include_metadata: true)
files_list = [File.join(ENV['PROJECT_ROOT_FOLDER'], 'config', '.')]
files_list.append File.join('fastlane', 'Deliverfile') if include_deliverfile
if include_metadata
files_list.append File.join('fastlane', 'download_metadata.swift')
files_list.append File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'Resources', ENV['APP_STORE_STRINGS_FILE_NAME'])
end
def self.commit_version_bump
files_list = [File.join(get_from_env!(key: 'PROJECT_ROOT_FOLDER'), 'config', '.')]

Fastlane::Helper::GitHelper.commit(message: 'Bump version number', files: files_list)
end

# Calls the `Scripts/localize.py` script in the project root folder and commit the `*.strings` files
#
# That script updates the `.strings` files with translations from GlotPress.
#
# @env PROJECT_ROOT_FOLDER The path to the git root of the project
# @env PROJECT_NAME The name of the directory containing the project code (especially containing the `build.gradle` file)
#
# @deprecated This method is only used by the `ios_localize_project` action, which is itself deprecated
# in favor of the new `ios_generate_strings_file_from_code` action
# @todo [Next Major] Remove this method once we fully remove `ios_localize_project`
#
def self.localize_project
Action.sh("cd #{get_from_env!(key: 'PROJECT_ROOT_FOLDER')} && ./Scripts/localize.py")

Fastlane::Helper::GitHelper.commit(message: 'Update strings for localization', files: strings_files) || UI.message('No new strings, skipping commit')
end

# Call the `Scripts/update-translations.rb` then the `fastlane/download_metadata` Scripts from the host project folder
#
# @env PROJECT_ROOT_FOLDER The path to the git root of the project
# @env PROJECT_NAME The name of the directory containing the project code (especially containing the `build.gradle` file)
#
# @todo Migrate the scripts, currently in each host repo and called by this method, to be helpers and actions
# in the release-toolkit instead, and move this code away from `ios_git_helper`.
#
def self.update_metadata
Action.sh("cd #{get_from_env!(key: 'PROJECT_ROOT_FOLDER')} && ./Scripts/update-translations.rb")

Fastlane::Helper::GitHelper.commit(message: 'Update translations', files: strings_files)

Action.sh('cd fastlane && ./download_metadata.swift')

Fastlane::Helper::GitHelper.commit(message: 'Update metadata translations', files: './fastlane/metadata/')
end

def self.strings_files
project_root = get_from_env!(key: 'PROJECT_ROOT_FOLDER')
project_name = get_from_env!(key: 'PROJECT_NAME')

Dir.glob(File.join(project_root, project_name, '**', '*.strings'))
end

def self.get_from_env!(key:)
ENV.fetch(key) do
UI.user_error! "Could not find value for \"#{key}\" in environment."
Expand Down
Loading