From 3256f5336d46afd9a2524b12e8e4a9480a604b22 Mon Sep 17 00:00:00 2001 From: Jeroen van Erp Date: Tue, 12 Oct 2021 11:16:51 +0200 Subject: [PATCH] Update builds and release pipeline --- .github/workflows/gradle.yml | 13 -- .github/workflows/release.yml | 49 +++++++ build.gradle | 170 ++++++++++++----------- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 142 insertions(+), 92 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a7e9def0a..fbda90de5 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -24,19 +24,6 @@ jobs: run: chmod +x gradlew - name: Build with Gradle run: ./gradlew check - # java10: - # name: Build with Java 10 - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # - name: Set up JDK 10 - # uses: actions/setup-java@v1 - # with: - # java-version: 10 - # - name: Grant execute permission for gradlew - # run: chmod +x gradlew - # - name: Build with Gradle - # run: ./gradlew check -xanimalsnifferMain -xanimalsnifferTest integration: name: Integration test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..84c9d4688 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: SSHJ Release + +on: + push: + tags: + - '*' + +permissions: + contents: write + +jobs: + java12: + name: Build with Java 12 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up JDK 12 + uses: actions/setup-java@v1 + with: + java-version: 12 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew check + release: + name: Release + needs: [java12] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-java@v1 + with: + java-version: 12 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Release + run: ./gradlew release -Prelease.disableChecks -Prelease.pushTagsOnly -Prelease.customUsername=${{ github.actor }} -Prelease.customPassword=${{ github.token }} + env: + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNINGKEY }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNINGKEYID }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNINGPASSWORD }} + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_PASSWORD }} + + diff --git a/build.gradle b/build.gradle index 7924ea687..5e0596c0e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,18 +6,22 @@ plugins { id "java" id "groovy" id "jacoco" - id "com.github.blindpirate.osgi" version '0.0.3' + id "com.github.blindpirate.osgi" version '0.0.6' id "maven-publish" - id 'pl.allegro.tech.build.axion-release' version '1.11.0' - id "com.bmuschko.docker-remote-api" version "6.4.0" - id "com.github.hierynomus.license" version "0.12.1" - id "com.jfrog.bintray" version "1.8.5" - id 'ru.vyarus.java-lib' version '1.0.5' - // id 'ru.vyarus.pom' version '1.0.3' - id 'ru.vyarus.github-info' version '1.1.0' + id "signing" + id 'pl.allegro.tech.build.axion-release' version '1.13.3' + id "com.bmuschko.docker-remote-api" version "7.1.0" + id "com.github.hierynomus.license" version "0.16.1" + id 'ru.vyarus.github-info' version '1.2.0' + id "io.github.gradle-nexus.publish-plugin" version "1.0.0" +} + +repositories { + mavenCentral() } group = "com.hierynomus" +defaultTasks ["build"] ext.moduleName = "${project.group}.${project.name}" scmVersion { @@ -33,13 +37,7 @@ scmVersion { project.version = scmVersion.version -defaultTasks "build" - -repositories { - mavenCentral() -} - -configurations.compile.transitive = false +configurations.implementation.transitive = false def bouncycastleVersion = "1.69" def sshdVersion = "2.1.0" @@ -85,7 +83,6 @@ if (JavaVersion.current().isJava8Compatible()) { } } - compileJava { options.compilerArgs.addAll(['--release', '7']) } @@ -123,6 +120,12 @@ jar { } } + +java { + withJavadocJar() + withSourcesJar() +} + sourcesJar { manifest { attributes( @@ -188,71 +191,82 @@ github { license 'Apache' } -pom { - description "SSHv2 library for Java" - url "https://github.com/hierynomus/sshj" - inceptionYear "2009" - developers { - developer { - id "hierynomus" - name "Jeroen van Erp" - email "jeroen@javadude.nl" - roles { - role "Lead developer" - } - } - developer { - id "shikhar" - name "Shikhar Bhushan" - email "shikhar@schmizz.net" - url "http://schmizz.net" - roles { - role "Previous lead developer" - } - } - developer { - id "iterate" - name "David Kocher" - email "dkocher@iterate.ch" - organization "iterage GmbH" - organizationUrl "https://iterate.ch" - roles { - role "Developer" - } - } - } +publishing { + publications { + maven(MavenPublication) { + from(components.java) + } + } } -if (project.hasProperty("bintrayUsername") && project.hasProperty("bintrayApiKey")) { - bintray { - user = project.property("bintrayUsername") - key = project.property("bintrayApiKey") - publish = true - publications = ["maven"] - pkg { - repo = "maven" - name = "${project.name}" - licenses = ["Apache-2.0"] - vcsUrl = "https://github.com/hierynomus/sshj.git" - labels = ["ssh", "sftp", "secure-shell", "network", "file-transfer"] - githubRepo = "hierynomus/sshj" - version { - name = "${project.version}" - vcsTag = "v${project.version}" - released = new SimpleDateFormat('yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ').format(new Date()) - gpg { - sign = true - passphrase = project.property("signing.password") - } - mavenCentralSync { - sync = true - user = project.property("sonatypeUsername") - password = project.property("sonatypePassword") - close = 1 +project.signing { + required { project.gradle.taskGraph.hasTask("release") } + sign publishing.publications.maven + + if (project.hasProperty("signingKeyId") || project.hasProperty("signingKey")) { + def signingKeyId = project.findProperty("signingKeyId") + def signingKey = project.findProperty("signingKey") + def signingPassword = project.findProperty("signingPassword") + if (signingKeyId) { + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) + } else if (signingKey) { + useInMemoryPgpKeys(signingKey, signingPassword) + } + } +} + +project.plugins.withType(MavenPublishPlugin).all { + PublishingExtension publishing = project.extensions.getByType(PublishingExtension) + publishing.publications.withType(MavenPublication).all { mavenPublication -> + mavenPublication.pom { + name = "${project.name}" + description = 'SSHv2 library for Java' + inceptionYear = '2009' + url = "https://github.com/hierynomus/${project.name}" + licenses { + license { + name = "The Apache License, Version 2.0" + url = "https://www.apache.org/licenses/LICENSE-2.0" + } + } + developers { + developer { + id = "hierynomus" + name = "Jeroen van Erp" + email = "jeroen@hierynomus.com" + } + developer { + id = "shikhar" + name = "Shikhar Bhushan" + email = "shikhar@schmizz.net" + url = "http://schmizz.net" + roles = ["Previous Lead developer"] + } + developer { + id = "iterate" + name = "David Kocher" + email = "dkocher@iterate.ch" + organization = "iterate GmbH" + organizationUrl = "https://iterate.ch" + roles = ["Developer"] } + } + scm { + url = "https://github.com/hierynomus/${project.name}" + connection = "scm:git@github.com:hierynomus/${project.name}.git" + developerConnection = "scm:git@github.com:hierynomus/${project.name}.git" } - } - } + } + } +} + +nexusPublishing { + repositories { + sonatype() //sonatypeUsername and sonatypePassword properties are used automatically + } + + connectTimeout = Duration.ofMinutes(3) + clientTimeout = Duration.ofMinutes(3) } jacocoTestReport { @@ -295,7 +309,7 @@ task stopItestContainer(type: DockerStopContainer) { task forkedUploadRelease(type: GradleBuild) { buildFile = project.buildFile - tasks = ["bintrayUpload"] + tasks = ["clean", "publishToSonatype", "closeAndReleaseSonatypeStagingRepository"] } project.tasks.integrationTest.dependsOn(startItestContainer) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4c5803d13..f371643ee 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists