[CI] Update boot version property at release time
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -40,7 +40,7 @@ jobs:
|
||||
version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
|
||||
echo "project_version=$version" >>$GITHUB_OUTPUT
|
||||
build_jdk_17:
|
||||
name: Build and Deploy Artifacts (JDK 17)
|
||||
name: Build (JDK 17)
|
||||
needs: [prerequisites]
|
||||
runs-on: ubuntu-latest
|
||||
if: needs.prerequisites.outputs.runjobs
|
||||
|
||||
13
.github/workflows/prepare-release.yml
vendored
13
.github/workflows/prepare-release.yml
vendored
@@ -7,7 +7,10 @@ on:
|
||||
description: 'Version to release'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
springBootVersion:
|
||||
description: 'Spring Boot Version (Delivery Vehicle)'
|
||||
required: true
|
||||
type: string
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -27,10 +30,7 @@ jobs:
|
||||
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
|
||||
|
||||
- name: Set up Gradle
|
||||
uses: spring-io/spring-gradle-build-action@v1
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
uses: spring-io/spring-gradle-build-action@v2
|
||||
|
||||
- id: check-open-issues
|
||||
name: Check for open issues
|
||||
@@ -54,9 +54,10 @@ jobs:
|
||||
git config user.name 'github-actions[bot]'
|
||||
git config user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
releaseVersion="${{ inputs.releaseVersion }}"
|
||||
springBootVersion="${{ inputs.springBootVersion }}"
|
||||
releaseBranch="release-initiate/$releaseVersion"
|
||||
git checkout -b $releaseBranch
|
||||
./gradlew :updateToReleaseVersion -PreleaseVersion=$releaseVersion
|
||||
./gradlew :updateToReleaseVersion -PreleaseVersion=$releaseVersion -PspringBootVersion=$springBootVersion
|
||||
git commit -am "[Release $releaseVersion] Update version"
|
||||
git push origin $releaseBranch
|
||||
gh pr create --title "[Release $releaseVersion] Update version" --body "Merge to initiate release."
|
||||
|
||||
@@ -26,6 +26,7 @@ public class UpdateProjectVersionPlugin implements Plugin<Project> {
|
||||
updateToReleaseVersionTask.setGroup("Release");
|
||||
updateToReleaseVersionTask.setDescription("Updates the project version to the next release in gradle.properties");
|
||||
updateToReleaseVersionTask.setReleaseVersion((String) project.findProperty("releaseVersion"));
|
||||
updateToReleaseVersionTask.setSpringBootVersion((String) project.findProperty("springBootVersion"));
|
||||
});
|
||||
project.getTasks().register("updateToSnapshotVersion", UpdateToSnapshotVersionTask.class, updateToSnapshotVersionTask -> {
|
||||
updateToSnapshotVersionTask.setGroup("Release");
|
||||
|
||||
@@ -17,25 +17,38 @@
|
||||
package org.springframework.pulsar.gradle.versions;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
public abstract class UpdateProjectVersionTask extends DefaultTask {
|
||||
|
||||
protected void updateVersionInGradleProperties(String newVersion) {
|
||||
String currentVersion = getProject().getVersion().toString();
|
||||
this.updatePropertyInGradleProperties("version", (p) -> p.getVersion().toString(), newVersion);
|
||||
}
|
||||
|
||||
protected void updatePropertyInGradleProperties(String propertyName, String newPropertyValue) {
|
||||
this.updatePropertyInGradleProperties(propertyName,
|
||||
(p) -> Objects.toString(p.findProperty(propertyName), ""), newPropertyValue);
|
||||
}
|
||||
|
||||
protected void updatePropertyInGradleProperties(
|
||||
String propertyName,
|
||||
Function<Project, String> currentPropertyValueFromProject,
|
||||
String newPropertyValue) {
|
||||
String currentPropertyValue = currentPropertyValueFromProject.apply(getProject());
|
||||
File gradlePropertiesFile = getProject().getRootProject().file(Project.GRADLE_PROPERTIES);
|
||||
if (!gradlePropertiesFile.exists()) {
|
||||
throw new RuntimeException("No gradle.properties to update version in");
|
||||
throw new RuntimeException("No gradle.properties to update property in");
|
||||
}
|
||||
System.out.printf("Updating the project version in %s from %s to %s%n",
|
||||
Project.GRADLE_PROPERTIES, currentVersion, newVersion);
|
||||
System.out.printf("Updating the %s property in %s from %s to %s%n",
|
||||
propertyName, Project.GRADLE_PROPERTIES, currentPropertyValue, newPropertyValue);
|
||||
FileUtils.replaceFileText(gradlePropertiesFile, (gradlePropertiesText) -> {
|
||||
gradlePropertiesText = gradlePropertiesText.replace(
|
||||
"version=" + currentVersion, "version=" + newVersion);
|
||||
"%s=%s".formatted(propertyName, currentPropertyValue),
|
||||
"%s=%s".formatted(propertyName, newPropertyValue));
|
||||
return gradlePropertiesText;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,9 +24,13 @@ public abstract class UpdateToReleaseVersionTask extends UpdateProjectVersionTas
|
||||
@Input
|
||||
private String releaseVersion;
|
||||
|
||||
@Input
|
||||
private String springBootVersion;
|
||||
|
||||
@TaskAction
|
||||
public void updateToReleaseVersion() {
|
||||
updateVersionInGradleProperties(this.releaseVersion);
|
||||
updatePropertyInGradleProperties("springBootVersionForDocs", this.springBootVersion);
|
||||
}
|
||||
|
||||
public String getReleaseVersion() {
|
||||
@@ -36,4 +40,12 @@ public abstract class UpdateToReleaseVersionTask extends UpdateProjectVersionTas
|
||||
public void setReleaseVersion(String releaseVersion) {
|
||||
this.releaseVersion = releaseVersion;
|
||||
}
|
||||
|
||||
public String getSpringBootVersion() {
|
||||
return springBootVersion;
|
||||
}
|
||||
|
||||
public void setSpringBootVersion(String springBootVersion) {
|
||||
this.springBootVersion = springBootVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ pulsarClientVersion=3.1.0
|
||||
pulsarClientReactiveVersion=0.4.0
|
||||
springFrameworkVersion=6.1.0-RC1
|
||||
|
||||
# only used by docs, tests, and samples (unpublished deps)
|
||||
# only used by integration tests and samples (unpublished deps)
|
||||
springBootVersion=3.2.0-SNAPSHOT
|
||||
|
||||
# only used for docs
|
||||
springBootVersionForDocs=3.2.0-SNAPSHOT
|
||||
|
||||
springCloudStreamVersion=4.1.0-SNAPSHOT
|
||||
|
||||
@@ -36,7 +36,7 @@ tasks.create('generateAntoraResources') {
|
||||
}
|
||||
|
||||
def generateAttributes() {
|
||||
return ['spring-boot-version': project.springBootVersion ?: 'current',
|
||||
return ['spring-boot-version': project.springBootVersionForDocs ?: 'current',
|
||||
'spring-framework-version': project.springFrameworkVersion ?: 'current',
|
||||
'spring-cloud-stream-version': project.springCloudStreamVersion ?: 'current',
|
||||
'spring-pulsar-version': project.version,
|
||||
|
||||
Reference in New Issue
Block a user