Skip to content

Commit

Permalink
Realease Attach artifacts to Maven Central (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinayagarwal authored Apr 17, 2020
1 parent 72dcf6c commit 4516fc7
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 43 deletions.
File renamed without changes.
27 changes: 27 additions & 0 deletions .ci/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# Exit immediately if any command in the script fails
set -e

# Configure GIT
git config --global user.name "Gluon Bot"
git config --global user.email "[email protected]"

# Decrypt encrypted files
openssl aes-256-cbc -K $encrypted_dc87922a4c8c_key -iv $encrypted_dc87922a4c8c_iv -in .ci/secring.gpg.enc -out secring.gpg -d
if [[ ! -s secring.gpg ]]
then echo "Decryption failed."
exit 1
fi

# Release artifacts
./gradlew publish closeAndReleaseRepository -i -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD -Psigning.keyId=$GPG_KEYNAME -Psigning.password=$GPG_PASSPHRASE -Psigning.secretKeyRingFile=secring.gpg

# Update version by 1
newVersion=${TRAVIS_TAG%.*}.$((${TRAVIS_TAG##*.} + 1))

# Update project version to next snapshot version
sed -i -z "0,/version = $TRAVIS_TAG/s//version = $newVersion-SNAPSHOT/" gradle.properties

git commit gradle.properties -m "Prepare development of $newVersion"
git push https://gluon-bot:$GITHUB_PASSWORD@github.com/$TRAVIS_REPO_SLUG HEAD:master
Binary file added .ci/secring.gpg.enc
Binary file not shown.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ os: osx
osx_image: xcode11.3

before_script:
- bash ci/android.sh
- bash .ci/android.sh
- export ANDROID_SDK=$HOME/android-sdk
- export ANDROID_NDK=$HOME/android-sdk/ndk-bundle
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home
Expand All @@ -26,13 +26,13 @@ cache:
# Deploy releases on every tag push
deploy:
- provider: script
script: ./gradlew publish -PrepositoryUrl=$mavenPublishURL/public-snapshots/ -PrepositoryUsername=$mavenPublishUsername -PrepositoryPassword=$mavenPublishPassword
script: ./gradlew publish -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD
skip_cleanup: true
on:
branch: master

- provider: script
script: ./gradlew publish -PrepositoryUrl=$mavenPublishURL/releases/ -PrepositoryUsername=$mavenPublishUsername -PrepositoryPassword=$mavenPublishPassword
script: bash .ci/release.sh
skip_cleanup: true
on:
tags: true
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
plugins {
id 'io.codearte.nexus-staging' version '0.21.1'
id 'de.marcphilipp.nexus-publish' version '0.4.0' apply false
id "org.openjfx.javafxplugin" version "0.0.8" apply false
}

Expand Down Expand Up @@ -29,4 +31,11 @@ subprojects {
repositories {
mavenCentral()
}
}

nexusStaging {
username = project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : ''
password = project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : ''
numberOfRetries = 30
delayBetweenRetriesInMillis = 3000
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
group = com.gluonhq.attach
version = 4.0.7-SNAPSHOT

# disable publish of sha256, sha512
systemProp.org.gradle.internal.publish.checksums.insecure=true
57 changes: 17 additions & 40 deletions gradle/mavenPublish.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import java.time.Duration

apply plugin: 'java'
apply plugin: 'maven-publish'
//apply plugin: 'signing'
apply plugin: 'signing'
apply plugin: 'de.marcphilipp.nexus-publish'

def nativeLib(buildDir, projectDir, service, osname) {
return tasks.create("nativeLib${service}${osname}") {
Expand Down Expand Up @@ -110,9 +113,9 @@ publishing {
}

scm {
connection = 'scm:git:https://github.com/tiainen/attach.git'
developerConnection = 'scm:git:ssh://[email protected]/tiainen/attach.git'
url = 'https://github.com/tiainen/attach'
connection = 'scm:git:https://github.com/gluonhq/attach.git'
developerConnection = 'scm:git:ssh://[email protected]/gluonhq/attach.git'
url = 'https://github.com/gluonhq/attach'
}
}

Expand All @@ -126,25 +129,12 @@ publishing {
}
}
}

repositories {
maven {
// to upload release, use:
// ./gradlew -PrepositoryUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2 publish
// url = getStringProperty('repositoryUrl', 'https://oss.sonatype.org/content/repositories/snapshots/')
url = getStringProperty('repositoryUrl', 'https://nexus.gluonhq.com/nexus/content/repositories/public-snapshots/')
credentials {
username = getStringPropertyDefaultAsProperty('repositoryUsername', 'gluonNexusUsername')
password = getStringPropertyDefaultAsProperty('repositoryPassword', 'gluonNexusPassword')
}
}
}
}

//signing {
// sign publishing.publications.maven
// required = { gradle.taskGraph.hasTask(publish) && !version.endsWith("SNAPSHOT") }
//}
signing {
sign publishing.publications.maven
required = { gradle.taskGraph.hasTask(publish) && !version.endsWith("SNAPSHOT") }
}

private String getServiceName(projectName) {
if (projectName.contains("-")) { // in-app-billing -> InAppBilling
Expand All @@ -154,24 +144,11 @@ private String getServiceName(projectName) {
return projectName.capitalize()
}

private String getStringProperty(String name, String defaultValue) {
if (!project.hasProperty(name)) {
return defaultValue
}

def propertyValue = project.property(name)
return propertyValue != null ? propertyValue.toString().trim() : defaultValue
}

private String getStringPropertyDefaultAsProperty(String name, String defaultProperty) {
if (!project.hasProperty(name)) {
return project.hasProperty(defaultProperty) ? project.property(defaultProperty) : System.getenv(name)
}

def propertyValue = project.property(name)
if (propertyValue != null) {
return propertyValue.toString().trim()
} else {
return project.hasProperty(defaultProperty) ? project.property(defaultProperty) : System.getenv(name)
nexusPublishing {
repositories {
sonatype()
}
// credentials are shared from staging plugin
clientTimeout = Duration.ofMinutes(5)
connectTimeout = Duration.ofMinutes(5)
}

0 comments on commit 4516fc7

Please sign in to comment.