Skip to content

Commit

Permalink
Avoid publishing final releases when --validate-plugin is used
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Apr 7, 2023
1 parent 9205fd4 commit 12f01df
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/nebula.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ jobs:
- ${{ runner.os }}-gradlewrapper-
- name: Verify plugin publication
if: |
startsWith(github.ref, 'refs/tags/v')
startsWith(github.ref, 'refs/tags/v') &&
(!contains(github.ref, '-rc.'))
run: ./gradlew --stacktrace -Dgradle.publish.key=${{ secrets.gradlePublishKey }} -Dgradle.publish.secret=${{ secrets.gradlePublishSecret }} publishPlugins --validate-only -x signPluginMavenPublication -x check
publish:
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repositories {
}

dependencies {
compileOnly 'io.github.gradle-nexus:publish-plugin:1.0.0'
implementation 'com.netflix.nebula:nebula-oss-publishing-plugin:latest.release'
implementation 'com.netflix.nebula:gradle-contacts-plugin:latest.release'
implementation 'com.netflix.nebula:gradle-dependency-lock-plugin:latest.release'
Expand Down
2 changes: 1 addition & 1 deletion gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ commons-lang:commons-lang:2.4=integTestRuntimeClasspath,runtimeClasspath,testRun
commons-logging:commons-logging:1.2=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
de.regnis.q.sequence:sequence-library:1.0.3=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.2=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.github.gradle-nexus:publish-plugin:1.0.0=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
io.github.gradle-nexus:publish-plugin:1.0.0=compileClasspath,integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
joda-time:joda-time:2.10=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
junit:junit:4.12=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
net.java.dev.jna:jna-platform:5.7.0=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
Expand Down
28 changes: 25 additions & 3 deletions src/main/groovy/nebula/plugin/plugin/NebulaPluginPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
*/
package nebula.plugin.plugin

import io.github.gradlenexus.publishplugin.AbstractNexusStagingRepositoryTask
import nebula.plugin.publishing.NebulaOssPublishingExtension
import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.invocation.Gradle
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory
Expand Down Expand Up @@ -63,6 +65,7 @@ class NebulaPluginPlugin implements Plugin<Project> {
static final PLUGIN_IDS = GRADLE_PLUGIN_IDS + THIRDPARTY_PLUGIN_IDS + NEBULA_PLUGIN_IDS

private final ProviderFactory providers
private boolean isPluginPublishingValidation

@Inject
NebulaPluginPlugin(ProviderFactory providerFactory) {
Expand All @@ -71,6 +74,7 @@ class NebulaPluginPlugin implements Plugin<Project> {

@Override
void apply(Project project) {
this.isPluginPublishingValidation = project.gradle.startParameter.taskNames.contains('--validate-only')
project.with {
def nebulaOssPublishingExtension = project.rootProject.extensions.findByType(NebulaOssPublishingExtension) ?: project.rootProject.extensions.create("nebulaOssPublishing", NebulaOssPublishingExtension)
nebulaOssPublishingExtension.packageGroup.set("com.netflix")
Expand Down Expand Up @@ -174,7 +178,7 @@ class NebulaPluginPlugin implements Plugin<Project> {

gradle.taskGraph.whenReady { graph ->
tasks.publishPlugins.onlyIf {
graph.hasTask(':final') || gradle.startParameter.taskNames.contains('--validate-only')
graph.hasTask(':final') || isPluginPublishingValidation
}
}
}
Expand Down Expand Up @@ -215,10 +219,28 @@ class NebulaPluginPlugin implements Plugin<Project> {
}


project.tasks.withType(Sign).configureEach {
it.mustRunAfter(validatePluginsTask, project.tasks.named('check'))
/**
* Configure signing unless it is plugin validation
*/
if (!isPluginPublishingValidation) {
project.tasks.withType(Sign).configureEach {
it.mustRunAfter(validatePluginsTask, project.tasks.named('check'))
}
}

/**
* Disable publishing to maven repositories when running --validate-only
*/
if (isPluginPublishingValidation) {
project.tasks.withType(PublishToMavenRepository).configureEach {
it.enabled = false
}
project.tasks.withType(AbstractNexusStagingRepositoryTask).configureEach {
it.enabled = false
}
}
}

}

private void disableGradleModuleMetadataTask(Project project) {
Expand Down

0 comments on commit 12f01df

Please sign in to comment.