-
Notifications
You must be signed in to change notification settings - Fork 8
Add ios_get_build_number action
#458
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
Conversation
| # @return [String] The current build number according to the public xcconfig file. | ||
| # | ||
| def self.get_build_number | ||
| read_build_number_from_config_file(ENV['PUBLIC_CONFIG_FILE']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mokagio Ready for re-review. It now uses an argument instead of the env variable
lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_number.rb
Outdated
Show resolved
Hide resolved
| it 'parses an xcconfig file with keys with spaces and returns a nil build number' do | ||
| xcconfig_mock_content = <<~CONTENT | ||
| VERSION_SHORT = 6 | ||
| VERSION_LONG = 6.30.1 | ||
| BUILD_NUMBER = 1940 | ||
| CONTENT | ||
|
|
||
| expect_build_number(xcconfig_mock_content: xcconfig_mock_content, expected_build_number: nil) | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was surprised by this because key = value is a valid xcconfig syntax. Looking at the pre-existing, underlying implementation, I can see why this is required given that we manually parse the xcconfig files
release-toolkit/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb
Lines 286 to 302 in e4b28a4
| # Read the value of a given key from an `.xcconfig` file. | |
| # | |
| # @param [String] key The xcconfig key to get the value for | |
| # @param [String] filePath The path to the `.xcconfig` file to read the value from | |
| # | |
| # @return [String] The value for the given key, or `nil` if the key was not found. | |
| # | |
| def self.read_from_config_file(key, filePath) | |
| File.open(filePath, 'r') do |f| | |
| f.each_line do |line| | |
| line = line.strip() | |
| return line.split('=')[1] if line.start_with?("#{key}=") | |
| end | |
| end | |
| return nil | |
| end |
We should be able to replace that bespoke logic with the API provided by the xcodeproj gem like we do in Jetpack and WordPress iOS:
version_config_path = File.join(PROJECT_ROOT_FOLDER, 'config', 'Version.internal.xcconfig')
versions = Xcodeproj::Config.new(File.new(version_config_path)).to_hashThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Gio Lodi <[email protected]>
Co-authored-by: Gio Lodi <[email protected]>
What does it do?
This action adds an action called
ios_get_build_numberto get the current build number from anxcconfigfile. Because Day One iOS and Mac use the build number to name builds, this new action is needed for things like GitHub release names and tags.How to test
bloom/DayOne-Applerepo, switch to thespencer/demo-get-build-number-actionbranchbundle exec fastlane ios test_get_build_number_actionbundle exec fastlane mac test_get_build_number_actionChecklist before requesting a review
bundle exec rubocopto test for code style violations and recommendationsspecs/*_spec.rb) if applicablebundle exec rspecto run the whole test suite and ensure all your tests passCHANGELOG.mdfile to describe your changes under the approprioate existing###subsection of the existing## Trunksection.