Skip to content

Commit

Permalink
Simplify maven publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbrooks committed Sep 14, 2021
1 parent 343264f commit 156fb8b
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 209 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ jobs:
sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_KEY_RING_FILE'"
- name: Publish to MavenCentral
run: ./gradlew --max-workers 1 --no-daemon publishReleasePublicationToSonatypeRepository closeAndReleaseRepository
run: ./gradlew -Psigning.keyId=${{ secrets.SIGNING_KEY_ID}} -Psigning.password=${{ secrets.SIGNING_PASSWORD }} -P-Psigning.secretKeyRingFile=${{ secrets.SIGNING_KEY_FILE_PATH }} --no-parallel --no-daemon publishAllPublicationsToMavenCentralRepository closeAndReleaseRepository
env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_KEY_FILE_PATH: ${{ secrets.SIGNING_KEY_FILE_PATH }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
SONATYPE_PROFILE_ID: ${{ secrets.SONATYPE_PROFILE_ID }}
25 changes: 1 addition & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import io.codearte.gradle.nexus.NexusStagingExtension

buildscript {
repositories {
Expand All @@ -10,19 +9,11 @@ buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30")
classpath("org.jlleitschuh.gradle:ktlint-gradle:10.2.0")
classpath("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0")
classpath("com.vanniktech:gradle-maven-publish-plugin:0.18.0")
}
}

subprojects {
plugins.apply("org.jlleitschuh.gradle.ktlint")
extensions.configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version.set("0.42.1")
}

group = "com.jzbrooks"
version = properties["vgo_version"]?.toString() ?: ""

repositories {
mavenLocal()
mavenCentral()
Expand Down Expand Up @@ -63,17 +54,3 @@ subprojects {
})
}
}

ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_KEY_FILE_PATH")

apply(plugin = "io.codearte.nexus-staging")
configure<NexusStagingExtension> {
packageGroup = "com.jzbrooks"
stagingProfileId = System.getenv("SONATYPE_PROFILE_ID")
numberOfRetries = 60
delayBetweenRetriesInMillis = 30_000
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
19 changes: 17 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
vgo_version=2.0.2

org.gradle.jvmargs=-Xmx2g -XX:+UseParallelGC

GROUP=com.jzbrooks
VERSION_NAME=2.0.2

POM_URL=https://github.com/jzbrooks/vgo/

POM_LICENSE_NAME=MIT License
POM_LICENSE_URL=https://github.com/jzbrooks/vgo/blob/master/LICENSE

POM_SCM_URL=https://github.com/jzbrooks/vgo/tree/master
POM_SCM_CONNECTION=scm:git:git:github.com/jzbrooks/vgo.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com/jzbrooks/vgo.git

POM_DEVELOPER_ID=jzbrooks
POM_DEVELOPER_NAME=Justin Brooks
POM_DEVELOPER_URL=https://github.com/jzbrooks
POM_DEVELOPER_EMAIL[email protected]
59 changes: 2 additions & 57 deletions vgo-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("org.jlleitschuh.gradle.ktlint")
id("org.jetbrains.kotlin.jvm")
id("maven-publish")
id("signing")
id("com.vanniktech.maven.publish")
}

dependencies {
Expand All @@ -22,58 +22,3 @@ tasks {
from(this@tasks["javadoc"])
}
}

publishing {
publications {
create<MavenPublication>("release") {
artifactId = "vgo-core"

artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
from(components["kotlin"])

@Suppress("UnstableApiUsage")
pom {
name.set("vgo-core")
description.set("vgo-core is a library for optimizing vector artwork files.")
url.set("https://github.com/jzbrooks/vgo/")

licenses {
license {
name.set("MIT License")
url.set("https://github.com/jzbrooks/vgo/blob/master/LICENSE")
}
}

developers {
developer {
id.set("jzbrooks")
name.set("Justin Brooks")
email.set("[email protected]")
}
}

scm {
connection.set("scm:git:github.com/jzbrooks/vgo.git")
developerConnection.set("scm:git:ssh://github.com/jzbrooks/vgo.git")
url.set("https://github.com/jzbrooks/vgo/tree/master")
}
}
}
}

repositories {
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}
}

signing {
sign(publishing.publications)
}
3 changes: 3 additions & 0 deletions vgo-core/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_ARTIFACT_ID=vgo-core
POM_NAME=vgo-core
POM_DESCRIPTION=vgo-core is a library for optimizing vector artwork files.
59 changes: 2 additions & 57 deletions vgo-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id("org.jlleitschuh.gradle.ktlint")
id("org.jetbrains.kotlin.jvm")
id("java-gradle-plugin")
id("maven-publish")
id("signing")
id("com.vanniktech.maven.publish")
id("org.gradle.kotlin.kotlin-dsl") version "2.1.4"
}

Expand Down Expand Up @@ -35,58 +35,3 @@ tasks {
from(this@tasks["javadoc"])
}
}

publishing {
publications {
create<MavenPublication>("release") {
artifactId = "vgo-plugin"

artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
from(components["kotlin"])

@Suppress("UnstableApiUsage")
pom {
name.set("vgo-plugin")
description.set("vgo is a gradle plugin for optimizing vector artwork files that helps ensure a compact representation without compromising quality.")
url.set("https://github.com/jzbrooks/vgo/")

licenses {
license {
name.set("MIT License")
url.set("https://github.com/jzbrooks/vgo/blob/master/LICENSE")
}
}

developers {
developer {
id.set("jzbrooks")
name.set("Justin Brooks")
email.set("[email protected]")
}
}

scm {
connection.set("scm:git:github.com/jzbrooks/vgo.git")
developerConnection.set("scm:git:ssh://github.com/jzbrooks/vgo.git")
url.set("https://github.com/jzbrooks/vgo/tree/master")
}
}
}
}

repositories {
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}
}

signing {
sign(publishing.publications)
}
6 changes: 6 additions & 0 deletions vgo-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
POM_ARTIFACT_ID=vgo-plugin
POM_NAME=vgo-plugin
POM_DESCRIPTION=vgo is a gradle plugin for optimizing vector artwork files that helps ensure a compact representation without compromising quality.



69 changes: 7 additions & 62 deletions vgo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import java.nio.file.Files
import java.nio.file.Paths

plugins {
id("org.jlleitschuh.gradle.ktlint")
id("org.jetbrains.kotlin.jvm")
id("maven-publish")
id("signing")
id("com.vanniktech.maven.publish")
}

sourceSets {
Expand All @@ -33,10 +33,9 @@ tasks {

jar {
dependsOn(configurations.runtimeClasspath)

manifest {
attributes["Main-Class"] = "com.jzbrooks.vgo.Application"
attributes["Bundle-Version"] = project.version
attributes["Bundle-Version"] = project.properties["VERSION_NAME"]
}

val sourceClasses = sourceSets.main.get().output.classesDirs
Expand All @@ -59,6 +58,8 @@ tasks {
}

val generateConstants by registering {
finalizedBy("compileKotlin")

outputs.files("$projectDir/src/generated/kotlin/com/jzbrooks/BuildConstants.kt")

doLast {
Expand All @@ -72,13 +73,12 @@ tasks {
"""
|package com.jzbrooks
|
|object BuildConstants {
|internal object BuildConstants {
""".trimMargin()
)

val vgoProperties = project.properties
.filter { it.key.startsWith("vgo_") }
.mapKeys { it.key.removePrefix("vgo_") }
.filterKeys { it == "VERSION_NAME" }

for (property in vgoProperties) {
append(" const val ")
Expand Down Expand Up @@ -159,58 +159,3 @@ tasks {
from(this@tasks["javadoc"])
}
}

publishing {
publications {
create<MavenPublication>("release") {
artifactId = "vgo"

artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
from(components["kotlin"])

@Suppress("UnstableApiUsage")
pom {
name.set("vgo")
description.set("vgo is a tool for optimizing vector artwork files that helps ensure your vector artwork is represented compactly without compromising quality.")
url.set("https://github.com/jzbrooks/vgo/")

licenses {
license {
name.set("MIT License")
url.set("https://github.com/jzbrooks/vgo/blob/master/LICENSE")
}
}

developers {
developer {
id.set("jzbrooks")
name.set("Justin Brooks")
email.set("[email protected]")
}
}

scm {
connection.set("scm:git:github.com/jzbrooks/vgo.git")
developerConnection.set("scm:git:ssh://github.com/jzbrooks/vgo.git")
url.set("https://github.com/jzbrooks/vgo/tree/master")
}
}
}
}

repositories {
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}
}

signing {
sign(publishing.publications)
}
3 changes: 3 additions & 0 deletions vgo/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_ARTIFACT_ID=vgo
POM_NAME=vgo
POM_DESCRIPTION=vgo is a tool for optimizing vector artwork files that helps ensure your vector artwork is represented compactly without compromising quality.
2 changes: 1 addition & 1 deletion vgo/src/main/kotlin/com/jzbrooks/vgo/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Application {
}

if (argReader.readFlag("version|v")) {
println(BuildConstants.VERSION)
println(BuildConstants.VERSION_NAME)
return 0
}

Expand Down

0 comments on commit 156fb8b

Please sign in to comment.