Skip to content

Commit

Permalink
Update latestReleasedVersion on version bump (#5462)
Browse files Browse the repository at this point in the history
Per [b/306709509](https://b.corp.google.com/issues/306709509),

This fixes an oversight in which we were not updating the
`latestReleasedVersion` during our version bumps.

Additionally, this fixes the following:

- [b/306713770](https://b.corp.google.com/issues/306713770) -> Update
the `latestReleasedVersion` for libraries where it's invalid
- [b/300682493](https://b.corp.google.com/issues/300682493) -> Add
condition to `moveUnreleasedChanges` task for changelog file existence
  • Loading branch information
daymxn authored Oct 23, 2023
1 parent 250c69f commit 1ec75d4
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 29 deletions.
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck-debug-testing/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck-debug/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck-interop/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck-playintegrity/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class PostReleasePlugin : Plugin<Project> {
* is set to the current version of said module. After a release, this `version` should be bumped
* up to differentiate between code at HEAD, and the latest released version.
*
* Furthermore, this file may optionally contain a `latestReleasedVersion` variable (if the SDK
* has released). If this property is present, it should be updated to the related version that
* went out during the release.
*
* @see VersionBumpTask
*
* @param project the [Project] to register this task to
Expand All @@ -72,7 +76,9 @@ class PostReleasePlugin : Plugin<Project> {
* @param project the [Project] to register this task to
*/
fun registerMoveUnreleasedChangesTask(project: Project) =
project.tasks.register<MoveUnreleasedChangesTask>("moveUnreleasedChanges")
project.tasks.register<MoveUnreleasedChangesTask>("moveUnreleasedChanges") {
onlyIf("CHANGELOG.md file must be present") { project.file("CHANGELOG.md").exists() }
}

/**
* Registers the `updatePinnedDependencies` for the provided [Project]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,29 @@ import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.provideDelegate

/**
* Bumps the `version` property of the specified [versionFile].
* Bumps the `version` property of the specified [versionFile], and sets the
* `latestReleasedVersion`.
*
* Primarily utilized as a post-release clean up task in which we bump the versions of released
* modules to be one patch higher than their currently released counterparts.
* modules to be one patch higher than their currently released counterparts, and update their
* latest released version.
*
* @see PostReleasePlugin
*
* @property versionFile A [File] that contains the `version` property. Defaults to the
* `gradle.properties` file at the project's root.
* @property releasedVersion A [ModuleVersion] of what to bump from. Defaults to the project
* version.
* @property newVersion A [ModuleVersion] of what to set the version to. Defaults to one patch
* higher than the existing version.
* higher than [releasedVersion]
*/
abstract class VersionBumpTask : DefaultTask() {
@get:[Optional InputFile]
abstract val versionFile: Property<File>

@get:[Optional Input]
abstract val releasedVersion: Property<ModuleVersion>

@get:[Optional Input]
abstract val newVersion: Property<ModuleVersion>

Expand All @@ -50,18 +57,23 @@ abstract class VersionBumpTask : DefaultTask() {
@TaskAction
fun build() {
versionFile.get().rewriteLines {
if (it.startsWith("version=")) "version=${newVersion.get()}" else it
when {
it.startsWith("version=") -> "version=${newVersion.get()}"
it.startsWith("latestReleasedVersion") -> "latestReleasedVersion=${releasedVersion.get()}"
else -> it
}
}
}

fun configure() {
versionFile.convention(project.file("gradle.properties"))
newVersion.convention(computeNewVersion())
releasedVersion.convention(computeReleasedVersion())
newVersion.convention(releasedVersion.map { it.bump() })
}

fun computeNewVersion(): ModuleVersion? {
fun computeReleasedVersion(): ModuleVersion? {
val version: String? by project

return version?.let { ModuleVersion.fromStringOrNull(it)?.bump() }
return version?.let { ModuleVersion.fromStringOrNull(it) }
}
}
2 changes: 1 addition & 1 deletion firebase-config/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#

version=21.5.1
latestReleasedVersion=21.4.1
latestReleasedVersion=21.5.0
android.enableUnitTestBinaryResources=true

2 changes: 1 addition & 1 deletion firebase-crashlytics-ndk/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=18.5.1
latestReleasedVersion=18.4.3
latestReleasedVersion=18.5.0
2 changes: 1 addition & 1 deletion firebase-crashlytics/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=18.5.1
latestReleasedVersion=18.4.3
latestReleasedVersion=18.5.0
2 changes: 1 addition & 1 deletion firebase-database/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

version=20.3.1
latestReleasedVersion=20.2.2
latestReleasedVersion=20.3.0
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion firebase-dynamic-links/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

version=21.2.1
latestReleasedVersion=21.1.0
latestReleasedVersion=21.2.0
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion firebase-firestore/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=24.9.1
latestReleasedVersion=24.8.1
latestReleasedVersion=24.9.0
2 changes: 1 addition & 1 deletion firebase-functions/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=20.4.1
latestReleasedVersion=20.3.1
latestReleasedVersion=20.4.0
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion firebase-inappmessaging-display/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=20.4.1
latestReleasedVersion=20.3.5
latestReleasedVersion=20.4.0
2 changes: 1 addition & 1 deletion firebase-inappmessaging/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=20.4.1
latestReleasedVersion=20.3.5
latestReleasedVersion=20.4.0
2 changes: 1 addition & 1 deletion firebase-installations/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.2.1
latestReleasedVersion=17.1.4
latestReleasedVersion=17.2.0
2 changes: 1 addition & 1 deletion firebase-messaging-directboot/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=23.3.1
latestReleasedVersion=23.2.1
latestReleasedVersion=23.3.0
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion firebase-messaging/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=23.3.1
latestReleasedVersion=23.2.1
latestReleasedVersion=23.3.0
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion firebase-ml-modeldownloader/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=24.2.1
latestReleasedVersion=24.1.3
latestReleasedVersion=24.2.0
2 changes: 1 addition & 1 deletion firebase-perf/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
#

version=20.5.1
latestReleasedVersion=20.4.1
latestReleasedVersion=20.5.0
android.enableUnitTestBinaryResources=true

2 changes: 1 addition & 1 deletion firebase-sessions/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.

version=1.1.1
latestReleasedVersion=1.0.2
latestReleasedVersion=1.1.0
2 changes: 1 addition & 1 deletion firebase-storage/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

version=20.3.1
latestReleasedVersion=20.2.1
latestReleasedVersion=20.3.0
android.enableUnitTestBinaryResources=true

0 comments on commit 1ec75d4

Please sign in to comment.