Skip to content

Commit e819456

Browse files
committed
chore(ci): add logic to auto-bump release-number on release
1 parent cf72173 commit e819456

3 files changed

Lines changed: 52 additions & 7 deletions

File tree

build-logic/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies {
2020
implementation 'com.gradleup.shadow:shadow-gradle-plugin:8.3.6'
2121
implementation 'org.graalvm.buildtools:native-gradle-plugin:0.10.5'
2222
implementation libs.bundles.spotless.libs
23+
implementation libs.spotless.plugin.gradle
2324
}
2425

2526
spotless {

build-logic/src/main/groovy/buildlogic.spotless-markdown-conventions.gradle

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,65 @@
11
import com.diffplug.spotless.cli.picocli.usage.DocumentedUsages
2+
import com.diffplug.gradle.spotless.FreshMarkExtension
3+
import com.oracle.svm.core.annotate.Inject
24

35
plugins {
46
id 'buildlogic.spotless-common-conventions'
7+
id 'com.diffplug.spotless-changelog'
58
}
69

10+
Action<FreshMarkExtension> freshmarkSetup = new Action<FreshMarkExtension>(){
11+
12+
void execute(FreshMarkExtension freshmark) {
13+
freshmark.target '*.md'
14+
freshmark.properties(new FreshmarkPropertiesAction(rootProject, project))
15+
freshmark.properties {
16+
it.put('changeThisValueToForceCacheMiss', '1f31705c-b1c6-4bce-9831-98881431b721')
17+
}
18+
freshmark.prettier() // prettier for markdown formatting
19+
freshmark.endWithNewline()
20+
}
21+
}
22+
723
spotless {
824
freshmark {
925
// freshmark for keeping markdown files up to date
10-
target '*.md'
11-
// provide lib versions to freshmark
12-
properties(new FreshmarkPropertiesAction(rootProject, project))
13-
properties {
14-
it.put('changeThisValueToForceCacheMiss', '1f31705c-b1c6-4bce-9831-98881431b721')
26+
freshmarkSetup.execute(it)
27+
}
28+
}
29+
30+
interface MarkdownProjInjections {
31+
@javax.inject.Inject
32+
ExecOperations getExecOperations()
33+
}
34+
35+
// if this freshmark has a changelog file, then it has version-sensitive content
36+
if (tasks.names.contains('changelogCheck')) {
37+
// create a freshmark apply task manually
38+
FreshMarkExtension freshmark = new FreshMarkExtension(spotless)
39+
freshmarkSetup.execute(freshmark)
40+
// override version for this task, we want to use versionNext because versionLast is bumped after evaluation, so peek ahead
41+
freshmark.properties {
42+
it.put('spotlessVersion', rootProject.spotlessChangelog.versionNext)
43+
}
44+
def changelogBumpFreshmark = freshmark.createIndependentApplyTask('changelogBumpFreshmark')
45+
// freshmark should run after the changelog bump
46+
changelogBumpFreshmark.dependsOn tasks.named('changelogBump')
47+
48+
def changelogBumpFreshmarkGitAdd = tasks.register('changelogBumpFreshmarkGitAdd') {
49+
def execOps = project.objects.newInstance(MarkdownProjInjections).execOperations
50+
// this git add should run after the freshmark
51+
dependsOn(changelogBumpFreshmark)
52+
// do the git add
53+
doLast {
54+
execOps.exec { commandLine 'git', 'add' , '*.md' }
1555
}
16-
prettier() // prettier for markdown formatting
17-
endWithNewline()
56+
}
57+
tasks.named('changelogPush').configure {
58+
dependsOn changelogBumpFreshmarkGitAdd
1859
}
1960
}
2061

62+
2163
class FreshmarkPropertiesAction implements Action<Map<String, Object>> {
2264

2365
private final Project rootProject

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ picocli = "4.7.6"
1111
selfie = "2.5.1"
1212
slf4j = "2.0.17"
1313
spotless-lib = "3.1.0"
14+
spotless-plugin-gradle = "7.0.2"
1415

1516
[libraries]
1617
annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" }
@@ -31,6 +32,7 @@ slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
3132
slf4j-binding = { module = "org.slf4j:slf4j-jdk14", version.ref = "slf4j" }
3233
spotless-lib = { module = "com.diffplug.spotless:spotless-lib", version.ref = "spotless-lib" }
3334
spotless-lib-extra = { module = "com.diffplug.spotless:spotless-lib-extra", version.ref = "spotless-lib" }
35+
spotless-plugin-gradle = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless-plugin-gradle" }
3436

3537
[bundles]
3638
durian-libs = ["durian-core", "durian-io", "durian-collect"]

0 commit comments

Comments
 (0)