Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Fix prerelease property being incorrectly set on publish task (#75)
Browse files Browse the repository at this point in the history
## Description

When executing a final release for a WDK project the actual github release is marked as `prerelease`. 
This is due to the predicate not being fully correct.

## Changes
* ![FIX] ReleasePlugin: Github publish task prerelease predicate
* ![ADD] gradle-commons-test test library
  • Loading branch information
Azurelol authored Sep 2, 2021
1 parent a16777d commit 75654ba
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ dependencies {

testImplementation 'gradle.plugin.net.wooga.gradle:atlas-unity:2.0.0-rc.3'
testImplementation 'gradle.plugin.net.wooga.gradle:atlas-wdk-unity:2.0.0-rc.3'
testImplementation 'com.wooga.gradle:gradle-commons-test:(0, 1]'

implementation group: 'org.kohsuke', name: 'github-api', version: '1.130'
implementation 'org.ajoberstar.grgit:grgit-core:(4.1,5]'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package wooga.gradle.release

import com.wooga.gradle.test.PropertyQueryTaskWriter
import org.ajoberstar.grgit.Grgit
import org.gradle.api.Task
import org.gradle.api.specs.Spec
Expand Down Expand Up @@ -45,7 +46,6 @@ class ReleasePluginIntegrationSpec extends IntegrationSpec {
createFile("paket.dependencies")
}


// @Unroll("verify dependency setup to #testType unity sub-projects")
// def "verify dependency setup to unity sub-projects"() {
// given: "some subprojects with net.wooga.unity applied"
Expand Down Expand Up @@ -417,4 +417,30 @@ class ReleasePluginIntegrationSpec extends IntegrationSpec {
'0.3.0-a0000' | 300
'12.34.200-2334' | 123600
}

@Unroll("prerelease #expectedMessage when project status is #status")
def "prerelease property is set correctly on by the plugin"() {
given: "a buildfile with release plugin applied"
buildFile << """
${applyPlugin(ReleasePlugin)}
project.status = "${status}"
""".stripIndent()

when:
def query = new PropertyQueryTaskWriter("${GithubPublishPlugin.PUBLISH_TASK_NAME}.prerelease")
query.write(buildFile)
def result = runTasksSuccessfully(query.taskName)

then:
result.wasExecuted(query.taskName)
query.matches(result, isPrerelease)

where:
status | isPrerelease
"final" | false
"release" | false
"rc" | true

expectedMessage = isPrerelease ? "set" : "not set"
}
}
4 changes: 3 additions & 1 deletion src/main/groovy/wooga/gradle/release/ReleasePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ class ReleasePlugin implements Plugin<Project> {
githubPublishTask.dependsOn(archives)
githubPublishTask.tagName.set("v${project.version}")
githubPublishTask.releaseName.set(project.version.toString())
githubPublishTask.prerelease.set(project.provider { project.status != 'final' })
// Gradle defaults to 'release' for the project status, as seen here:
// https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html#getStatus--
githubPublishTask.prerelease.set(project.provider { project.status != 'final' && project.status != 'release' })

// Write the release description using the release notes generated by
// the release strategy
Expand Down

0 comments on commit 75654ba

Please sign in to comment.