diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2017-05-10 09:25:11 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-10 09:25:11 +1000 |
commit | 8492b9d4228b45276343fcc194c3cc4f94c74b7c (patch) | |
tree | bf8d69b6f46252515f2f56c556ecf3c97b87b567 /admin/build.sh | |
parent | 605760dbd421e648a0dae1d07517887f69e1caa8 (diff) | |
parent | 6afb291eea3dfadb889a3ea622d73457c2d4e3ef (diff) | |
download | scala-async-8492b9d4228b45276343fcc194c3cc4f94c74b7c.tar.gz scala-async-8492b9d4228b45276343fcc194c3cc4f94c74b7c.tar.bz2 scala-async-8492b9d4228b45276343fcc194c3cc4f94c74b7c.zip |
Merge pull request #170 from lrytz/module-pluginv0.9.6#2.13.0-M1#8
Use scala-module-plugin, update tag-based publishing
Diffstat (limited to 'admin/build.sh')
-rwxr-xr-x | admin/build.sh | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/admin/build.sh b/admin/build.sh index 3257da0..7cb5c34 100755 --- a/admin/build.sh +++ b/admin/build.sh @@ -1,19 +1,53 @@ #!/bin/bash -# prep environment for publish to sonatype staging if the HEAD commit is tagged +set -e -# git on travis does not fetch tags, but we have TRAVIS_TAG -# headTag=$(git describe --exact-match ||:) +# Builds of tagged revisions are published to sonatype staging. -if [ "$IS_PUBLISH_JDK" == "true" ] && [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then - echo "Going to release from tag $TRAVIS_TAG!" - myVer=$(echo $TRAVIS_TAG | sed -e s/^v// | sed -e 's/_[0-9]*\.[0-9]*//') - publishVersion='set every version := "'$myVer'"' - extraTarget="publish-signed" +# 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="+publish-signed" cat admin/gpg.sbt >> project/plugins.sbt - admin/decrypt.sh sensitive.sbt - (cd admin/ && ./decrypt.sh secring.asc) + cp admin/publish-settings.sbt . + + # Copied from the output of genKeyPair.sh + K=$encrypted_97ebac4c5d62_key + IV=$encrypted_97ebac4c5d62_iv + + openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d fi -sbt ++$TRAVIS_SCALA_VERSION "$publishVersion" clean update compile test $extraTarget +sbt "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget |