Skip to content

Commit

Permalink
build: replace 'bumpVersion' with extended 'versionAsSpecified'
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Jan 15, 2025
1 parent 26c8408 commit 810dbd6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-automation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
# run: ./gradlew release -Pversion=${{ env.VERSION }}

- name: Bump Version
run: ./gradlew bumpVersion -PnewVersion=${{ env.VERSION }}
run: ./gradlew versionAsSpecified -PnewVersion=${{ env.VERSION }}

- name: Close the Milestone
if: ${{ steps.version_parser.outputs.prerelease == '' }}
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
git reset --hard $RELEASE_BRANCH
- name: Gradle Release for Next Minor Snapshot
run: ./gradlew bumpVersion -PnewVersion=${{ env.NEXT_VERSION_SNAPSHOT }}
run: ./gradlew versionAsSpecified -PnewVersion=${{ env.NEXT_VERSION_SNAPSHOT }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
Expand Down
18 changes: 18 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: Apache-2.0
import net.swiftzer.semver.SemVer

tasks.versionAsSpecified {
val chartFile =
fileTree(rootDir) {
include("charts/**/Chart.yaml")
exclude("**/node_modules/")
}
doLast {
val newVersion = SemVer.parse(inputs.properties["newVersion"] as String).toString()
chartFile.forEach { file ->
val yaml = file.readText()
val oldVersion = Regex("(?<=^(appVersion|version): ).+", RegexOption.MULTILINE)
file.writeText(yaml.replace(oldVersion, newVersion))
}
}
}
26 changes: 0 additions & 26 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,6 @@ testModuleInfo {
requiresStatic("com.github.spotbugs.annotations")
}

// Release related tasks

fun replaceVersion(files: String, match: String, newVersion: String) {
ant.withGroovyBuilder {
"replaceregexp"("match" to match, "replace" to newVersion, "flags" to "gm") {
"fileset"(
"dir" to rootProject.projectDir,
"includes" to files,
"excludes" to "**/node_modules/"
)
}
}
}

tasks.register("bumpVersion") {
description = "Bump versions of the project"
group = "release"

val newVersion =
project.findProperty("newVersion") as String?
?: throw GradleException("Please provide -PnewVersion=<version>")

replaceVersion("charts/**/Chart.yaml", "(?<=^(appVersion|version): ).+", newVersion)
replaceVersion("version.txt", ".+", newVersion)
}

// Vals
val dockerProjectRootDirectory: Directory = layout.projectDirectory.dir("docker")
val dockerBuildRootDirectory: Directory = layout.buildDirectory.dir("docker").get()
Expand Down

0 comments on commit 810dbd6

Please sign in to comment.