Skip to content

Commit

Permalink
Add deploy (arrow-kt#52)
Browse files Browse the repository at this point in the history
* add deploy

* minor improvement

* bad indent

* missing method

* delete gradle from modules

* fix missing module

* increase decoding from raw threshold
  • Loading branch information
AdrianRaFo committed May 2, 2019
1 parent 5025045 commit b895f92
Show file tree
Hide file tree
Showing 20 changed files with 166 additions and 130 deletions.
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: java
language: kotlin
sudo: required
dist: trusty

jdk:
- oraclejdk8
Expand All @@ -9,6 +11,8 @@ stages:
if: type == pull_request
- name: upload
if: branch = master AND type != pull_request AND sender != 47degdev
- name: deploy
if: branch = master AND type != pull_request

jobs:
include:
Expand All @@ -28,3 +32,6 @@ jobs:
- ./gradlew :helios-benchmarks:uploadBenchmark
- ./gradlew :helios-benchmarks:executeLibrariesBenchmark
- ./gradlew :helios-benchmarks:uploadLibrariesBenchmark
- stage: deploy
script:
- ./deploy-scripts/deploy.sh
17 changes: 11 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ apply plugin: "kotlin"

apply from: 'detekt.gradle'

def findPropertyOrEnv(String key) {
[project.properties[key], System.getenv(key)].find { it != null }
}

subprojects { project ->

group = GROUP
Expand Down Expand Up @@ -109,15 +113,16 @@ subprojects { project ->

bintray {
publish = true
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
configurations = ['archives']
user = findPropertyOrEnv("BINTRAY_USER") ?: "no.bintray.user"
key = findPropertyOrEnv("BINTRAY_API_KEY") ?: "no.bintray.api.key"
publications = ["HeliosPublication"]
configurations = ["archives"]
pkg {
repo = 'helios'
repo = "helios"
name = project.name
userOrg = POM_DEVELOPER_ID
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/47deg/helios.git'
licenses = ["Apache-2.0"]
vcsUrl = "https://github.com/47deg/helios.git"
}
}

Expand Down
18 changes: 18 additions & 0 deletions deploy-scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
gradle-mvn-push.gradle#!/usr/bin/env bash
. $(dirname $0)/deploy_common.sh

echo "Branch '$TRAVIS_BRANCH'"

if [ "$TRAVIS_BRANCH" == "master" ]; then
if [[ "$VERSION_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Starting script for Release $VERSION_NAME"
. $(dirname $0)/deploy_release.sh
elif [[ "$VERSION_NAME" == *-SNAPSHOT ]]; then
echo "Starting script for Snapshot Release $VERSION_NAME"
. $(dirname $0)/deploy_snapshot.sh
else
echo "No deploy script matched version '$VERSION_NAME' on master"
fi
else
echo "Skipped deployment in branch '$TRAVIS_BRANCH'"
fi
8 changes: 8 additions & 0 deletions deploy-scripts/deploy_common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
. $(dirname $0)/deploy_functions.sh
set -e

SLUG="47deg/hood"
JDK="oraclejdk8"
BRANCH="master"
VERSION_NAME=$(getProperty "VERSION_NAME")
12 changes: 12 additions & 0 deletions deploy-scripts/deploy_functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

function getProperty {
PROP_KEY=$1
PROP_VALUE=`cat gradle.properties | grep "$PROP_KEY" | cut -d'=' -f2`
echo $PROP_VALUE
}

function fail {
echo "$1"
exit -1
}
21 changes: 21 additions & 0 deletions deploy-scripts/deploy_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
. $(dirname $0)/deploy_common.sh

VERSION_PATTERN=^[0-9]+\.[0-9]+\.[0-9]+$

echo "Deploying release '$VERSION_NAME' ..."

if [ "$TRAVIS_REPO_SLUG" != "$SLUG" ]; then
fail "Failed release deployment: wrong repository. Expected '$SLUG' but was '$TRAVIS_REPO_SLUG'."
elif [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then
fail "Failed release deployment: wrong JDK. Expected '$JDK' but was '$TRAVIS_JDK_VERSION'."
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
fail "Failed release deployment: was pull request."
elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
fail "Failed release deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
elif ! [[ "$VERSION_NAME" =~ $VERSION_PATTERN ]]; then
fail "Failed release deployment: wrong version. Expected '$VERSION_NAME' to have pattern 'X.Y.Z'"
else
./gradlew bintrayUpload
echo "Release '$VERSION_NAME' deployed!"
fi
21 changes: 21 additions & 0 deletions deploy-scripts/deploy_snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
. $(dirname $0)/deploy_common.sh

VERSION_PATTERN=^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$

echo "Deploying snapshot '$VERSION_NAME' ..."

if [ "$TRAVIS_REPO_SLUG" != "$SLUG" ]; then
fail "Failed snapshot deployment: wrong repository. Expected '$SLUG' but was '$TRAVIS_REPO_SLUG'."
elif [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then
fail "Failed snapshot deployment: wrong JDK. Expected '$JDK' but was '$TRAVIS_JDK_VERSION'."
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
fail "Failed snapshot deployment: was pull request."
elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
fail "Failed snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
elif ! [[ "$VERSION_NAME" =~ $VERSION_PATTERN ]]; then
echo "Skipping snapshot deployment '$VERSION_NAME': This is probably a pre-release build"
else
./gradlew bintrayUpload
echo "Snapshot '$VERSION_NAME' deployed!"
fi
2 changes: 0 additions & 2 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ ank {

sourceCompatibility = javaVersion
targetCompatibility = javaVersion

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ kotlin.incremental=true
kotlin.code.style=official

# Pomfile definitions
POM_NAME=helios
POM_ARTIFACT_ID=helios
POM_PACKAGING=jar
POM_DESCRIPTION=Helios a meta powered Json Encoder

POM_URL=https://github.com/47deg/helios/

POM_SCM_URL=https://github.com/47deg/helios/
POM_SCM_CONNECTION=scm:git:git://github.com/47deg/helios.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/47deg/helios.git
Expand Down
164 changes: 60 additions & 104 deletions gradle/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
@@ -1,126 +1,82 @@
apply plugin: 'maven'

version = VERSION_NAME
group = GROUP

def findProperty(String key) {
[project.properties[key], System.getenv(key)].find { it != null }
}

def getReleaseRepositoryUrl() {
return findProperty('RELEASE_REPOSITORY_URL') ?: "https://api.bintray.com/maven/com.47deg/helios/" + POM_ARTIFACT_ID
return findProperty("RELEASE_REPOSITORY_URL") ?: "https://api.bintray.com/maven/47deg/helios/helios"
}

def getSnapshotRepositoryUrl() {
return findProperty('SNAPSHOT_REPOSITORY_URL') ?: "https://oss.jfrog.org/artifactory/oss-snapshot-local"
return findProperty("SNAPSHOT_REPOSITORY_URL") ?: "https://oss.jfrog.org/artifactory/oss-snapshot-local"
}

def getRepositoryUsername() {
return findProperty('BINTRAY_USER') ?: "no.bintray.user"
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = "sources"
from sourceSets.main.allSource,
"build/generated/source/kapt/main",
"build/generated/source/kapt/debug",
"build/generated/source/kapt/release",
"build/generated/source/kaptKotlin/main",
"build/generated/source/kaptKotlin/debug",
"build/generated/source/kaptKotlin/release",
"build/tmp/kapt/main/kotlinGenerated"
}

def getRepositoryPassword() {
return findProperty('BINTRAY_API_KEY') ?: "no.bintray.api.key"
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = "javadoc"
from javadoc.destinationDir
}

uploadArchives {
repositories.mavenDeployer {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME

repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
publishing {
publications {
HeliosPublication(MavenPublication) {

artifactId = POM_ARTIFACT_ID
groupId = group
version = version

artifact sourcesJar
artifact javadocJar

from components.java
pom {
name = POM_NAME
packaging = POM_PACKAGING
description = POM_DESCRIPTION
url = POM_URL
scm {
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
licenses {
license {
name = POM_LICENCE_NAME
url = POM_LICENCE_URL
distribution = POM_LICENCE_DIST
}
}

pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
}
}
}
}
}

install {
repositories.mavenInstaller {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME

pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
repositories {
maven {
def releasesRepoUrl = getReleaseRepositoryUrl()
def snapshotsRepoUrl = getSnapshotRepositoryUrl()
url = version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
getArchiveClassifier().set('sources')
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
getArchiveClassifier().set('javadoc')
from javadoc.destinationDir
}
}

if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
allprojects {
tasks.withType(Javadoc) {
options.addStringOption("Xdoclint:none", "-quiet")
}
}

artifacts {
archives sourcesJar
archives javadocJar
}
}
}
4 changes: 1 addition & 3 deletions helios-benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ dependencies {
kapt project(":helios-meta-compiler")
}

apply from: rootProject.file("gradle/gradle-mvn-push.gradle")

jmh {
resultFormat = "JSON"
resultsFile = file("$rootDir/build/reports/benchmarks.json")
Expand Down Expand Up @@ -81,7 +79,7 @@ compareBenchmarkCI {
currentBenchmarkPath = [file("$rootDir/build/reports/helios_benchmark.json")]
outputToFile = true
outputFormat = "json"
benchmarkThreshold = ["Parsing": 500.00]
benchmarkThreshold = ["Parsing": 500.00, "Decodingfromraw": 250]
token = System.getenv("GITHUB_ACCESS_TOKEN")
}

Expand Down
4 changes: 2 additions & 2 deletions helios-benchmarks/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Maven publishing configuration
POM_NAME=Helios Core
POM_ARTIFACT_ID=helios-core
POM_NAME=Helios Benchmarks
POM_ARTIFACT_ID=helios-benchmarks
POM_PACKAGING=jar
1 change: 0 additions & 1 deletion helios-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ dependencies {

}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
apply from: rootProject.file('gradle/generated-kotlin-sources.gradle')
2 changes: 0 additions & 2 deletions helios-dsl-syntax-compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ dependencies {
testCompile fileTree(dir: './src/test/libs', includes: ['*.jar'])
testCompile files(Jvm.current().getToolsJar())
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
2 changes: 0 additions & 2 deletions helios-meta-compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ dependencies {
testCompile fileTree(dir: './src/test/libs', includes: ['*.jar'])
testCompile files(Jvm.current().getToolsJar())
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

0 comments on commit b895f92

Please sign in to comment.