diff --git a/.travis.yml b/.travis.yml index 17d401c0..31fbad2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,28 +6,21 @@ scala: - 2.13.0 env: - global: - # PGP_PASSPHRASE - - secure: "SkBtn/6OjEldoikn0MFuyeLT/pau27kwKSDYTVQeJ4BKDzdWLwLE5Q3RukLGttIfNdhOvRoocpQSW9GkZfibTHmwrRnAokucfZCqTsKbwoOp1xIoOh5GrrVrB6gcP7WBTKinqFdBgSvLOrP7GviImz4ZuB9wq1r+mToGG4pDrXc=" - # SONA_USER - - secure: "JSv/Er6q1XtTpRH1bpU63YBf7ufwg0vW+Kv/udQBtr8YX/P3gRYC1x6hW4uwftaKMYh7wXDkfNy51SRpH3kUptdJvjPUifVElyPiYlsumetmD+rZJmxX6agx+U5pdjIXPqPoton9MdSVHNTROeTu339bDak0Z+N5ht5wRfjP7F4=" - # SONA_PASS - - secure: "OIVtcj7AHZr8Grpf03ZmZsygcADewiYIvSnRwLYCx+5AqOzs39EZ68DsIOxi7wEXVUbVj5RvLXpKzLX3iN+UszLOQRoFPFQyyn+3Y50f8T2aRxdZtInzXn0sCVTj4Hhd/zbKl1W+2Nh3Sqazab7tFoQVzEyYqhcPeiNRMF7h+aY=" - matrix: - # The empty SCALAJS_VERSION will only compile for the JVM - - SCALAJS_VERSION= ADOPTOPENJDK=8 - - SCALAJS_VERSION=0.6.28 ADOPTOPENJDK=8 - - SCALAJS_VERSION=1.0.0-M8 ADOPTOPENJDK=8 - - SCALAJS_VERSION= ADOPTOPENJDK=11 + - ADOPTOPENJDK=8 SCALAJS_VERSION= + - ADOPTOPENJDK=8 SCALAJS_VERSION=0.6.28 + - ADOPTOPENJDK=8 SCALAJS_VERSION=1.0.0-M8 + - ADOPTOPENJDK=11 SCALAJS_VERSION= matrix: include: - - env: SCALANATIVE_VERSION=0.3.9 ADOPTOPENJDK=8 - - env: SCALANATIVE_VERSION=0.4.0-M2 ADOPTOPENJDK=8 + - scala: 2.11.12 + env: ADOPTOPENJDK=8 SCALANATIVE_VERSION=0.3.9 + - scala: 2.11.12 + env: ADOPTOPENJDK=8 SCALANATIVE_VERSION=0.4.0-M2 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/" + - "[[ -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" @@ -36,9 +29,9 @@ install: - sdk install java $(sdk list java | grep -o "$ADOPTOPENJDK\.[0-9\.]*hs-adpt" | head -1) - unset JAVA_HOME - java -Xmx32m -version - - javac -J-Xmx32m -version + - git fetch --tags # get all tags for sbt-dynver -script: admin/build.sh +script: ./build.sh notifications: email: @@ -46,11 +39,11 @@ notifications: - seth.tisue@lightbend.com before_cache: - - find $HOME/.sbt -name "*.lock" | xargs rm - - find $HOME/.ivy2/cache -name "ivydata-*.properties" | xargs rm + - rm -fv $HOME/.ivy2/.sbt.ivy.lock + - find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete + - find $HOME/.sbt -name "*.lock" -print -delete cache: directories: - $HOME/.ivy2/cache - - $HOME/.sbt/boot - - $HOME/.sbt/launchers + - $HOME/.sbt - $HOME/.sdkman diff --git a/admin/README.md b/admin/README.md deleted file mode 100644 index 83b93b7d..00000000 --- a/admin/README.md +++ /dev/null @@ -1,66 +0,0 @@ -## Tag Driven Releasing - -### 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. - Ensure that `RELEASE_COMBO` is `true` for build matrix combinations - that should be released to sonatype (when building a tag). - -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: - - oraclejdk8 - - openjdk11 - -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 the travis build matrix where `[ "$RELEASE_COMBO" = "true" ]`. - - If you need to release against a different Scala version, create a new commit that modifies - `.travis.yml` and push a new tag, e.g., `v1.2.3#2.13.0-M5`. The suffix after `#` is ignored. - 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 a22cb331..00000000 --- a/admin/build.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -set -e - -# Builds of tagged revisions are published to sonatype staging. - -# Travis runs a build on new revisions, including on new tags. -# 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 the travis matrix where -# [ "$RELEASE_COMBO" = "true" ]. - -# In order to build a previously released version against a new (binary incompatible) Scala release, -# add a new commit that modifies (and prunes) the Scala versions in .travis.yml on top of the existing tag. -# Then add a new tag for that commit, e.g., `v1.1.2#2.13.0-M5`. or `v1.1.2#native`. Everything after the `#` -# in the tag name is ignored. Push the tag (the commit doesn't need to be on any branch). - -if [[ "$SCALANATIVE_VERSION" != "" ]]; then - if [[ "$TRAVIS_JDK_VERSION" == "oraclejdk8" && "$TRAVIS_SCALA_VERSION" =~ 2\.11\..* ]]; then - RELEASE_COMBO=true; - fi -elif [[ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]]; then - RELEASE_COMBO=true; -fi - -if ! [ "$SCALAJS_VERSION" == "" ]; then - projectPrefix="scala-parser-combinatorsJS" -elif ! [ "$SCALANATIVE_VERSION" == "" ]; then - projectPrefix="scala-parser-combinatorsNative" -else - projectPrefix="scala-parser-combinators" -fi - -verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?" -tagPat="^v$verPat(#.*)?$" - -if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then - tagVer=${TRAVIS_TAG} - tagVer=${tagVer#v} # Remove `v` at beginning. - tagVer=${tagVer%%#*} # Remove anything after `#`. - publishVersion='set every version := "'$tagVer'"' - - if [ "$RELEASE_COMBO" = "true" ]; then - currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//') - echo "Releasing $tagVer with Scala $TRAVIS_SCALA_VERSION on Java version $currentJvmVer." - - publishTask="$projectPrefix/publishSigned" - - cat admin/gpg.sbt >> project/plugins.sbt - cp admin/publish-settings.sbt . - - # Copied from the output of genKeyPair.sh - K=$encrypted_5e972ec514e2_key - IV=$encrypted_5e972ec514e2_iv - - openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d - fi -fi - -sbt "++$TRAVIS_SCALA_VERSION" "$publishVersion" "$projectPrefix/update" "$projectPrefix/compile" "$projectPrefix/test" "$projectPrefix/publishLocal" "$publishTask" 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 f11b56ad..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") - -Global / 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 f6c13e89..00000000 --- a/admin/pubring.asc +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: BCPG v1.49 - -mQENBFVQwAoBCACr9atY5vDPbvYEMO8D4OvBz/YTP/tr43S/ibYIL2SAAZXvoVht -5BRAw063HqeM74U58isdbrt33VfmmJSJ0lVJX3iJ6dJeRO66az4aiqUckDP1JyVx -S3PJc402PcnF2Is849DHJF8AutIiAVnXa+gD5j/BShA6UZek9LqM9SRIl0SwE4Xo -WfMGdfvgQFl2vKJohrUbpKIYnhPa4HEu9FUFjVWn4iemeUVZ5OWzfEWNymrWDdLC -q5j1YMfjVvrtT3DhQD+HnDM4l5FNFxl7DHJkeMZZl+pp6RxS++m+/xMK5WmGj2Un -JUKzdoXGJdBA2q3erk5Dq6++ivvLqABt2J8DABEBAAG0O3NjYWxhLXBhcnNlci1j -b21iaW5hdG9ycyA8c2NhbGEtaW50ZXJuYWxzQGdvb2dsZWdyb3Vwcy5jb20+iQEc -BBMBAgAGBQJVUMAKAAoJEHCQr0Ol4Q0LX7MH/1GTgBitKA/RNXK04k//P9U4k7bX -ofJDUrtwx+WNg2bi2er6RQhsWPWQ3p/clgK7by93XkgDrBPLsUTIUTCHGa/Dn9R+ -h5syQfjI5iDi1AZ47ARmSZisadG6RAzLNewQUFcYwBTmGxLBrGBjcxvrmUN1XLml -jA4mqzvApDvwMrzWKdE6eNBf7G2k4dlwG4AzkSNMHfCDFXUgqsqvodrAp+WmGpbN -kZzrAVYoZtfKfalakjZDdn6EqKgw0VgZynSCX1gfwrwLric12fCBWbqXARiMVaM2 -EUqbFszdNRkD/TT9vDIabQqZvLsJO6Ql50hrOJ7IPoEmxJukuS64Je/AYiM= -=iDWo ------END PGP PUBLIC KEY BLOCK----- diff --git a/admin/secring.asc.enc b/admin/secring.asc.enc deleted file mode 100644 index fd45d256..00000000 Binary files a/admin/secring.asc.enc and /dev/null differ diff --git a/build.sbt b/build.sbt index 94e151e4..bb726b57 100644 --- a/build.sbt +++ b/build.sbt @@ -1,22 +1,14 @@ -import ScalaModulePlugin._ import sbtcrossproject.CrossPlugin.autoImport.crossProject -crossScalaVersions in ThisBuild := List("2.12.9", "2.11.12", "2.13.0") - useCoursier in ThisBuild := !scalaVersion.value.startsWith("2.11.") // https://github.com/sbt/sbt/issues/4995 -lazy val root = project.in(file(".")) - .aggregate(`scala-parser-combinatorsJS`, `scala-parser-combinatorsJVM`, `scala-parser-combinatorsNative`) - .settings(disablePublishing) - -lazy val `scala-parser-combinators` = crossProject(JSPlatform, JVMPlatform, NativePlatform) +lazy val parserCombinators = crossProject(JVMPlatform, JSPlatform, NativePlatform) .withoutSuffixFor(JVMPlatform).in(file(".")) - .settings(scalaModuleSettings: _*) - .jvmSettings(scalaModuleSettingsJVM) + .settings(ScalaModulePlugin.scalaModuleSettings) + .jvmSettings(ScalaModulePlugin.scalaModuleSettingsJVM) .settings( name := "scala-parser-combinators", - version := "1.2.0-SNAPSHOT", - mimaPreviousVersion := None, + scalaModuleMimaPreviousVersion := None, apiMappings += (scalaInstance.value.libraryJar -> url(s"https://www.scala-lang.org/api/${scalaVersion.value}/")), @@ -60,7 +52,3 @@ lazy val `scala-parser-combinators` = crossProject(JSPlatform, JVMPlatform, Nati else libraryDependencies.value } ) - -lazy val `scala-parser-combinatorsJVM` = `scala-parser-combinators`.jvm -lazy val `scala-parser-combinatorsJS` = `scala-parser-combinators`.js -lazy val `scala-parser-combinatorsNative` = `scala-parser-combinators`.native diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..6ae94e10 --- /dev/null +++ b/build.sh @@ -0,0 +1,75 @@ +#!/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" && "$TRAVIS_SCALA_VERSION" =~ ^2\.1[01234]\..*$ ]]; 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 +} + +if [[ "$SCALAJS_VERSION" != "" ]]; then + projectPrefix="parserCombinatorsJS" +elif [[ "$SCALANATIVE_VERSION" != "" ]]; then + projectPrefix="parserCombinatorsNative" +else + projectPrefix="parserCombinators" +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="$projectPrefix/publishSigned" +export CI_SNAPSHOT_RELEASE="$projectPrefix/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 $projectPrefix/test $projectPrefix/publishLocal $releaseTask diff --git a/project/plugins.sbt b/project/plugins.sbt index 9eba479a..6a1974ee 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,15 +1,13 @@ -addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.0.0") - val scalaJSVersion = Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("0.6.28") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) - val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).filter(_.nonEmpty).getOrElse("0.3.9") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) +addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.1.2") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "0.6.1") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)