Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new GitHub Actions API for setting output #290

Merged
merged 2 commits into from
Jan 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[chore] Use new GHA API for setting output
  • Loading branch information
violetagg committed Jan 18, 2023
commit 09e5a5151c49bb0105b1f761fa9a163b9bcef4cb
29 changes: 26 additions & 3 deletions gradle/setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,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")

println "::set-output name=versionType::$versionType"
println "::set-output name=fullVersion::$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"

//only output the versionType and fullVersion for the main artifact
if (project.name == 'reactor-adapter') {
outputToGha(versionType, version)
}
}
}

Expand Down