Skip to content

Commit 3431796

Browse files
committed
fix(release): add automatic git commit to updateCff Gradle task
This ensures the version number in releases will be up-to-date.
1 parent 2bf6291 commit 3431796

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

gradle/updateCff.gradle

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import java.time.format.DateTimeFormatter
2929

3030
tasks.register('updateCff') {
3131
group = 'release'
32-
description = 'Updates the version in CITATION.cff file'
32+
description = 'Updates the version in CITATION.cff file and commits the change'
3333

3434
inputs.file("CITATION.cff")
3535
outputs.file("CITATION.cff")
@@ -61,6 +61,30 @@ tasks.register('updateCff') {
6161

6262
cffFile.text = content
6363
println "Updated CITATION.cff to version ${version} and date-released ${today}"
64+
65+
// Commit the change to git
66+
println "Committing CITATION.cff to git..."
67+
68+
// Helper function to run git commands
69+
def runGitCommand = { List<String> command ->
70+
def process = new ProcessBuilder(command)
71+
.directory(project.rootDir)
72+
.inheritIO()
73+
.start()
74+
def exitCode = process.waitFor()
75+
if (exitCode != 0) {
76+
throw new GradleException("Git command failed: ${command.join(' ')} (exit code: ${exitCode})")
77+
}
78+
return exitCode
79+
}
80+
81+
// Stage the file
82+
runGitCommand(['git', 'add', 'CITATION.cff'])
83+
84+
// Commit the change
85+
runGitCommand(['git', 'commit', '-m', "Update CITATION.cff to version ${version}"])
86+
87+
println "Successfully committed CITATION.cff"
6488
}
6589
}
6690

0 commit comments

Comments
 (0)