|  | 
| 4 | 4 | 
 | 
| 5 | 5 | # Builds of tagged revisions are published to sonatype staging. | 
| 6 | 6 | 
 | 
| 7 |  | -# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice. | 
|  | 7 | +# Travis runs a build on new revisions, including on new tags. | 
| 8 | 8 | # Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds. | 
| 9 | 9 | # Checking the local git clone would not work because git on travis does not fetch tags. | 
| 10 | 10 | 
 | 
| 11 | 11 | # The version number to be published is extracted from the tag, e.g., v1.2.3 publishes | 
| 12 |  | -# version 1.2.3 using all Scala versions in build.sbt's `crossScalaVersions`. | 
|  | 12 | +# version 1.2.3 using all Scala versions in the travis matrix where | 
|  | 13 | +# [ "$RELEASE_COMBO" = "true" ]. | 
| 13 | 14 | 
 | 
| 14 |  | -# When a new, binary incompatible Scala version becomes available, a previously released version | 
| 15 |  | -# can be released using that new Scala version by creating a new tag containing the Scala and the | 
| 16 |  | -# JVM version after hashes, e.g., v1.2.3#2.13.0-M1#8. The JVM version needs to be listed in | 
| 17 |  | -# `.travis.yml`, otherwise the required build doesn't run. | 
|  | 15 | +# In order to build a previously released version against a new (binary incompatible) Scala release, | 
|  | 16 | +# a new commit that modifies (and prunes) the Scala versions in .travis.yml needs to be added on top | 
|  | 17 | +# of the existing tag. Then a new tag can be created for that commit, e.g., `v1.2.3#2.13.0-M5`. | 
|  | 18 | +# Everything after the `#` in the tag name is ignored. | 
|  | 19 | + | 
|  | 20 | +if [[ "$SCALANATIVE_VERSION" != "" ]]; then | 
|  | 21 | +  if [[ "$TRAVIS_JDK_VERSION" == "oraclejdk8" && "$TRAVIS_SCALA_VERSION" =~ 2\.11\..* ]]; then | 
|  | 22 | +    RELEASE_COMBO=true; | 
|  | 23 | +  fi | 
|  | 24 | +elif [[ "$TRAVIS_JDK_VERSION" == "openjdk6" && "$TRAVIS_SCALA_VERSION" =~ 2\.11\..* \ | 
|  | 25 | +      || "$TRAVIS_JDK_VERSION" == "oraclejdk8" && "$TRAVIS_SCALA_VERSION" =~ 2\.1[23]\..* ]]; then | 
|  | 26 | +  RELEASE_COMBO=true; | 
|  | 27 | +fi | 
|  | 28 | + | 
|  | 29 | +if ! [ "$SCALAJS_VERSION" == "" ]; then | 
|  | 30 | +  projectPrefix="scala-parser-combinatorsJS" | 
|  | 31 | +elif ! [ "$SCALANATIVE_VERSION" == "" ]; then | 
|  | 32 | +  projectPrefix="scala-parser-combinatorsNative" | 
|  | 33 | +else | 
|  | 34 | +  projectPrefix="scala-parser-combinators" | 
|  | 35 | +fi | 
| 18 | 36 | 
 | 
| 19 | 37 | verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?" | 
| 20 | 38 | tagPat="^v$verPat(#$verPat#[0-9]+)?$" | 
| 21 | 39 | 
 | 
| 22 | 40 | if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then | 
| 23 |  | -  currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//') | 
| 24 |  | - | 
| 25 |  | -  tagVer=$(echo $TRAVIS_TAG | sed s/#.*// | sed s/^v//) | 
|  | 41 | +  tagVer=${TRAVIS_TAG} | 
|  | 42 | +  tagVer=${tagVer#v}   # Remove `v` at beginning. | 
|  | 43 | +  tagVer=${tagVer%%#*} # Remove anything after `#`. | 
| 26 | 44 |   publishVersion='set every version := "'$tagVer'"' | 
| 27 | 45 | 
 | 
| 28 |  | -  scalaAndJvmVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//) | 
| 29 |  | -  if [ "$scalaAndJvmVer" != "" ]; then | 
| 30 |  | -    scalaVer=$(echo $scalaAndJvmVer | sed s/#.*//) | 
| 31 |  | -    jvmVer=$(echo $scalaAndJvmVer | sed s/[^#]*// | sed s/^#//) | 
| 32 |  | -    if [ "$jvmVer" != "$currentJvmVer" ]; then | 
| 33 |  | -      echo "Not publishing $TRAVIS_TAG on Java version $currentJvmVer." | 
| 34 |  | -      exit 0 | 
| 35 |  | -    fi | 
| 36 |  | -    publishScalaVersion='set every ScalaModulePlugin.scalaVersionsByJvm := Map('$jvmVer' -> List("'$scalaVer'" -> true))' | 
| 37 |  | -    echo "Releasing $tagVer using Scala $scalaVer on Java version $jvmVer." | 
| 38 |  | -  else | 
| 39 |  | -    echo "Releasing $tagVer on Java version $currentJvmVer according to 'scalaVersionsByJvm' in build.sbt." | 
| 40 |  | -  fi | 
|  | 46 | +  if [ "$RELEASE_COMBO" = "true" ]; then | 
|  | 47 | +    currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//') | 
|  | 48 | +    echo "Releasing $tagVer with Scala $TRAVIS_SCALA_VERSION on Java version $currentJvmVer." | 
| 41 | 49 | 
 | 
| 42 |  | -  extraTarget="+publish-signed" | 
| 43 |  | -  cat admin/gpg.sbt >> project/plugins.sbt | 
| 44 |  | -  cp admin/publish-settings.sbt . | 
|  | 50 | +    publishTask="$projectPrefix/publish-signed" | 
| 45 | 51 | 
 | 
| 46 |  | -  # Copied from the output of genKeyPair.sh | 
| 47 |  | -  K=$encrypted_5e972ec514e2_key | 
| 48 |  | -  IV=$encrypted_5e972ec514e2_iv | 
|  | 52 | +    cat admin/gpg.sbt >> project/plugins.sbt | 
|  | 53 | +    cp admin/publish-settings.sbt . | 
| 49 | 54 | 
 | 
| 50 |  | -  openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d | 
|  | 55 | +    # Copied from the output of genKeyPair.sh | 
|  | 56 | +    K=$encrypted_5e972ec514e2_key | 
|  | 57 | +    IV=$encrypted_5e972ec514e2_iv | 
|  | 58 | + | 
|  | 59 | +    openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d | 
|  | 60 | +  fi | 
| 51 | 61 | fi | 
| 52 | 62 | 
 | 
| 53 | 63 | if [[ "$TRAVIS_JDK_VERSION" == "openjdk6" ]]; then | 
| 54 | 64 |   SBTOPTS="-Dsbt.override.build.repos=true -Dsbt.repository.config=./.sbtrepos" | 
| 55 | 65 | fi | 
| 56 | 66 | 
 | 
| 57 |  | -sbt $SBTOPTS "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget | 
|  | 67 | +sbt $SBTOPTS "++$TRAVIS_SCALA_VERSION" "$publishVersion" "$projectPrefix/update"  "$projectPrefix/compile" "$projectPrefix/test" "$projectPrefix/publishLocal" "$publishTask" | 
0 commit comments