Skip to content

Commit 1ec75d4

Browse files
authored
Update latestReleasedVersion on version bump (#5462)
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
1 parent 250c69f commit 1ec75d4

File tree

23 files changed

+47
-29
lines changed

23 files changed

+47
-29
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version=17.1.1
2-
latestReleasedVersion=17.0.1
2+
latestReleasedVersion=17.1.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version=17.1.1
2-
latestReleasedVersion=17.0.1
2+
latestReleasedVersion=17.1.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version=17.1.1
2-
latestReleasedVersion=17.0.1
2+
latestReleasedVersion=17.1.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version=17.1.1
2-
latestReleasedVersion=17.0.1
2+
latestReleasedVersion=17.1.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version=17.1.1
2-
latestReleasedVersion=17.0.1
2+
latestReleasedVersion=17.1.0

buildSrc/src/main/java/com/google/firebase/gradle/plugins/PostReleasePlugin.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class PostReleasePlugin : Plugin<Project> {
5252
* is set to the current version of said module. After a release, this `version` should be bumped
5353
* up to differentiate between code at HEAD, and the latest released version.
5454
*
55+
* Furthermore, this file may optionally contain a `latestReleasedVersion` variable (if the SDK
56+
* has released). If this property is present, it should be updated to the related version that
57+
* went out during the release.
58+
*
5559
* @see VersionBumpTask
5660
*
5761
* @param project the [Project] to register this task to
@@ -72,7 +76,9 @@ class PostReleasePlugin : Plugin<Project> {
7276
* @param project the [Project] to register this task to
7377
*/
7478
fun registerMoveUnreleasedChangesTask(project: Project) =
75-
project.tasks.register<MoveUnreleasedChangesTask>("moveUnreleasedChanges")
79+
project.tasks.register<MoveUnreleasedChangesTask>("moveUnreleasedChanges") {
80+
onlyIf("CHANGELOG.md file must be present") { project.file("CHANGELOG.md").exists() }
81+
}
7682

7783
/**
7884
* Registers the `updatePinnedDependencies` for the provided [Project]

buildSrc/src/main/java/com/google/firebase/gradle/plugins/VersionBumpTask.kt

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,29 @@ import org.gradle.api.tasks.TaskAction
2424
import org.gradle.kotlin.dsl.provideDelegate
2525

2626
/**
27-
* Bumps the `version` property of the specified [versionFile].
27+
* Bumps the `version` property of the specified [versionFile], and sets the
28+
* `latestReleasedVersion`.
2829
*
2930
* Primarily utilized as a post-release clean up task in which we bump the versions of released
30-
* modules to be one patch higher than their currently released counterparts.
31+
* modules to be one patch higher than their currently released counterparts, and update their
32+
* latest released version.
3133
*
3234
* @see PostReleasePlugin
3335
*
3436
* @property versionFile A [File] that contains the `version` property. Defaults to the
3537
* `gradle.properties` file at the project's root.
38+
* @property releasedVersion A [ModuleVersion] of what to bump from. Defaults to the project
39+
* version.
3640
* @property newVersion A [ModuleVersion] of what to set the version to. Defaults to one patch
37-
* higher than the existing version.
41+
* higher than [releasedVersion]
3842
*/
3943
abstract class VersionBumpTask : DefaultTask() {
4044
@get:[Optional InputFile]
4145
abstract val versionFile: Property<File>
4246

47+
@get:[Optional Input]
48+
abstract val releasedVersion: Property<ModuleVersion>
49+
4350
@get:[Optional Input]
4451
abstract val newVersion: Property<ModuleVersion>
4552

@@ -50,18 +57,23 @@ abstract class VersionBumpTask : DefaultTask() {
5057
@TaskAction
5158
fun build() {
5259
versionFile.get().rewriteLines {
53-
if (it.startsWith("version=")) "version=${newVersion.get()}" else it
60+
when {
61+
it.startsWith("version=") -> "version=${newVersion.get()}"
62+
it.startsWith("latestReleasedVersion") -> "latestReleasedVersion=${releasedVersion.get()}"
63+
else -> it
64+
}
5465
}
5566
}
5667

5768
fun configure() {
5869
versionFile.convention(project.file("gradle.properties"))
59-
newVersion.convention(computeNewVersion())
70+
releasedVersion.convention(computeReleasedVersion())
71+
newVersion.convention(releasedVersion.map { it.bump() })
6072
}
6173

62-
fun computeNewVersion(): ModuleVersion? {
74+
fun computeReleasedVersion(): ModuleVersion? {
6375
val version: String? by project
6476

65-
return version?.let { ModuleVersion.fromStringOrNull(it)?.bump() }
77+
return version?.let { ModuleVersion.fromStringOrNull(it) }
6678
}
6779
}

firebase-config/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
#
1616

1717
version=21.5.1
18-
latestReleasedVersion=21.4.1
18+
latestReleasedVersion=21.5.0
1919
android.enableUnitTestBinaryResources=true
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version=18.5.1
2-
latestReleasedVersion=18.4.3
2+
latestReleasedVersion=18.5.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version=18.5.1
2-
latestReleasedVersion=18.4.3
2+
latestReleasedVersion=18.5.0

0 commit comments

Comments
 (0)