Skip to content

Commit 5da13d2

Browse files
committed
[CI] Update boot version property at release time
1 parent ca56833 commit 5da13d2

File tree

7 files changed

+47
-16
lines changed

7 files changed

+47
-16
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
4141
echo "project_version=$version" >>$GITHUB_OUTPUT
4242
build_jdk_17:
43-
name: Build and Deploy Artifacts (JDK 17)
43+
name: Build (JDK 17)
4444
needs: [prerequisites]
4545
runs-on: ubuntu-latest
4646
if: needs.prerequisites.outputs.runjobs

.github/workflows/prepare-release.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ on:
77
description: 'Version to release'
88
required: true
99
type: string
10-
10+
springBootVersion:
11+
description: 'Spring Boot Version (Delivery Vehicle)'
12+
required: true
13+
type: string
1114
permissions:
1215
contents: read
1316

@@ -27,10 +30,7 @@ jobs:
2730
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
2831

2932
- name: Set up Gradle
30-
uses: spring-io/spring-gradle-build-action@v1
31-
with:
32-
java-version: '17'
33-
distribution: 'temurin'
33+
uses: spring-io/spring-gradle-build-action@v2
3434

3535
- id: check-open-issues
3636
name: Check for open issues
@@ -54,9 +54,10 @@ jobs:
5454
git config user.name 'github-actions[bot]'
5555
git config user.email 'github-actions[bot]@users.noreply.github.com'
5656
releaseVersion="${{ inputs.releaseVersion }}"
57+
springBootVersion="${{ inputs.springBootVersion }}"
5758
releaseBranch="release-initiate/$releaseVersion"
5859
git checkout -b $releaseBranch
59-
./gradlew :updateToReleaseVersion -PreleaseVersion=$releaseVersion
60+
./gradlew :updateToReleaseVersion -PreleaseVersion=$releaseVersion -PspringBootVersion=$springBootVersion
6061
git commit -am "[Release $releaseVersion] Update version"
6162
git push origin $releaseBranch
6263
gh pr create --title "[Release $releaseVersion] Update version" --body "Merge to initiate release."

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public void apply(Project project) {
2626
updateToReleaseVersionTask.setGroup("Release");
2727
updateToReleaseVersionTask.setDescription("Updates the project version to the next release in gradle.properties");
2828
updateToReleaseVersionTask.setReleaseVersion((String) project.findProperty("releaseVersion"));
29+
updateToReleaseVersionTask.setSpringBootVersion((String) project.findProperty("springBootVersion"));
2930
});
3031
project.getTasks().register("updateToSnapshotVersion", UpdateToSnapshotVersionTask.class, updateToSnapshotVersionTask -> {
3132
updateToSnapshotVersionTask.setGroup("Release");

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,38 @@
1717
package org.springframework.pulsar.gradle.versions;
1818

1919
import java.io.File;
20+
import java.util.Objects;
21+
import java.util.function.Function;
2022

2123
import org.gradle.api.DefaultTask;
2224
import org.gradle.api.Project;
23-
import org.gradle.api.tasks.Input;
24-
import org.gradle.api.tasks.TaskAction;
2525

2626
public abstract class UpdateProjectVersionTask extends DefaultTask {
2727

2828
protected void updateVersionInGradleProperties(String newVersion) {
29-
String currentVersion = getProject().getVersion().toString();
29+
this.updatePropertyInGradleProperties("version", (p) -> p.getVersion().toString(), newVersion);
30+
}
31+
32+
protected void updatePropertyInGradleProperties(String propertyName, String newPropertyValue) {
33+
this.updatePropertyInGradleProperties(propertyName,
34+
(p) -> Objects.toString(p.findProperty(propertyName), ""), newPropertyValue);
35+
}
36+
37+
protected void updatePropertyInGradleProperties(
38+
String propertyName,
39+
Function<Project, String> currentPropertyValueFromProject,
40+
String newPropertyValue) {
41+
String currentPropertyValue = currentPropertyValueFromProject.apply(getProject());
3042
File gradlePropertiesFile = getProject().getRootProject().file(Project.GRADLE_PROPERTIES);
3143
if (!gradlePropertiesFile.exists()) {
32-
throw new RuntimeException("No gradle.properties to update version in");
44+
throw new RuntimeException("No gradle.properties to update property in");
3345
}
34-
System.out.printf("Updating the project version in %s from %s to %s%n",
35-
Project.GRADLE_PROPERTIES, currentVersion, newVersion);
46+
System.out.printf("Updating the %s property in %s from %s to %s%n",
47+
propertyName, Project.GRADLE_PROPERTIES, currentPropertyValue, newPropertyValue);
3648
FileUtils.replaceFileText(gradlePropertiesFile, (gradlePropertiesText) -> {
3749
gradlePropertiesText = gradlePropertiesText.replace(
38-
"version=" + currentVersion, "version=" + newVersion);
50+
"%s=%s".formatted(propertyName, currentPropertyValue),
51+
"%s=%s".formatted(propertyName, newPropertyValue));
3952
return gradlePropertiesText;
4053
});
4154
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ public abstract class UpdateToReleaseVersionTask extends UpdateProjectVersionTas
2424
@Input
2525
private String releaseVersion;
2626

27+
@Input
28+
private String springBootVersion;
29+
2730
@TaskAction
2831
public void updateToReleaseVersion() {
2932
updateVersionInGradleProperties(this.releaseVersion);
33+
updatePropertyInGradleProperties("springBootVersionForDocs", this.springBootVersion);
3034
}
3135

3236
public String getReleaseVersion() {
@@ -36,4 +40,12 @@ public String getReleaseVersion() {
3640
public void setReleaseVersion(String releaseVersion) {
3741
this.releaseVersion = releaseVersion;
3842
}
43+
44+
public String getSpringBootVersion() {
45+
return springBootVersion;
46+
}
47+
48+
public void setSpringBootVersion(String springBootVersion) {
49+
this.springBootVersion = springBootVersion;
50+
}
3951
}

gradle.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ pulsarClientVersion=3.1.0
88
pulsarClientReactiveVersion=0.4.0
99
springFrameworkVersion=6.1.0-RC1
1010

11-
# only used by docs, tests, and samples (unpublished deps)
11+
# only used by integration tests and samples (unpublished deps)
1212
springBootVersion=3.2.0-SNAPSHOT
13+
14+
# only used for docs
15+
springBootVersionForDocs=3.2.0-SNAPSHOT
16+
1317
springCloudStreamVersion=4.1.0-SNAPSHOT

gradle/antora-docs.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ tasks.create('generateAntoraResources') {
3636
}
3737

3838
def generateAttributes() {
39-
return ['spring-boot-version': project.springBootVersion ?: 'current',
39+
return ['spring-boot-version': project.springBootVersionForDocs ?: 'current',
4040
'spring-framework-version': project.springFrameworkVersion ?: 'current',
4141
'spring-cloud-stream-version': project.springCloudStreamVersion ?: 'current',
4242
'spring-pulsar-version': project.version,

0 commit comments

Comments
 (0)