Skip to content

Commit

Permalink
support publishing to maven central
Browse files Browse the repository at this point in the history
add jar signing
add maven upload and nexus staging tasks

add release shell script

update to version 0.2.0
  • Loading branch information
wakingrufus committed Nov 29, 2017
1 parent 369fad2 commit dfa5432
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ shippable/
*.iml
*.ipr
*.iws
*.asc
*.gpg
97 changes: 89 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0"
}
repositories {
mavenCentral()
Expand All @@ -10,30 +10,39 @@ buildscript {
plugins {
id 'java'
id 'idea'
id "org.jetbrains.kotlin.jvm" version "1.1.4"
id "org.jetbrains.kotlin.jvm" version "1.2.0"
id 'jacoco'
id 'maven'
id 'signing'
id 'io.codearte.nexus-staging' version '0.11.0'
}

repositories {
mavenCentral()
}

version = "0.1.0"
ext {
pomFile = file("${project.buildDir}/generated-pom.xml")
isReleaseVersion = !(project.version =~ /-SNAPSHOT$/)
}

version = "0.2.0"
project.group = "com.github.wakingrufus"

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8"
compile 'org.projectlombok:lombok:1.16.18'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'io.github.microutils:kotlin-logging:1.4.4'
compile "org.jetbrains.kotlin:kotlin-reflect"
compile "org.jsoup:jsoup:1.10.3"

testCompile "org.jetbrains.kotlin:kotlin-test"
testCompile "org.jetbrains.kotlin:kotlin-test-junit"
testCompile 'org.mockito:mockito-core:2.8.9'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'junit:junit:4.12'
testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"
testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'
testCompile 'org.slf4j:slf4j-log4j12:1.7.25'
}

idea {
Expand All @@ -43,7 +52,7 @@ idea {
}

task wrapper(type: Wrapper) {
gradleVersion = '4.3.1'
gradleVersion = '4.2.1'
}

jacocoTestReport {
Expand All @@ -64,4 +73,76 @@ compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
}

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives jar
archives sourcesJar
archives javadocJar
}

signing {
required { signatory != null && project.ext.isReleaseVersion }
sign configurations.archives
}

nexusStaging {
packageGroup = "com.github.wakingrufus"
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
name 'lib-elo'
packaging 'jar'
group project.group
version project.version
// optionally artifactId can be defined here
description 'A library which performs ELO calculations for a game league (such as chess)'
url 'https://github.com/wakingrufus/lib-elo'

scm {
connection 'scm:git:https://github.com/wakingrufus/lib-elo.git'
developerConnection 'scm:git:https://github.com/wakingrufus/lib-elo.git/'
url 'https://github.com/wakingrufus/lib-elo'
}

licenses {
license {
name 'MIT License'
url 'https://opensource.org/licenses/MIT'
}
}

developers {
developer {
id 'wakingrufus'
name 'Rufus'
email '[email protected]'
}
}
}
}
}
}
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
signing.keyId=
signing.password=
signing.secretKeyRingFile=secring.gpg

ossrhUsername=
ossrhPassword=
11 changes: 11 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
echo Enter signing key id
read key_id
echo Enter signing key password
read key_pass
gpg2 --export-secret-key $key_id > secring.gpg
echo Enter ossrh Username
read ossrh_username
echo Enter ossrh Password
read ossrh_password
gradle -PossrhUsername=$ossrh_username -PossrhPassword=$ossrh_password -Psigning.keyId=$key_id -Psigning.password=$key_pass signArchives uploadArchives closeAndReleaseRepository
4 changes: 2 additions & 2 deletions shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ build:
- mkdir -p shippable/codecoverage/target/site/jacoco
- rm -rf build
- gradle wrapper
- ./gradlew clean build
- ./gradlew clean build -x signArchives
- cp build/test-results/test/*.xml shippable/testresults
- cp build/reports/jacoco/test/jacocoTestReport.xml shippable/codecoverage
- cp -r build/jacoco/test.exec shippable/codecoverage/target/site/jacoco
- cp -r build/classes shippable/codecoverage/target
on_success:
- export TAG_NAME=`git describe --exact-match --tags HEAD`
- export BRANCH_NAME=`git rev-parse --abbrev-ref HEAD`
- if [ "$TAG_NAME" != "" ]; then ./gradlew tasks; fi
- if [ "$TAG_NAME" != "" ]; then ./gradlew uploadArchives closeAndReleaseRepository; fi

0 comments on commit dfa5432

Please sign in to comment.