|
2 | 2 |
|
3 | 3 | set -e
|
4 | 4 |
|
5 |
| -# prep environment for publish to sonatype staging if the HEAD commit is tagged |
| 5 | +# Builds of tagged revisions are published to sonatype staging. |
6 | 6 |
|
7 |
| -# git on travis does not fetch tags, but we have TRAVIS_TAG |
8 |
| -# headTag=$(git describe --exact-match ||:) |
| 7 | +# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice. |
| 8 | +# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds. |
| 9 | +# Checking the local git clone would not work because git on travis does not fetch tags. |
9 | 10 |
|
10 |
| -if [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then |
11 |
| - echo "Going to release from tag $TRAVIS_TAG!" |
12 |
| - myVer=$(echo $TRAVIS_TAG | sed -e s/^v//) |
13 |
| - publishVersion='set every version := "'$myVer'"' |
14 |
| - extraTarget="+publish-signed" |
15 |
| - cat admin/gpg.sbt >> project/plugins.sbt |
16 |
| - cp admin/publish-settings.sbt . |
| 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`. |
17 | 13 |
|
18 |
| - # Copied from the output of genKeyPair.sh |
19 |
| - K=$encrypted_5e972ec514e2_key |
20 |
| - IV=$encrypted_5e972ec514e2_iv |
| 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. |
21 | 18 |
|
22 |
| - openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d |
| 19 | +verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?" |
| 20 | +tagPat="^v$verPat(#$verPat#[0-9]+)?$" |
| 21 | + |
| 22 | +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//) |
| 26 | + publishVersion='set every version := "'$tagVer'"' |
| 27 | + scalaAndJvmVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//) |
| 28 | + if [ "$scalaAndJvmVer" != "" ]; then |
| 29 | + scalaVer=$(echo $scalaAndJvmVer | sed s/#.*//) |
| 30 | + jvmVer=$(echo $scalaAndJvmVer | sed s/[^#]*// | sed s/^#//) |
| 31 | + if [ "$jvmVer" != "$currentJvmVer" ]; then |
| 32 | + echo "Not publishing $TRAVIS_TAG on Java version $currentJvmVer." |
| 33 | + exit 0 |
| 34 | + fi |
| 35 | + publishScalaVersion='set every scalaVersionsByJvm := Map('$jvmVer' -> List("'$scalaVer'" -> true))' |
| 36 | + echo "Releasing $tagVer using Scala $scalaVer on Java version $jvmVer." |
| 37 | + else |
| 38 | + echo "Releasing $tagVer on Java version $currentJvmVer according to 'scalaVersionsByJvm' in build.sbt." |
| 39 | + fi |
| 40 | +
|
| 41 | +
|
| 42 | + extraTarget="+publish-signed" |
| 43 | + cat admin/gpg.sbt >> project/plugins.sbt |
| 44 | + cp admin/publish-settings.sbt . |
| 45 | +
|
| 46 | + # Copied from the output of genKeyPair.sh |
| 47 | + K=$encrypted_5e972ec514e2_key |
| 48 | + IV=$encrypted_5e972ec514e2_iv |
| 49 | +
|
| 50 | + openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d |
23 | 51 | fi
|
24 | 52 |
|
25 |
| -sbt "$publishVersion" clean update +test +publishLocal $extraTarget |
| 53 | +sbt "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget |
0 commit comments