Skip to content

Commit

Permalink
GitHub workflow to publish the relocated artifacts (#2318)
Browse files Browse the repository at this point in the history
Revert publish workflow to "Maven" Publication only. Use a separate GitHub workflow to publish the relocated artifacts
  • Loading branch information
paul-dingemans authored Oct 14, 2023
1 parent d107daa commit 53c5280
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: ./.github/actions/setup-gradle-build

- name: Build executable and publish to Maven
run: ./gradlew clean shadowJarExecutable publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache
run: ./gradlew clean shadowJarExecutable publishMavenPublicationToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache
env:
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/publish-relocations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish snapshot build

on: [ workflow_dispatch ]

env:
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEYID }}
ORG_GRADLE_PROJECT_signingKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}

jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'pinterest/ktlint'
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4

- uses: ./.github/actions/setup-gradle-build

- name: Publish relocated artifacts to Maven
run: ./gradlew clean publishRelocation-ktlint-cliPublicationToMavenCentralRelocationRepository publishRelocation-ktlint-cli-reporter-baselinePublicationToMavenCentralRelocationRepository publishRelocation-ktlint-cli-reporter-checkstylePublicationToMavenCentralRelocationRepository publishRelocation-ktlint-cli-reporter-corePublicationToMavenCentralRelocationRepository publishRelocation-ktlint-cli-reporter-htmlPublicationToMavenCentralRelocationRepository publishRelocation-ktlint-cli-reporter-jsonPublicationToMavenCentralRelocationRepository publishRelocation-ktlint-cli-reporter-plain-summaryPublicationToMavenCentralRelocationRepository publishRelocation-ktlint-cli-reporter-plainPublicationToMavenCentralRelocationRepository publishRelocation-ktlint-cli-reporter-sarifPublicationToMavenCentralRelocationRepository publishRelocation-ktlint-cliPublicationToMavenCentralRelocationRepository --no-daemon --no-parallel --no-configuration-cache
2 changes: 1 addition & 1 deletion .github/workflows/publish-snapshot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: ./.github/actions/setup-gradle-build

- name: Publish snapshot to Maven
run: ./gradlew clean publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache
run: ./gradlew clean publishMavenPublicationToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache

- name: Publish Kotlin-dev snapshot to Maven
run: ./gradlew -PkotlinDev clean publishMavenPublicationToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache
14 changes: 14 additions & 0 deletions build-logic/src/main/kotlin/ktlint-publication.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ publishing {
name = "mavenCentral"
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl

logger.lifecycle("Set publication repository for version $version to $url")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}

maven {
name = "mavenCentralRelocation"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
Expand Down
16 changes: 0 additions & 16 deletions ktlint-cli-reporter-baseline/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

plugins {
id("ktlint-publication-library")
}
Expand Down Expand Up @@ -52,20 +50,6 @@ publishing {
message.set("artifactId has been changed")
}
}

repositories {
maven {
name = "mavenCentral"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions ktlint-cli-reporter-checkstyle/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

plugins {
id("ktlint-publication-library")
}
Expand Down Expand Up @@ -50,20 +48,6 @@ publishing {
message.set("artifactId has been changed")
}
}

repositories {
maven {
name = "mavenCentral"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions ktlint-cli-reporter-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

plugins {
id("ktlint-publication-library")
}
Expand Down Expand Up @@ -44,20 +42,6 @@ publishing {
message.set("artifactId has been changed")
}
}

repositories {
maven {
name = "mavenCentral"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions ktlint-cli-reporter-html/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

plugins {
id("ktlint-publication-library")
}
Expand Down Expand Up @@ -50,20 +48,6 @@ publishing {
message.set("artifactId has been changed")
}
}

repositories {
maven {
name = "mavenCentral"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions ktlint-cli-reporter-json/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

plugins {
id("ktlint-publication-library")
}
Expand Down Expand Up @@ -50,20 +48,6 @@ publishing {
message.set("artifactId has been changed")
}
}

repositories {
maven {
name = "mavenCentral"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions ktlint-cli-reporter-plain-summary/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

plugins {
id("ktlint-publication-library")
}
Expand Down Expand Up @@ -50,20 +48,6 @@ publishing {
message.set("artifactId has been changed")
}
}

repositories {
maven {
name = "mavenCentral"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions ktlint-cli-reporter-plain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

plugins {
id("ktlint-publication-library")
}
Expand Down Expand Up @@ -50,20 +48,6 @@ publishing {
message.set("artifactId has been changed")
}
}

repositories {
maven {
name = "mavenCentral"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions ktlint-cli-reporter-sarif/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

plugins {
id("ktlint-publication-library")
}
Expand Down Expand Up @@ -51,20 +49,6 @@ publishing {
message.set("artifactId has been changed")
}
}

repositories {
maven {
name = "mavenCentral"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
}
}
Expand Down
19 changes: 0 additions & 19 deletions ktlint-cli/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.gradle.crypto.checksum.Checksum
import java.net.URI

plugins {
id("ktlint-publication-library")
Expand Down Expand Up @@ -215,31 +214,13 @@ publishing {
message.set("groupId and artifactId have been changed")
}
}

repositories {
maven {
name = "mavenCentral"
url = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")

logger.lifecycle("Create relocation pom.xml for ktlint-cli and upload to $url")

credentials {
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
?: System.getenv("SONATYPE_NEXUS_USERNAME")
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
}
}
}
}
}
}
}

// TODO: Remove in release after ktlint 1.0.1
signing {
logger.lifecycle("Sign relocation pom.xml for ktlint-cli")

// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
// useGpgCmd()
Expand Down

0 comments on commit 53c5280

Please sign in to comment.