This repository was archived by the owner on Dec 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update plublish process to publish to sonatype (#1)
Description =========== Bintray and with it JCenter will be shutdown the comming weeks. To be able to host this library in a commenly available repository we need to switch the publish logic to publish to sonatype and with it the central repository. This needs some adjustments in both gradle file and jenkins pipeline. I took the liberty to upgrade the project to use the latest version of gradle `6.8.2` as this has some features regarding pgp signing which gradle 5 does not have. I want to sign the artifacts with a gpg subkey to not roll out the master key on the ci system with a ascii in memory format which is not supported with gradle 5. The jenkins steps also need to fetch new credentials. Changes ======= * ![UPDATE] `build.gradle` to publish to OSSRH instead of bintray * ![UPDATE] gradle wrapper to version `6.8.2` * ![UPDATE] `Jenkinsfile` to pass new credentials and publish snapshot versions
- Loading branch information
Showing
11 changed files
with
106 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,11 @@ | ||
#!groovy | ||
@Library('github.com/wooga/[email protected]') _ | ||
|
||
withCredentials([usernamePassword(credentialsId: 'github_integration', passwordVariable: 'githubPassword', usernameVariable: 'githubUser'), | ||
usernamePassword(credentialsId: 'github_integration_2', passwordVariable: 'githubPassword2', usernameVariable: 'githubUser2'), | ||
string(credentialsId: 'spock_github_extension_coveralls_token', variable: 'coveralls_token')]) { | ||
|
||
def testEnvironment = [ 'osx': | ||
[ | ||
"ATLAS_GITHUB_INTEGRATION_USER=${githubUser}", | ||
"ATLAS_GITHUB_INTEGRATION_PASSWORD=${githubPassword}" | ||
], | ||
'windows': | ||
[ | ||
"ATLAS_GITHUB_INTEGRATION_USER=${githubUser2}", | ||
"ATLAS_GITHUB_INTEGRATION_PASSWORD=${githubPassword2}" | ||
] | ||
] | ||
|
||
buildJavaLibrary plaforms: ['osx','windows'], coverallsToken: coveralls_token, testEnvironment: testEnvironment | ||
def testEnvironment = [ | ||
"ATLAS_GITHUB_INTEGRATION_USER=${githubUser}", | ||
"ATLAS_GITHUB_INTEGRATION_PASSWORD=${githubPassword}" | ||
] | ||
buildJavaLibraryOSSRH coverallsToken: coveralls_token, testEnvironment: testEnvironment | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,14 +19,15 @@ plugins { | |
id 'java-library' | ||
id 'groovy' | ||
id 'maven-publish' | ||
id 'com.jfrog.bintray' version '1.8.4' | ||
id 'nebula.release' version '6.3.5' | ||
id 'signing' | ||
id 'nebula.release' version '15.2.0' | ||
id 'jacoco' | ||
id 'com.github.kt3k.coveralls' version '2.8.2' | ||
id 'io.codearte.nexus-staging' version '0.22.0' | ||
id "de.marcphilipp.nexus-publish" version "0.4.0" | ||
} | ||
|
||
group "com.wooga.spock.extensions" | ||
|
||
List<String> cliTasks = project.rootProject.gradle.startParameter.taskNames | ||
if (cliTasks.contains("rc")) { | ||
cliTasks.remove("rc") | ||
|
@@ -35,74 +36,27 @@ if (cliTasks.contains("rc")) { | |
} | ||
|
||
dependencies { | ||
compile 'org.codehaus.groovy:groovy-all:2.4.15' | ||
compile 'org.kohsuke:github-api:1.95' | ||
compile('org.spockframework:spock-core:1.2-groovy-2.4') | ||
implementation 'org.codehaus.groovy:groovy-all:2.4.15' | ||
api 'org.kohsuke:github-api:1.95' | ||
implementation('org.spockframework:spock-core:1.2-groovy-2.4') | ||
|
||
testCompile 'net.bytebuddy:byte-buddy:1.9.12' | ||
testCompile 'com.github.stefanbirkner:system-rules:1.18.0' | ||
testImplementation 'net.bytebuddy:byte-buddy:[1.9,2)' | ||
testImplementation 'com.github.stefanbirkner:system-rules:[1.18,2)' | ||
} | ||
|
||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
|
||
task sourcesJar(type: Jar, dependsOn: classes) { | ||
classifier = 'sources' | ||
task sourcesJar(type: Jar) { | ||
archiveClassifier.set('sources') | ||
from sourceSets.main.allSource | ||
} | ||
|
||
javadoc.failOnError = false | ||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from javadoc.destinationDir | ||
} | ||
|
||
artifacts { | ||
archives sourcesJar | ||
archives javadocJar | ||
} | ||
|
||
bintray { | ||
user = project.hasProperty('bintrayUser') ? project.property('bintray.user') : System.getenv('BINTRAY_USER') | ||
key = project.hasProperty('bintrayApiKey') ? project.property('bintray.key') : System.getenv('BINTRAY_API_KEY') | ||
publish = true | ||
publications = ['Bintray'] | ||
pkg { | ||
repo = 'maven' | ||
name = project.name | ||
userOrg = 'wooga' | ||
licenses = ['Apache-2.0'] | ||
vcsUrl = 'https://github.com/wooga/spock-github-extension.git' | ||
labels = ['test', 'spock', 'github'] | ||
version { | ||
name = project.version.toString() | ||
vcsTag = project.version.toString() | ||
released = new Date() | ||
} | ||
} | ||
} | ||
|
||
|
||
def pomConfig = { | ||
licenses { | ||
license { | ||
name "The Apache Software License, Version 2.0" | ||
url "http://www.apache.org/licenses/LICENSE-2.0.txt" | ||
distribution "repo" | ||
} | ||
} | ||
developers { | ||
developer { | ||
id "manfred.endres" | ||
name "Manfred Endres" | ||
email "[email protected]" | ||
} | ||
} | ||
|
||
scm { | ||
url "https://github.com/wooga/spock-github-extension.git" | ||
} | ||
task javadocJar(type: Jar) { | ||
archiveClassifier.set('javadoc') | ||
from javadoc | ||
} | ||
|
||
jacocoTestReport { | ||
|
@@ -112,29 +66,77 @@ jacocoTestReport { | |
} | ||
} | ||
|
||
artifacts { | ||
archives sourcesJar | ||
archives javadocJar | ||
} | ||
|
||
publishing { | ||
publications { | ||
Bintray(MavenPublication) { | ||
from components.java | ||
main(MavenPublication) { | ||
artifactId = project.name | ||
from(components["java"]) | ||
artifact sourcesJar { | ||
classifier "sources" | ||
} | ||
artifact javadocJar { | ||
classifier "javadoc" | ||
} | ||
|
||
groupId project.group | ||
artifactId project.name | ||
version project.version.toString() | ||
pom.withXml { | ||
def root = asNode() | ||
root.appendNode('description', 'A extension for Spock to create Github repositories during test.') | ||
root.appendNode('name', 'Spock GitHub extension') | ||
root.appendNode('url', 'https://github.com/thombergs/myAwesomeLib') | ||
root.children().last() + pomConfig | ||
pom { | ||
name = 'Spock GitHub extension' | ||
description = 'A extension for Spock to create Github repositories during test.' | ||
url = 'https://github.com/wooga/spock-github-extension' | ||
|
||
artifactId = project.name | ||
inceptionYear = "2019" | ||
|
||
scm { | ||
connection = 'scm:git:https://github.com/wooga/spock-github-extension.git' | ||
developerConnection = 'scm:git:https://github.com/wooga/spock-github-extension.git' | ||
url = 'https://github.com/wooga/spock-github-extension.git' | ||
} | ||
|
||
licenses { | ||
license { | ||
name = 'The Apache License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
id = 'manfred.endres' | ||
name = 'Manfred Endres' | ||
email = '[email protected]' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
[finalSetup, candidateSetup, snapshotSetup].each { it.dependsOn(build)} | ||
nexusPublishing { | ||
repositories { | ||
sonatype() | ||
} | ||
} | ||
|
||
nexusStaging { | ||
username = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : System.getenv('OSSRH_USERNAME') | ||
password = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : System.getenv('OSSRH_PASSWORD') | ||
packageGroup = "com.wooga" | ||
} | ||
|
||
signing { | ||
def signingKeyId = project.hasProperty("signingKeyId") ? project.property('signingKeyId') : System.getenv('OSSRH_SIGNING_KEY_ID') | ||
def signingKey = project.hasProperty("signingKey") ? project.property('signingKey') : System.getenv('OSSRH_SIGNING_KEY') | ||
def signingPassword = project.hasProperty('signingPassphrase') ? project.property('signingPassphrase') : System.getenv("OSSRH_SIGNING_PASSPHRASE") | ||
useInMemoryPgpKeys(signingKeyId.toString(), signingKey.toString(), signingPassword.toString()) | ||
sign publishing.publications.main | ||
} | ||
|
||
postRelease.dependsOn(tasks.publish) | ||
tasks."final".dependsOn(tasks.closeAndReleaseRepository) | ||
tasks."candidate".dependsOn(tasks.closeAndReleaseRepository) | ||
tasks.closeAndReleaseRepository.mustRunAfter(tasks.postRelease) | ||
tasks.publish.mustRunAfter(tasks.release) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,8 +52,8 @@ class Repository { | |
void captureResetRefs() { | ||
try { | ||
resetRefs = repository.refs | ||
} catch(HttpException e) { | ||
if(!e.message.contains("Git Repository is empty.")) { | ||
} catch (HttpException e) { | ||
if (!e.message.contains("Git Repository is empty.")) { | ||
throw e | ||
} | ||
resetRefs = [] | ||
|
@@ -112,7 +112,8 @@ class Repository { | |
commitBuilder.message(message) | ||
commitBuilder.tree(commit.tree.getSha()) | ||
commitBuilder.parent(commit.getSHA1()) | ||
commitBuilder.author(repository.owner.name, repository.owner.email, new Date()) | ||
def email = repository.owner.email ?: "[email protected]" | ||
commitBuilder.author(repository.owner.name, email, new Date()) | ||
GHCommit newCommit = commitBuilder.create() | ||
|
||
GHRef branchRef = getBranchRef(branchName) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters