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

Migrate to use com.vanniktech.maven.publish #201

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ jobs:
with:
fetch-depth: 0
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v3
uses: gradle/actions/wrapper-validation@v3
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
check-latest: true
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build
uses: gradle/gradle-build-action@v3
with:
arguments: build --info
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run: ./gradlew build --info
- name: Publish unit test results (Ubuntu)
uses: EnricoMi/publish-unit-test-result-action@v2
if: always() && matrix.os == 'ubuntu-latest'
Expand All @@ -40,14 +40,14 @@ jobs:
comment_mode: off
check_name: "Test Results (Ubuntu)"
- name: Publish unit test results (Windows)
uses: EnricoMi/publish-unit-test-result-action/composite@v2
uses: EnricoMi/publish-unit-test-result-action/windows@v2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if: always() && matrix.os == 'windows-latest'
with:
files: "**/test-results/**/*.xml"
comment_mode: off
check_name: "Test Results (Windows)"
- name: Publish unit test results (MacOS)
uses: EnricoMi/publish-unit-test-result-action/composite@v2
uses: EnricoMi/publish-unit-test-result-action/macos@v2
if: always() && matrix.os == 'macos-latest'
with:
files: "**/test-results/**/*.xml"
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ jobs:
with:
fetch-depth: 0
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v3
uses: gradle/actions/wrapper-validation@v3
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
check-latest: true
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Publish
uses: gradle/gradle-build-action@v3
with:
arguments: |
publishMainPublicationToSonatypeRepository
closeAndReleaseSonatypeStagingRepository
publishPlugins
-Dorg.gradle.internal.http.socketTimeout=120000
-Dorg.gradle.internal.network.retry.max.attempts=1
-Dorg.gradle.internal.publish.checksums.insecure=true
run: |
./gradlew
publishToMavenCentral
publishPlugins
--no-configuration-cache
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Dorg.gradle.internal.http.socketTimeout=120000
-Dorg.gradle.internal.network.retry.max.attempts=1
env:
OSSRH_USERNAME: ${{ secrets.SONATYPE_USER }}
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
PGP_KEY: ${{ secrets.GPG_KEY_ARMORED }}
PGP_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_ARMORED }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GRADLE_PORTAL_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PORTAL_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
47 changes: 45 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.gradle.publish.PublishTask.GRADLE_PUBLISH_KEY
import com.gradle.publish.PublishTask.GRADLE_PUBLISH_SECRET
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

repositories {
Expand All @@ -12,11 +13,10 @@ plugins {
alias(libs.plugins.pluginPublish)
alias(libs.plugins.spotless)
alias(libs.plugins.animalsniffer)
alias(libs.plugins.publishing)
alias(libs.plugins.mavenPublish)
}

group = "build.buf"
configurePublishing()

allprojects {
spotless {
Expand All @@ -38,6 +38,14 @@ dependencies {
testImplementation(libs.truth)
}

object ProjectInfo {
const val NAME = "Buf Gradle Plugin"
const val URL = "https://github.com/bufbuild/buf-gradle-plugin"
const val DESCRIPTION = "Buf plugin for Gradle"
}

fun isRelease() = !version.toString().endsWith("-SNAPSHOT")

gradlePlugin {
website.set(ProjectInfo.URL)
vcsUrl.set(ProjectInfo.URL)
Expand All @@ -61,7 +69,42 @@ kotlin {
}
}

mavenPublishing {
publishToMavenCentral(SonatypeHost.S01)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rubensf - This is what we would change if we wanted to publish to central instead of s01.

signAllPublications()
pom {
name.set(ProjectInfo.NAME)
description.set(ProjectInfo.DESCRIPTION)
url.set(ProjectInfo.URL)
scm {
url.set(ProjectInfo.URL)
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("Andrew Parmet")
name.set("Andrew Parmet")
email.set("[email protected]")
}
developer {
id.set("bufbuild")
name.set("Buf")
email.set("[email protected]")
url.set("https://buf.build")
organization.set("Buf Technologies, Inc.")
organizationUrl.set("https://buf.build")
}
}
}
}

tasks {
// Only enable publishing to the Gradle Portal for release builds.
named("publishPlugins") {
enabled = isRelease()
}
Expand Down
11 changes: 0 additions & 11 deletions buildSrc/build.gradle.kts

This file was deleted.

128 changes: 0 additions & 128 deletions buildSrc/src/main/kotlin/ConfigurePublishing.kt

This file was deleted.

4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# plugins
animalsniffer = "1.7.1"
kotlin = "1.9.24"
mavenPublish = "0.29.0"
pluginPublish = "1.2.1"
publishing = "0.29.0"
spotless = "6.25.0"

# signature
Expand All @@ -16,8 +16,8 @@ truth = "1.4.2"
[plugins]
animalsniffer = { id = "ru.vyarus.animalsniffer", version.ref = "animalsniffer" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
mavenPublish = { id = "com.vanniktech.maven.publish.base", version.ref = "mavenPublish" }
pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "pluginPublish" }
publishing = { id = "com.vanniktech.maven.publish.base", version.ref = "publishing" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }

[libraries]
Expand Down