Skip to content

Commit

Permalink
[chore] Use new GHA API for setting output
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Jan 6, 2023
1 parent 63050d6 commit 2844ccd
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions gradle/setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,39 @@ static def qualifyVersion(String v) {
return "BAD"
}

static def outputToGha(String versionType, String fullVersion) {
def ghaFilename = System.getenv("GITHUB_OUTPUT")
if (ghaFilename == null) {
println "::set-output name=versionType::$versionType"
println "::set-output name=fullVersion::$fullVersion"
}
else {
println "using GITHUB_OUTPUT file"
def ghaFile = new File(ghaFilename)
ghaFile.withWriterAppend {
it.newLine()
it.append("versionType=$versionType")
it.newLine()
it.append("fullVersion=$fullVersion")
}
}
}

task qualifyVersionGha() {
doLast {
def versionType = qualifyVersion("$version")
//we ensure that if at least _one_ submodule version is BAD, we only output versionType=BAD + job fails
if (versionType == "BAD") {
outputToGha(versionType, version)
println "::error ::Unable to parse $version to a VersionNumber with recognizable qualifier"
throw new TaskExecutionException(tasks.getByName("qualifyVersionGha"), new IllegalArgumentException("Unable to parse $version to a VersionNumber with recognizable qualifier"))
}
println "Recognized $version as $versionType"

if (project.name != 'reactor-netty') {
return
//only output the versionType and fullVersion for the main artifact
if (project.name == 'reactor-netty') {
outputToGha(versionType, version)
}
println "::set-output name=versionType::$versionType"
println "::set-output name=fullVersion::$version"
}
}

Expand Down

0 comments on commit 2844ccd

Please sign in to comment.