Skip to content

Commit 767ebc8

Browse files
committed
added scripts
1 parent b322ac0 commit 767ebc8

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ buildscript {
1919

2020
if(System.getenv('TRAVIS')){
2121
apply plugin: 'io.codearte.nexus-staging'
22-
apply from : './scripts/deploy.gradle'
22+
apply from: './scripts/deploy.gradle'
2323
}
2424

2525
dependencies {

scripts/deploy-jars.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e # exit with nonzero exit code if anything fails
3+
4+
openssl aes-256-cbc -K $encrypted_330589789bd4_key -iv $encrypted_330589789bd4_iv -in deployment.key.enc -out deployment.key -d
5+
secreteFilePath=$(pwd)/deployment.key
6+
echo "Deployment key found"
7+
8+
echo "Executing gradle deployToMavenCentral"
9+
./gradlew deployToMavenCentral -PdeploymentVersion=${TRAVIS_TAG} -Psigning.keyId=${signingKeyId} -Psigning.password=${signingPassword} -Psigning.secretKeyRingFile=$secreteFilePath -PossrhUsername=${ossrhUsername} -PossrhPassword=${ossrhPassword} --stacktrace --info
10+
11+
rm $secreteFilePath

scripts/deploy.gradle

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Get the proper version for the project. This method will extract the version number from the project variable "deploymentVersion".
3+
*/
4+
def getVersion = {
5+
if( ! project.hasProperty('deploymentVersion') ) {
6+
throw new RuntimeException("deploymentVersion not provided. You must specify a 'deploymentVersion' project variable (gradlew -PdeploymentVersion=..)")
7+
}
8+
9+
String tmpDeploymentVersion = deploymentVersion.replaceFirst("v", "");
10+
11+
if( ! tmpDeploymentVersion.matches("\\d+\\.\\d+\\.\\d+")) {
12+
throw new RuntimeException("Version is not valid. Correct format is like 1.0.2 but was " + tmpDeploymentVersion)
13+
}
14+
15+
return tmpDeploymentVersion;
16+
}
17+
18+
/*
19+
* Assert that the project properties necessary for the deployment to sonatype are correctly set.
20+
*/
21+
def assertDeploymentPropertiesAreSet = {
22+
boolean propertiesSet = project.getProperties().keySet().containsAll(Arrays.asList('ossrhUsername', 'ossrhPassword', 'signing.keyId', 'signing.password', 'signing.secretKeyRingFile'))
23+
if( ! propertiesSet ) {
24+
throw new RuntimeException("Deployment project properties are not correctly set: ossrhUsername, ossrhPassword, signing.keyId, signing.password, signing.secretKeyRingFile")
25+
}
26+
}
27+
28+
signing {
29+
required { gradle.getTaskGraph().hasTask("uploadArchives") }
30+
sign configurations.archives
31+
}
32+
33+
task configureSonatypeDeployment(type: DefaultTask) << {
34+
35+
assertDeploymentPropertiesAreSet()
36+
37+
nexusStaging {
38+
packageGroup = "org.tensorics"
39+
username = ossrhUsername
40+
password = ossrhPassword
41+
// Sonatype Nexus may take some time to properly close the repo, it has to perform some checks
42+
delayBetweenRetriesInMillis = 10000
43+
numberOfRetries = 10
44+
}
45+
46+
uploadArchives {
47+
repositories {
48+
mavenDeployer {
49+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
50+
51+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
52+
authentication(userName: ossrhUsername, password: ossrhPassword)
53+
}
54+
55+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
56+
authentication(userName: ossrhUsername, password: ossrhPassword)
57+
}
58+
59+
pom.project {
60+
name 'tensorics-expression'
61+
packaging 'jar'
62+
description ''
63+
url 'http://www.tensorics.org'
64+
65+
groupId 'org.tensorics'
66+
artifactId 'tensorics-expression'
67+
version getVersion()
68+
69+
scm {
70+
connection 'scm:git:https://github.com/tensorics/tensorics-expression.git'
71+
developerConnection 'scm:git:https://github.com/tensorics/tensorics-expression.git'
72+
url 'https://github.com/tensorics/tensorics-expression.git'
73+
}
74+
75+
licenses {
76+
license {
77+
name 'The Apache License, Version 2.0'
78+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
79+
}
80+
}
81+
82+
developers {
83+
developer {
84+
id 'andreacalia'
85+
name 'Andrea Calia'
86+
87+
}
88+
}
89+
90+
}
91+
}
92+
}
93+
}
94+
}
95+
96+
// Define the deploying task and defining the order for the dependencies
97+
task deployToMavenCentral(dependsOn: ['configureSonatypeDeployment', 'uploadArchives', 'closeAndPromoteRepository'], type: DefaultTask)
98+
uploadArchives.mustRunAfter configureSonatypeDeployment
99+
closeAndPromoteRepository.mustRunAfter uploadArchives

0 commit comments

Comments
 (0)