diff --git a/.travis.yml b/.travis.yml index 572dbae..7e9c164 100644 --- a/.travis.yml +++ b/.travis.yml @@ -113,3 +113,39 @@ jobs: skip_cleanup: true on: tags: true + + - stage: Publish Maven + language: scala + jdk: oraclejdk8 + + before_script: + - if [[ -z "$TRAVIS_TAG" ]]; then echo "Skipping this build for non-tag builds."; exit 0; fi + - cd java + - make + - curl -o ./shared/linux-x86-64/libenry.so -sL "https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG/libenry.so" + - mkdir -p ./shared/darwin + - curl -o ./shared/darwin/libenry.dylib -sL "https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG/libenry.dylib" + - openssl aes-256-cbc -K $encrypted_a0e1c69dbbc7_key -iv $encrypted_a0e1c69dbbc7_iv -in key.asc.enc -out key.asc -d + - gpg --no-default-keyring --primary-keyring ./project/.gnupg/pubring.gpg --secret-keyring ./project/.gnupg/secring.gpg --keyring ./project/.gnupg/pubring.gpg --fingerprint --import key.asc + + script: + - make test # ensure the shared objects are functional + - ./sbt publishLocal + - ./sbt publishSigned + - ./sbt sonatypeRelease + + before_deploy: + - rm ./target/enry-java-*-javadoc.jar + - rm ./target/enry-java-*-sources.jar + - rm ./target/enry-java-*-tests.jar + - rm ./target/enry-java-assembly-*.jar + + deploy: + provider: releases + api_key: + secure: $GITHUB_TOKEN + file_glob: true + file: ./target/enry-java*.jar + skip_cleanup: true + on: + tags: true diff --git a/java/.gitignore b/java/.gitignore index bbf3ec5..2e1635a 100644 --- a/java/.gitignore +++ b/java/.gitignore @@ -25,3 +25,7 @@ target .jnaerator shared *.jar +*.gpg +key.asc +project/.gnupg + diff --git a/java/build.sbt b/java/build.sbt index b281d73..c8cd056 100644 --- a/java/build.sbt +++ b/java/build.sbt @@ -1,12 +1,40 @@ name := "enry-java" organization := "tech.sourced" -version := "1.0" +version := "1.0.0" + +sonatypeProfileName := "tech.sourced" + +// pom settings for sonatype +homepage := Some(url("https://github.com/src-d/enry")) +scmInfo := Some(ScmInfo(url("https://github.com/src-d/enry"), + "git@github.com:src-d/enry.git")) +developers += Developer("abeaumont", + "Alfredo Beaumont", + "alfredo@sourced.tech", + url("https://github.com/abeaumont")) +licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0")) +pomIncludeRepository := (_ => false) crossPaths := false autoScalaLibrary := false publishMavenStyle := true exportJars := true +val SONATYPE_USERNAME = scala.util.Properties.envOrElse("SONATYPE_USERNAME", "NOT_SET") +val SONATYPE_PASSWORD = scala.util.Properties.envOrElse("SONATYPE_PASSWORD", "NOT_SET") +credentials += Credentials( + "Sonatype Nexus Repository Manager", + "oss.sonatype.org", + SONATYPE_USERNAME, + SONATYPE_PASSWORD) + +val SONATYPE_PASSPHRASE = scala.util.Properties.envOrElse("SONATYPE_PASSPHRASE", "not set") + +useGpg := false +pgpSecretRing := baseDirectory.value / "project" / ".gnupg" / "secring.gpg" +pgpPublicRing := baseDirectory.value / "project" / ".gnupg" / "pubring.gpg" +pgpPassphrase := Some(SONATYPE_PASSPHRASE.toArray) + libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test unmanagedBase := baseDirectory.value / "lib" @@ -23,3 +51,13 @@ artifact in (Compile, assembly) := { } addArtifact(artifact in (Compile, assembly), assembly) + +isSnapshot := version.value endsWith "SNAPSHOT" + +publishTo := { + val nexus = "https://oss.sonatype.org/" + if (isSnapshot.value) + Some("snapshots" at nexus + "content/repositories/snapshots") + else + Some("releases" at nexus + "service/local/staging/deploy/maven2") +} diff --git a/java/key.asc.enc b/java/key.asc.enc new file mode 100644 index 0000000..540b82d Binary files /dev/null and b/java/key.asc.enc differ diff --git a/java/project/plugins.sbt b/java/project/plugins.sbt index cc9a881..68c4402 100644 --- a/java/project/plugins.sbt +++ b/java/project/plugins.sbt @@ -1 +1,3 @@ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5") \ No newline at end of file +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") \ No newline at end of file