diff --git a/.travis.yml b/.travis.yml index b106b2d7..d1e4f772 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,42 @@ -dist: trusty - language: scala +scala: + - 2.11.12 + - 2.12.10 + - 2.13.1 + env: - global: - # PGP_PASSPHRASE - - secure: "MIHv2s6njtXubCzbP/eYXszuO/Y3FADYATZpDtOULZmQHcQ8z+sccQHidyq6hvoK9/I2hRUrc5RIelfA7D32tqP7aF3P9Dq1ZdiWqZYmFKUl6wzJMhgWwnT1RA9Nu67PcNLZGwOe7+55zZpWVNbeTKMe05TzUaaGUgApr9wvS0I=" - # SONA_USER - - secure: "e3FEhT76+qpmeubxtthmubnuyf5faCZneB1lQE8zv89/NZrD+v6tM8hGWatfiyyswmcaUdukxW/Q3NVlesKiy+cJLgNJ8AImRckKPiPVUYpXcQoc0R1Nyl4DeDyorGE17SslW28frlRU9OutTnZQlOfg4uqCdZuuCdcPV0lnGAU=" - # SONA_PASS - - secure: "BLhtiCjcjvwB0lUvfrMa9CSvWDcdGkadAVFFPyuXSU2OQw/RR9dZF3/ZLILf9jHL3pWj/Scp8jWRl40y6sUxihUOXhhxpDCF8UVgnXdDCQf/W7gerRC/+3Zpr3LugVeSEuBgECld6XZnYNst/xbL9GHzEc7kDm7MIfz8nY8Ic7s=" + - ADOPTOPENJDK=8 + - ADOPTOPENJDK=11 -script: admin/build.sh +before_install: + # adding $HOME/.sdkman to cache would create an empty directory, which interferes with the initial installation + - "[[ -d $HOME/.sdkman/bin ]] || rm -rf $HOME/.sdkman/" + - curl -sL https://get.sdkman.io | bash + - echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config + - source "$HOME/.sdkman/bin/sdkman-init.sh" -jdk: -- oraclejdk8 -- openjdk11 +install: + - sdk install java $(sdk list java | grep -o "$ADOPTOPENJDK\.[0-9\.]*hs-adpt" | head -1) + - unset JAVA_HOME + - java -Xmx32m -version + - git fetch --tags # get all tags for sbt-dynver + +script: ./build.sh notifications: email: - adriaan.moors@lightbend.com - seth.tisue@lightbend.com - andy@hicks.net + +before_cache: + - rm -f $HOME/.ivy2/.sbt.ivy.lock + - find $HOME/.ivy2/cache -name "ivydata-*.properties" | xargs rm + - find $HOME/.sbt -name "*.lock" | xargs rm +cache: + directories: + - $HOME/.ivy2/cache + - $HOME/.sbt + - $HOME/.cache/coursier + - $HOME/.sdkman diff --git a/admin/README.md b/admin/README.md deleted file mode 100644 index 46626b4e..00000000 --- a/admin/README.md +++ /dev/null @@ -1,72 +0,0 @@ -## Tag Driven Releasing - -### Background Reading - - - http://docs.travis-ci.com/user/environment-variables/ - - http://docs.travis-ci.com/user/encryption-keys/ - - http://docs.travis-ci.com/user/encrypting-files/ - -### Initial setup for the repository - -To configure tag driven releases from Travis CI. - - 1. Generate a key pair for this repository with `./admin/genKeyPair.sh`. - Edit `.travis.yml` and `admin/build.sh` as prompted. - 1. Publish the public key to https://pgp.mit.edu - 1. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`. - Edit `.travis.yml` as prompted. - 1. Edit `.travis.yml` to use `./admin/build.sh` as the build script, - and edit that script to use the tasks required for this project. - 1. Edit `build.sbt`'s `scalaVersionsByJvm in ThisBuild` to select Scala and JVM version - combinations that will be used for publishing. - -It is important to add comments in `.travis.yml` to identify the name -of each environment variable encoded in a `:secure` section. - -After these steps, your `.travis.yml` should contain config of the form: - -``` -language: scala - -env: - global: - # PGP_PASSPHRASE - - secure: "XXXXXX" - # SONA_USER - - secure: "XXXXXX" - # SONA_PASS - - secure: "XXXXXX" - -script: admin/build.sh - -jdk: - - openjdk6 - - oraclejdk8 - -notifications: - email: - - a@b.com -``` - -If Sonatype credentials change in the future, step 3 can be repeated -without generating a new key. - -### Testing - - 1. Follow the release process below to create a dummy release (e.g., `v0.1.0-TEST1`). - Confirm that the release was staged to Sonatype but do not release it to Maven - central. Instead, drop the staging repository. - -### Performing a release - - 1. Create a GitHub "Release" with a corresponding tag (e.g., `v0.1.1`) via the GitHub - web interface. - 1. The release will be published using the Scala and JVM version combinations specified - in `scalaVersionsByJvm` in `build.sbt`. - - If you need to release against a different Scala version, include the Scala version - and the JVM version to use in the tag name, separated by `#`s (e.g., `v0.1.1#2.13.0-M1#8`). - Note that the JVM version needs to be listed in `.travis.yml` for the build to run. - 1. Travis CI will schedule a build for this release. Review the build logs. - 1. Log into https://oss.sonatype.org/ and identify the staging repository. - 1. Sanity check its contents. - 1. Release staging repository to Maven and send out release announcement. diff --git a/admin/build.sh b/admin/build.sh deleted file mode 100755 index 6eee5d83..00000000 --- a/admin/build.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -set -e - -# Builds of tagged revisions are published to sonatype staging. - -# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice. -# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds. -# Checking the local git clone would not work because git on travis does not fetch tags. - -# The version number to be published is extracted from the tag, e.g., v1.2.3 publishes -# version 1.2.3 using all Scala versions in build.sbt's `crossScalaVersions`. - -# When a new, binary incompatible Scala version becomes available, a previously released version -# can be released using that new Scala version by creating a new tag containing the Scala and the -# JVM version after hashes, e.g., v1.2.3#2.13.0-M1#8. The JVM version needs to be listed in -# `.travis.yml`, otherwise the required build doesn't run. - -verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?" -tagPat="^v$verPat(#$verPat#[0-9]+)?$" - -if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then - currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//') - - tagVer=$(echo $TRAVIS_TAG | sed s/#.*// | sed s/^v//) - publishVersion='set every version := "'$tagVer'"' - - scalaAndJvmVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//) - if [ "$scalaAndJvmVer" != "" ]; then - scalaVer=$(echo $scalaAndJvmVer | sed s/#.*//) - jvmVer=$(echo $scalaAndJvmVer | sed s/[^#]*// | sed s/^#//) - if [ "$jvmVer" != "$currentJvmVer" ]; then - echo "Not publishing $TRAVIS_TAG on Java version $currentJvmVer." - exit 0 - fi - publishScalaVersion='set every ScalaModulePlugin.scalaVersionsByJvm := Map('$jvmVer' -> List("'$scalaVer'" -> true))' - echo "Releasing $tagVer using Scala $scalaVer on Java version $jvmVer." - else - echo "Releasing $tagVer on Java version $currentJvmVer according to 'scalaVersionsByJvm' in build.sbt." - fi - - extraTarget="+publishSigned" - cat admin/gpg.sbt >> project/plugins.sbt - cp admin/publish-settings.sbt . - - # Copied from the output of genKeyPair.sh - K=$encrypted_e923b9d88d53_key - IV=$encrypted_e923b9d88d53_iv - - openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d -fi - -sbt "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget diff --git a/admin/encryptEnvVars.sh b/admin/encryptEnvVars.sh deleted file mode 100755 index b6256679..00000000 --- a/admin/encryptEnvVars.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# -# Encrypt sonatype credentials so that they can be -# decrypted in trusted builds on Travis CI. -# -set -e - -read -s -p 'SONA_USER: ' SONA_USER -travis encrypt SONA_USER="$SONA_USER" -read -s -p 'SONA_PASS: ' SONA_PASS -travis encrypt SONA_PASS="$SONA_PASS" diff --git a/admin/genKeyPair.sh b/admin/genKeyPair.sh deleted file mode 100755 index 17db3f39..00000000 --- a/admin/genKeyPair.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# Generates a key pair for this repository to sign artifacts. -# Encrypt the private key and its passphrase in trusted builds -# on Travis CI. -# -set -e - -# Based on https://gist.github.com/kzap/5819745: -function promptDelete() { - if [[ -f "$1" ]]; then - echo About to delete $1, Enter for okay / CTRL-C to cancel - read - rm "$1" - fi -} -for f in admin/secring.asc.enc admin/secring.asc admin/pubring.asc; do promptDelete "$f"; done - -echo Generating key pair. Please enter 1. repo name 2. scala-internals@googlegroups.com, 3. a new passphrase -echo Be careful when using special characters in the passphrase, see http://docs.travis-ci.com/user/encryption-keys/#Note-on-escaping-certain-symbols -cp admin/gpg.sbt project -sbt 'set pgpReadOnly := false' \ - 'set pgpPublicRing := file("admin/pubring.asc")' \ - 'set pgpSecretRing := file("admin/secring.asc")' \ - 'pgp-cmd gen-key' -rm project/gpg.sbt - -echo ============================================================================================ -echo Encrypting admin/secring.asc. Update K and IV variables in admin/build.sh accordingly. -echo ============================================================================================ -travis encrypt-file admin/secring.asc -rm admin/secring.asc -mv secring.asc.enc admin - -echo ============================================================================================ -echo Encrypting environment variables. Add each to a line in .travis.yml. Include a comment -echo with the name of the corresponding variable -echo ============================================================================================ -read -s -p 'PGP_PASSPHRASE: ' PGP_PASSPHRASE -travis encrypt PGP_PASSPHRASE="$PGP_PASSPHRASE" - diff --git a/admin/gpg.sbt b/admin/gpg.sbt deleted file mode 100644 index 3b55e214..00000000 --- a/admin/gpg.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1") // only added when publishing, see build.sh diff --git a/admin/publish-settings.sbt b/admin/publish-settings.sbt deleted file mode 100644 index f763ea06..00000000 --- a/admin/publish-settings.sbt +++ /dev/null @@ -1,9 +0,0 @@ -def env(key: String) = Option(System.getenv(key)).getOrElse("") - -pgpPassphrase := Some(env("PGP_PASSPHRASE").toArray) - -pgpPublicRing := file("admin/pubring.asc") - -pgpSecretRing := file("admin/secring.asc") - -credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", env("SONA_USER"), env("SONA_PASS")) diff --git a/admin/pubring.asc b/admin/pubring.asc deleted file mode 100644 index 50fd4ea7..00000000 --- a/admin/pubring.asc +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: BCPG v1.49 - -mQENBFVR64QBCACAJOLyHZ5IKrJG7bBbLm+PDm+3EvYXFv5kAZpDoAooG5HUMhoF -6NA5fTa6WfHHih9yTd56YbsOEzk08VxlT2oE7NUcg2rDCBG/Iriyymn7ZR0HSR2K -qEy5jfr7e/0h1xKd4TE2VGNaBzA1y/h4Sg08LvV3FbHYXOHeb1emIfakE/hVTmlo -L2K0MF+KWpTkB1mXtZsNnoNSXEEN4tNlwzuPJK/A+auwFZ0yjEDRxgr5so+bkh2y -MvTsXHOupn97CrZdJUCti49nEj5MSum3Ng/8vR7lNAf9Tz5I53CmSwyd35eCZJUY -dL3NWHnNunMdDj5D0RA7dJIFaws+YlM/EXs5ABEBAAG0LnNjYWxhLXN3aW5nIDxz -Y2FsYS1pbnRlcm5hbHNAZ29vZ2xlZ3JvdXBzLmNvbT6JARwEEwECAAYFAlVR64QA -CgkQWu9VkpRCbxnXWQf/Tg7tdDK7zF3oyt8tsXZ7BQVTRL0J3AsddnrKw1KjfXzD -ugxxD4saFapsZZ5W7Ify4ifacHeQemX5n1FxJOJ+opdiD6BbpNmaC2onwg4I0SDj -1cnng34fdINb2xIjyxbSM34wukNEf8D5xZUlc+Eb5C6XhJpAJpD1LtkQeL5qvlHe -w2f0imVdleLSg7JjUOFw2HxLypnHuSF8sTnh3TS2YHERf6F3QOBDKpvQYCERmjzz -JYdBa3wZUEHU8+O40md+BUhV7iPSR35GR3NPX1Z+OZxMUGOdqkEuNnKBkdpj/ePu -FUNKC+EtLfcE9ny6PwvCREPEJf00kpgUdUiYTtIjWA== -=xCic ------END PGP PUBLIC KEY BLOCK----- diff --git a/admin/secring.asc.enc b/admin/secring.asc.enc deleted file mode 100644 index c0e25964..00000000 Binary files a/admin/secring.asc.enc and /dev/null differ diff --git a/build.sbt b/build.sbt index 544c8511..d74f8625 100644 --- a/build.sbt +++ b/build.sbt @@ -1,40 +1,13 @@ -import ScalaModulePlugin._ - -scalaModuleSettings - -name := "scala-swing" - -version := "2.1.1" - -scalacOptions in ThisBuild ++= Seq("-deprecation", "-feature") - -// Map[JvmMajorVersion, List[(ScalaVersion, UseForPublishing)]] -scalaVersionsByJvm in ThisBuild := Map( - 8 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> true), - 9 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> false), - 10 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> false), - 11 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> false), - 12 -> List("2.11.12", "2.12.8", "2.13.0").map(_ -> false) -) - -scalaVersion in ThisBuild := "2.12.8" - -OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}") - -mimaPreviousVersion := Some("2.1.0") - -// set the prompt (for this build) to include the project id. -shellPrompt in ThisBuild := { state => Project.extract(state).currentRef.project + "> " } - lazy val swing = project.in(file(".")) + .settings(ScalaModulePlugin.scalaModuleSettings) + .settings(ScalaModulePlugin.scalaModuleSettingsJVM) .settings( - libraryDependencies += { - if (scalaVersion.value == "2.13.0") { - "org.scalatest" % "scalatest_2.13.0-RC3" % "3.0.8-RC5" % Test - } else { - "org.scalatest" %% "scalatest" % "3.0.8-RC5" % Test - } - }, + name := "scala-swing", + OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}"), + scalaModuleMimaPreviousVersion := Some("2.1.0"), + // set the prompt (for this build) to include the project id. + shellPrompt in ThisBuild := { state => Project.extract(state).currentRef.project + "> " }, + libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % Test, // Adds a `src/main/scala-2.13+` source directory for Scala 2.13 and newer // and a `src/main/scala-2.13-` source directory for Scala version older than 2.13 unmanagedSourceDirectories in Compile += { diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..0a7d98d0 --- /dev/null +++ b/build.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +set -e + +# Builds of tagged revisions are published to sonatype staging. + +# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice. +# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds. + +# sbt-dynver sets the version number from the tag +# sbt-travisci sets the Scala version from the travis job matrix + +# When a new binary incompatible Scala version becomes available, a previously released version +# can be released using that new Scala version by creating a new tag containing the Scala version +# after a hash, e.g., v1.2.3#2.13.0-M3. In this situation, the first job of the travis job +# matrix builds the release. All other jobs are stopped. Make sure that the first job uses +# the desired JVM version. +# For normal tags that are cross-built, we release on JDK 8 for Scala 2.x + +isReleaseJob() { + if [[ "$ADOPTOPENJDK" == "8" ]]; then + true + else + false + fi +} + +# For tags that define a Scala version, we pick the jobs of one Scala version (2.13.x) to do the releases +isTagScalaReleaseJob() { + if [[ "$ADOPTOPENJDK" == "8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.13\.[0-9]+$ ]]; then + true + else + false + fi +} + +verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?" +tagPat="^v$verPat(#$verPat)?$" + +if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then + releaseTask="ci-release" + tagScalaVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//) + if [[ "$tagScalaVer" == "" ]]; then + if ! isReleaseJob; then + echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION" + exit 0 + fi + else + if isTagScalaReleaseJob; then + setTagScalaVersion='set every scalaVersion := "'$tagScalaVer'"' + else + echo "The releases for Scala $tagScalaVer are built by other jobs in the travis job matrix" + exit 0 + fi + fi +fi + +# default is +publishSigned; we cross-build with travis jobs, not sbt's crossScalaVersions +export CI_RELEASE="publishSigned" +export CI_SNAPSHOT_RELEASE="publish" + +# default is sonatypeBundleRelease, which closes and releases the staging repo +# see https://github.com/xerial/sbt-sonatype#commands +# for now, until we're confident in the new release scripts, just close the staging repo. +export CI_SONATYPE_RELEASE="; sonatypePrepare; sonatypeBundleUpload; sonatypeClose" + +sbt "$setTagScalaVersion" clean test publishLocal $releaseTask diff --git a/project/build.properties b/project/build.properties index c0bab049..080a737e 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.3.0 diff --git a/project/plugins.sbt b/project/plugins.sbt index 57a656c8..6165df3c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.0.0") +addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.1.2")