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

Jetpack App: Update release toolkit to support Jetpack #258

Merged
merged 59 commits into from
Jun 22, 2021

Conversation

JavonDavis
Copy link
Contributor

@JavonDavis JavonDavis commented May 12, 2021

This PR introduces changes that were primarily needed to support the new Jetpack app in the WPAndroid repo but are more focused on updating how versions are managed in our current and future Android apps. The proposals here are:

  • The use of a new app parameter/environment variable to add an additional context when doing versioning. This is a new parameter that can be passed as an option to the commands related to versioning, this value can can also be set as an environment variable for projects that don't have multiple 'apps' within them.
  • It also proposes the use of a new properties file in the project repos to manage versioning, a version.properties file that follows the following key-value format
appName.versionName=<version name>
appName.versionCode=<version code>

appName.alpha.versionName=<version name>
appName.alpha.versionCode=<version code>

Example here: https://github.com/wordpress-mobile/WordPress-Android/blob/fe4352dbdf2d8b56f760ceeb6a0bd591883b23e4/version.properties

With accompanying changes in the build.gradle file to read the versions from this file instead of being defined in the build.gradle. Something like so ->

def versionProperties = new Properties()
    file("../version.properties").withInputStream { versionProperties.load(it) }

    compileSdkVersion rootProject.compileSdkVersion

    defaultConfig {
	@@ -60,9 +63,10 @@ android {
        if (project.hasProperty("versionName")) {
            versionName project.property("versionName")
        } else {
            versionName versionProperties.getProperty("wordpress.alpha.versionName")
        }

        versionCode versionProperties.getProperty("wordpress.alpha.versionCode").toInteger()
task "updateVersionProperties" {
    doLast {
        ant.propertyfile(
                file: "../version.properties") {
            entry( key: "$key", value: "$value")
        }
    }
}

@JavonDavis JavonDavis added the enhancement New feature or request label May 12, 2021
@JavonDavis JavonDavis self-assigned this May 12, 2021
@codecov-commenter
Copy link

codecov-commenter commented May 12, 2021

Codecov Report

Merging #258 (d10336d) into develop (3417301) will decrease coverage by 0.14%.
The diff coverage is 21.26%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #258      +/-   ##
===========================================
- Coverage    51.66%   51.51%   -0.15%     
===========================================
  Files          108      108              
  Lines         4477     4523      +46     
===========================================
+ Hits          2313     2330      +17     
- Misses        2164     2193      +29     
Impacted Files Coverage Δ
...kit/actions/android/android_betabuild_prechecks.rb 25.00% <0.00%> (-0.54%) ⬇️
...toolkit/actions/android/android_build_prechecks.rb 34.37% <0.00%> (-2.30%) ⬇️
...olkit/actions/android/android_bump_version_beta.rb 31.42% <0.00%> (-5.42%) ⬇️
...kit/actions/android/android_bump_version_hotfix.rb 29.03% <0.00%> (-5.26%) ⬇️
...it/actions/android/android_bump_version_release.rb 26.19% <0.00%> (-3.81%) ⬇️
...it/actions/android/android_codefreeze_prechecks.rb 34.21% <0.00%> (-1.91%) ⬇️
...ns/android/android_completecodefreeze_prechecks.rb 38.70% <0.00%> (-1.30%) ⬇️
...ctions/android/android_current_branch_is_hotfix.rb 59.09% <0.00%> (-5.91%) ⬇️
...lkit/actions/android/android_finalize_prechecks.rb 41.93% <0.00%> (-1.40%) ⬇️
...olkit/actions/android/android_get_alpha_version.rb 55.00% <0.00%> (-6.12%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3417301...d10336d. Read the comment docs.

@JavonDavis JavonDavis changed the title Update/jetpack Jetpack App: Update release toolkit to support Jetpack May 13, 2021
@JavonDavis JavonDavis marked this pull request as ready for review May 13, 2021 18:27
@JavonDavis JavonDavis requested a review from a team May 13, 2021 18:27
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

I like the suggestion to introduce a version.properties 👍
But that also means that this PR is quite a breaking change, as it will require the apps to update:

  • Their Fastfile to update all the calls to the various actions you modified, to provide the app name now (especially WooCommerce Android as you otherwise made the app name default to wordpress).
  • Their build.gradle file to load the new version.properties and make the versionName/versionCode references point to it.
  • Create their version.properties.

That is quite the breaking change, so this should not be merged before we do an intermediate release of the release-toolkit before this PR, which first contains all the pending but non-breaking fixes that are waiting for review, and only could we merge this PR and immediately create a new major version (since breaking changes)

CHANGELOG.md Outdated Show resolved Hide resolved
@JavonDavis JavonDavis requested review from AliSoftware and a team June 15, 2021 15:24
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Still spotted an inverted logic remaining…

Once this is fixed and the other nits are addressed, should hopefully be finally good to merge tho. (Don't forget to also create the issue about alpha env var removal to handle it later)

@@ -23,14 +34,21 @@ def self.run(params)
#####################################################

def self.description
'Bumps the version of the app for a new beta'
'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.'
Copy link
Contributor

@AliSoftware AliSoftware Jun 16, 2021

Choose a reason for hiding this comment

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

We need to think about the people who will adopt this version of the release toolkit and have never seen your PR nor code. They should not have to guess what gradle task they need to add to make this working.

Suggested change
'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.'
'Bumps the version of the app for a new beta. Requires the `updateVersionProperties` gradle task to update the keys if you are using a `version.properties` file.'

(And same suggestion (search/replace all) on all the places and other actions where you mentioned this)

Copy link
Contributor Author

@JavonDavis JavonDavis Jun 17, 2021

Choose a reason for hiding this comment

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

That's true! Agree with being more explicit here

FastlaneCore::ConfigItem.new(key: :app,
env_name: 'PROJECT_NAME',
description: 'The name of the app to get the release version for',
is_string: true), # true: verifies the input is a string, false: every kind of value
Copy link
Contributor

@AliSoftware AliSoftware Jun 16, 2021

Choose a reason for hiding this comment

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

Nit: This is legacy api of ConfigItem constructor. The more modern version is:

Suggested change
is_string: true), # true: verifies the input is a string, false: every kind of value
type: String),

This is not a blocker and can be fixed in a subsequent PR; but could be nice to take the occasion to fix while you're at it; this suggestion applies in every places and actions where you added this of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh I think I'd rather tackle it in another PR, opened #278 to track it.

Comment on lines 16 to 28
if Fastlane::Helper::Android::VersionHelper.properties_file_exists
Fastlane::Helper::GitHelper.commit(
message: 'Bump version number',
files: File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle'),
push: true
)
else
Fastlane::Helper::GitHelper.commit(
message: 'Bump version number',
files: File.join(ENV['PROJECT_ROOT_FOLDER'], 'version.properties'),
push: true
)
end
Copy link
Contributor

@AliSoftware AliSoftware Jun 16, 2021

Choose a reason for hiding this comment

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

🚨 This one still seems inverted, commiting build.gradle if version.properties exists…

CHANGELOG.md Outdated
* Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present
* Add support for providing an `app:` parameter to most versioning-related actions to allow support for multiple apps hosted in a monorepo
* Supporting the new version.properties file also allows for the HAS_ALPHA_VERSION variable to be removed as the alpha reference in the properties file will be used going forward.
* Clients adopting the new version.properties will need to implement a gradle task to update the version.properties file named `updateVersionProperties`
Copy link
Contributor

@AliSoftware AliSoftware Jun 16, 2021

Choose a reason for hiding this comment

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

💄 nit:

Suggested change
* Clients adopting the new version.properties will need to implement a gradle task to update the version.properties file named `updateVersionProperties`
* Clients adopting the new `version.properties` will need to implement a gradle task named `updateVersionProperties` to update the `version.properties` file.

CHANGELOG.md Outdated
_None_
* Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present
* Add support for providing an `app:` parameter to most versioning-related actions to allow support for multiple apps hosted in a monorepo
* Supporting the new version.properties file also allows for the HAS_ALPHA_VERSION variable to be removed as the alpha reference in the properties file will be used going forward.
Copy link
Contributor

@AliSoftware AliSoftware Jun 16, 2021

Choose a reason for hiding this comment

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

💄 small nit:

Suggested change
* Supporting the new version.properties file also allows for the HAS_ALPHA_VERSION variable to be removed as the alpha reference in the properties file will be used going forward.
* Supporting the new `version.properties` file also allows for the `HAS_ALPHA_VERSION` variable to be removed as the alpha reference in the properties file will be used going forward.

CHANGELOG.md Outdated
### New Features

_None_
* Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present
Copy link
Contributor

@AliSoftware AliSoftware Jun 16, 2021

Choose a reason for hiding this comment

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

💄 small nitpick:

Suggested change
* Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present
* Support for a `version.properties` to manage app versioning - all existing paths remain intact and new paths are only used when a `version.properties` file is present.

@AliSoftware
Copy link
Contributor

Also there's a CI failure on tests, we should fix it before merging, in order to make CI actually run the tests and ensure those changes didn't break any existing test nor introduce regressions.

@oguzkocer
Copy link
Contributor

@JavonDavis About your review request, since @AliSoftware is already reviewing this, and he's our expert :) I don't know if I can add any value to this PR by reviewing it. I have quite a few things to get through in the next couple days, so I wanted to check if you'd still like me to review it or not. If you do, I'll try to get to it before my EOD.

@JavonDavis
Copy link
Contributor Author

If you do, I'll try to get to it before my EOD.

No worries @oguzkocer, though I'd definitely appreciate your feedback on the changes on the Android side once I open it for review for this so feel free to ignore this one!

@JavonDavis JavonDavis requested review from AliSoftware and removed request for oguzkocer June 17, 2021 03:02
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Ok, all looks good now 🎉

@@ -46,8 +46,8 @@ def self.get_public_version(app)
#
# @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively
#
def self.get_release_version(app)
return get_version_from_properties(product_name: app) if properties_file_exists
def self.get_release_version(product_name:)
Copy link
Contributor

Choose a reason for hiding this comment

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

You should update the comment on line 45 too, to match the param name 😉

        # @param [String] product_name The name of the app to be used for beta and alpha version update (i.e the prefix in version.properties file)

@JavonDavis JavonDavis merged commit c0df075 into develop Jun 22, 2021
@JavonDavis JavonDavis deleted the update/jetpack branch June 22, 2021 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants