Skip to content

Commit

Permalink
added scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
andreacalia committed Dec 5, 2016
1 parent b322ac0 commit 767ebc8
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ buildscript {

if(System.getenv('TRAVIS')){
apply plugin: 'io.codearte.nexus-staging'
apply from : './scripts/deploy.gradle'
apply from: './scripts/deploy.gradle'
}

dependencies {
Expand Down
11 changes: 11 additions & 0 deletions scripts/deploy-jars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e # exit with nonzero exit code if anything fails

openssl aes-256-cbc -K $encrypted_330589789bd4_key -iv $encrypted_330589789bd4_iv -in deployment.key.enc -out deployment.key -d
secreteFilePath=$(pwd)/deployment.key
echo "Deployment key found"

echo "Executing gradle deployToMavenCentral"
./gradlew deployToMavenCentral -PdeploymentVersion=${TRAVIS_TAG} -Psigning.keyId=${signingKeyId} -Psigning.password=${signingPassword} -Psigning.secretKeyRingFile=$secreteFilePath -PossrhUsername=${ossrhUsername} -PossrhPassword=${ossrhPassword} --stacktrace --info

rm $secreteFilePath
99 changes: 99 additions & 0 deletions scripts/deploy.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Get the proper version for the project. This method will extract the version number from the project variable "deploymentVersion".
*/
def getVersion = {
if( ! project.hasProperty('deploymentVersion') ) {
throw new RuntimeException("deploymentVersion not provided. You must specify a 'deploymentVersion' project variable (gradlew -PdeploymentVersion=..)")
}

String tmpDeploymentVersion = deploymentVersion.replaceFirst("v", "");

if( ! tmpDeploymentVersion.matches("\\d+\\.\\d+\\.\\d+")) {
throw new RuntimeException("Version is not valid. Correct format is like 1.0.2 but was " + tmpDeploymentVersion)
}

return tmpDeploymentVersion;
}

/*
* Assert that the project properties necessary for the deployment to sonatype are correctly set.
*/
def assertDeploymentPropertiesAreSet = {
boolean propertiesSet = project.getProperties().keySet().containsAll(Arrays.asList('ossrhUsername', 'ossrhPassword', 'signing.keyId', 'signing.password', 'signing.secretKeyRingFile'))
if( ! propertiesSet ) {
throw new RuntimeException("Deployment project properties are not correctly set: ossrhUsername, ossrhPassword, signing.keyId, signing.password, signing.secretKeyRingFile")
}
}

signing {
required { gradle.getTaskGraph().hasTask("uploadArchives") }
sign configurations.archives
}

task configureSonatypeDeployment(type: DefaultTask) << {

assertDeploymentPropertiesAreSet()

nexusStaging {
packageGroup = "org.tensorics"
username = ossrhUsername
password = ossrhPassword
// Sonatype Nexus may take some time to properly close the repo, it has to perform some checks
delayBetweenRetriesInMillis = 10000
numberOfRetries = 10
}

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 'tensorics-expression'
packaging 'jar'
description ''
url 'http://www.tensorics.org'

groupId 'org.tensorics'
artifactId 'tensorics-expression'
version getVersion()

scm {
connection 'scm:git:https://github.com/tensorics/tensorics-expression.git'
developerConnection 'scm:git:https://github.com/tensorics/tensorics-expression.git'
url 'https://github.com/tensorics/tensorics-expression.git'
}

licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id 'andreacalia'
name 'Andrea Calia'
email '[email protected]'
}
}

}
}
}
}
}

// Define the deploying task and defining the order for the dependencies
task deployToMavenCentral(dependsOn: ['configureSonatypeDeployment', 'uploadArchives', 'closeAndPromoteRepository'], type: DefaultTask)
uploadArchives.mustRunAfter configureSonatypeDeployment
closeAndPromoteRepository.mustRunAfter uploadArchives

0 comments on commit 767ebc8

Please sign in to comment.