Skip to content

Commit 2066212

Browse files
committed
[CI] Include version.samples property update in release workflow
1 parent dc23c52 commit 2066212

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

buildSrc/src/main/java/org/springframework/pulsar/gradle/versions/UpdateProjectVersionTask.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 the original author or authors.
2+
* Copyright 2019-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,22 +31,24 @@ public abstract class UpdateProjectVersionTask extends DefaultTask {
3131

3232
static final String VERSION_PROPERTY = "version";
3333

34-
static final String SPRING_BOOT_VERSION_PROPERTY = "spring-boot-for-docs";
34+
static final String VERSION_FOR_SAMPLES_PROPERTY = "version.samples";
35+
36+
static final String SPRING_BOOT_VERSION_FOR_DOCS_PROPERTY = "spring-boot-for-docs";
3537

3638
static final Pattern VERSION_PATTERN = Pattern.compile("^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-M\\d+|-RC\\d+|-SNAPSHOT)?$");
3739

38-
protected void updateVersionInGradleProperties(String newVersion) {
39-
this.updatePropertyInFile(Project.GRADLE_PROPERTIES, VERSION_PROPERTY,
40-
(p) -> p.getVersion().toString(),
41-
(__) -> newVersion,
42-
(currentValue) -> "%s=%s".formatted(VERSION_PROPERTY, currentValue),
43-
(__) -> "%s=%s".formatted(VERSION_PROPERTY, newVersion));
40+
protected void updateVersionInGradleProperties(String versionPropertyName, String newVersion) {
41+
this.updatePropertyInFile(Project.GRADLE_PROPERTIES, versionPropertyName,
42+
(p) -> p.property(versionPropertyName).toString(),
43+
(currentValue) -> newVersion,
44+
(currentValue) -> "%s=%s".formatted(versionPropertyName, currentValue),
45+
(newValue) -> "%s=%s".formatted(versionPropertyName, newValue));
4446
}
4547

4648
protected void updateVersionInTomlVersions(String versionPropertyName,
4749
Function<String, String> newPropertyValueGivenCurrentValue) {
4850
this.updatePropertyInFile("gradle/libs.versions.toml", versionPropertyName,
49-
(p) -> currentVersionForProperty(p, versionPropertyName),
51+
(p) -> currentVersionInCatalog(p, versionPropertyName),
5052
newPropertyValueGivenCurrentValue,
5153
(currentValue) -> "%s = \"%s\"".formatted(versionPropertyName, currentValue),
5254
(newValue) -> "%s = \"%s\"".formatted(versionPropertyName, newValue));
@@ -85,7 +87,7 @@ protected VersionInfo parseVersion(String version) {
8587
}
8688
}
8789

88-
protected String currentVersionForProperty(Project project, String versionProperty) {
90+
protected String currentVersionInCatalog(Project project, String versionProperty) {
8991
VersionCatalogsExtension catalog = project.getExtensions().getByType(VersionCatalogsExtension.class);
9092
return catalog.named("libs").findVersion(versionProperty)
9193
.orElseThrow(() -> new IllegalStateException("% property not found".formatted(versionProperty)))

buildSrc/src/main/java/org/springframework/pulsar/gradle/versions/UpdateToReleaseVersionTask.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 the original author or authors.
2+
* Copyright 2019-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,8 +26,8 @@ public abstract class UpdateToReleaseVersionTask extends UpdateProjectVersionTas
2626

2727
@TaskAction
2828
public void updateToReleaseVersion() {
29-
updateVersionInGradleProperties(this.releaseVersion);
30-
updateVersionInTomlVersions(SPRING_BOOT_VERSION_PROPERTY, this::calculateReleaseBootVersion);
29+
updateVersionInGradleProperties(VERSION_PROPERTY, this.releaseVersion);
30+
updateVersionInTomlVersions(SPRING_BOOT_VERSION_FOR_DOCS_PROPERTY, this::calculateReleaseBootVersion);
3131
}
3232

3333
public String getReleaseVersion() {

buildSrc/src/main/java/org/springframework/pulsar/gradle/versions/UpdateToSnapshotVersionTask.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 the original author or authors.
2+
* Copyright 2019-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,10 @@ public abstract class UpdateToSnapshotVersionTask extends UpdateProjectVersionTa
2323
@TaskAction
2424
public void updateToSnapshotVersion() {
2525
String currentVersion = getProject().getVersion().toString();
26-
updateVersionInGradleProperties(calculateNextSnapshotVersion(currentVersion));
27-
updateVersionInTomlVersions(SPRING_BOOT_VERSION_PROPERTY, this::calculateNextSnapshotVersion);
26+
String nextSnapshotVersion = calculateNextSnapshotVersion(currentVersion);
27+
updateVersionInGradleProperties(VERSION_PROPERTY, nextSnapshotVersion);
28+
updateVersionInGradleProperties(VERSION_FOR_SAMPLES_PROPERTY, nextSnapshotVersion);
29+
updateVersionInTomlVersions(SPRING_BOOT_VERSION_FOR_DOCS_PROPERTY, this::calculateNextSnapshotVersion);
2830
}
2931

3032
private String calculateNextSnapshotVersion(String version) {

0 commit comments

Comments
 (0)