From 036003140843d0369e15f041dddeda9aa8f47c8f Mon Sep 17 00:00:00 2001 From: Will Sargent Date: Sun, 20 Jun 2021 20:44:59 -0700 Subject: [PATCH] Fix maven publish --- RELEASING.md | 65 ++++++++++++++++++++++-- build.gradle | 9 +++- gradle.properties | 23 --------- gradle/release.gradle | 19 ------- gradle/shipkit.gradle | 33 ------------ gradle/wrapper/gradle-wrapper.properties | 2 +- version.properties | 3 +- 7 files changed, 70 insertions(+), 84 deletions(-) delete mode 100644 gradle/shipkit.gradle diff --git a/RELEASING.md b/RELEASING.md index 82192315..3d143d4a 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -12,18 +12,75 @@ To format everything using [Spotless](https://github.com/diffplug/spotless/tree/ ./gradlew spotlessApply ``` -Releases are handled using [shipkit](https://github.com/mockito/shipkit): +First, try publishing to maven local: ```bash -./gradlew testRelease +./gradlew publishToMavenLocal ``` -And then to run the release, which will increment the version number in `version.properties`: +If that works, then publish to Sonatype's staging repository and close: ```bash -./gradlew performRelease +./gradlew publishToSonatype closeSonatypeStagingRepository ``` +Inspect this in Sonatype OHSSH repository. Delete the staging repository after inspection. + +And then to promote it: + +```bash +./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository +``` + +If it looks weird that you have to specify "publishToSonatype" with another task, that's because [it is weird](https://github.com/gradle-nexus/publish-plugin/issues/19). + +## Gradle Signing + +If you run into errors with signing doing a `publishToSonaType`, this is common and underdocumented. + +``` +No value has been specified for property 'signatory.keyId'. +``` + +For the `signatory.keyId` error message, you need to set `signing.gnupg.keyName` if you +are using GPG 2.1 and a Yubikey 4. + +https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials +https://github.com/gradle/gradle/pull/1703/files#diff-6c52391bbdceb4cca64ce7b03e78212fR6 + +Note you need to use `gpg -K` and pick only the LAST EIGHT CHARS of the public signing key. + +> signing.gnupg.keyName = 5F798D53 + +### PinEntry + +Also note that if you are using a Yubikey, it'll require you to type in a PIN, which screws up Gradle. + +``` +gpg: signing failed: No pinentry +``` + +So you need to use pinentry-mode loopback, which is helpfully supplied by passphrase. + +- https://github.com/sbt/sbt-pgp/pull/142 +- https://wiki.archlinux.org/index.php/GnuPG#Unattended_passphrase +- https://github.com/gradle/gradle/pull/1703/files#diff-790036df959521791fdafe474b673924 + +You want this specified only the command line, i.e. + +> $ HISTCONTROL=ignoreboth ./gradlew publishToMavenLocal -Psigning.gnupg.passphrase=$PGP_PASSPHRASE --info + +### Cannot Allocate Memory + +gpg can't be run in parallel. You'll get this error message. + +``` +gpg: signing failed: Cannot allocate memory +``` +[Gradle is not smart enough to disable this](https://github.com/gradle/gradle/issues/12167). + +Do not use `-Porg.gradle.parallel=false` and don't use `--parallel` when publishing. + ## Documentation Documentation is done with [gradle-mkdocs-plugin](https://xvik.github.io/gradle-mkdocs-plugin/2.1.1/) and works best on Linux. diff --git a/build.gradle b/build.gradle index a329a85e..d4aa8621 100644 --- a/build.gradle +++ b/build.gradle @@ -10,13 +10,16 @@ */ plugins { id 'java' - id "org.shipkit.java" version "2.2.6" id "com.github.hierynomus.license" version "0.15.0" id 'com.diffplug.gradle.spotless' version '3.24.3' id 'ru.vyarus.mkdocs' version '2.1.1' + id "io.github.gradle-nexus.publish-plugin" version "1.1.0" + id "org.shipkit.shipkit-auto-version" version "1.1.19" //id 'org.inferred.processors' version '2.3.0' } +apply from: "gradle/release.gradle" + mkdocs { sourcesDir = projectDir strict = true @@ -32,11 +35,13 @@ spotless { allprojects { repositories { - jcenter() mavenCentral() } } +// Root project shouldn't publish +tasks.withType(PublishToMavenRepository).configureEach { it.enabled = false } + subprojects { subproj -> apply plugin: 'java' apply plugin: 'com.diffplug.gradle.spotless' diff --git a/gradle.properties b/gradle.properties index 19cb8e18..3c2ea482 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,11 +9,8 @@ # http://creativecommons.org/publicdomain/zero/1.0/ # -version = 0.0.0 group = com.tersesystems.logback -artifactIdMaven = logback-core -org.gradle.parallel=true org.gradle.caching=true # Set to true to attach a debugger @@ -22,26 +19,6 @@ org.gradle.debug=false # Set the memory size of the daemon to be higher because animalsniffer needs it. #org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -# For the `signatory.keyId` error message, you need to set `signing.gnupg.keyName` if you -# are using GPG 2.1 and a Yubikey 4. -# -# https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials -# https://github.com/gradle/gradle/pull/1703/files#diff-6c52391bbdceb4cca64ce7b03e78212fR6 -# -# Note you need to use `gpg -K` and pick only the LAST EIGHT CHARS of the public signing key. -#signing.gnupg.keyName = D66D1D69 - -# Also note that if you are using a Yubikey, it'll require you to type in a PIN, which screws up Gradle. -# So you need to use pinentry-mode loopback, which is helpfully supplied by passphrase. -# -# https://github.com/sbt/sbt-pgp/pull/142 -# https://wiki.archlinux.org/index.php/GnuPG#Unattended_passphrase -# https://github.com/gradle/gradle/pull/1703/files#diff-790036df959521791fdafe474b673924 -# -# You want this specified only the command line, i.e. -# $ HISTCONTROL=ignoreboth ./gradlew clean sign -Psigning.gnupg.passphrase=123456 --info -# signing.gnupg.passphrase = [CENSORED] - bytebuddyVersion = 1.10.8 junitVersion = 4.12 junitJupiterVersion = 5.0.1 diff --git a/gradle/release.gradle b/gradle/release.gradle index 3f06d712..06d21dde 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -1,22 +1,3 @@ -//Plugin jars are added to the buildscript classpath in the root build.gradle file -apply plugin: "org.shipkit.shipkit-auto-version" -apply plugin: "org.shipkit.shipkit-changelog" - -tasks.named("generateChangelog") { - previousRevision = project.ext.'shipkit-auto-version.previous-tag' - githubToken = System.getenv("GH_WRITE_TOKEN") - repository = "tersesystems/terse-logback" -} - -apply plugin: "org.shipkit.shipkit-github-release" -tasks.named("githubRelease") { - dependsOn tasks.named("generateChangelog") - repository = "tersesystems/terse-logback" - changelog = tasks.named("generateChangelog").get().outputFile - githubToken = System.getenv("GH_WRITE_TOKEN") - newTagRevision = System.getenv("GITHUB_SHA") -} - apply plugin: "io.github.gradle-nexus.publish-plugin" //https://github.com/gradle-nexus/publish-plugin/ nexusPublishing { repositories { diff --git a/gradle/shipkit.gradle b/gradle/shipkit.gradle deleted file mode 100644 index 5170363d..00000000 --- a/gradle/shipkit.gradle +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SPDX-License-Identifier: CC0-1.0 - * - * Copyright 2018-2020 Will Sargent. - * - * Licensed under the CC0 Public Domain Dedication; - * You may obtain a copy of the License at - * - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -shipkit { - gitHub.repository = "tersesystems/terse-logback" - gitHub.readOnlyAuthToken = "f602321e7bdca17438b3ea4b8473c7b1662e7d2b" - gitHub.writeAuthToken = System.getenv("GH_WRITE_TOKEN") -} - -allprojects { - plugins.withId("org.shipkit.bintray") { - bintray { - key = System.getenv("BINTRAY_API_KEY") - - pkg { - repo = 'maven' - user = 'wsargent' - userOrg = 'tersesystems' - name = 'terse-logback' - licenses = ['CC0'] - labels = ['logback', 'slf4j' ] - } - } - } -} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 746141d6..91355f43 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -10,7 +10,7 @@ # #Fri Mar 06 17:39:40 PST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/version.properties b/version.properties index 66e51ad4..375f61ff 100644 --- a/version.properties +++ b/version.properties @@ -11,6 +11,5 @@ #Version of the produced binaries. This file is intended to be checked-in. #It will be automatically bumped by release automation. -version=0.17.0 -previousVersion=0.16.2 +version=1.0.*