1
1
#! /bin/bash
2
2
3
- # prep environment for publish to sonatype staging if the HEAD commit is tagged
3
+ set -e
4
4
5
- # git on travis does not fetch tags, but we have TRAVIS_TAG
6
- # headTag=$(git describe --exact-match ||:)
5
+ # Builds of tagged revisions are published to sonatype staging.
7
6
8
- if [[ " $TRAVIS_TAG " =~ ^v[0-9]+\. [0-9]+\. [0-9]+ (-[A-Za-z0-9-]+)? ]]; then
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.
10
+
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`.
13
+
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 version
16
+ # after a hash, e.g., v1.2.3#2.13.0-M1.
17
+
18
+ verPat=" [0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
19
+ tagPat=" ^v$verPat (#$verPat )?$"
20
+
21
+ if [[ " $TRAVIS_TAG " =~ $tagPat ]]; then
9
22
echo " Going to release from tag $TRAVIS_TAG !"
10
- myVer=$( echo $TRAVIS_TAG | sed -e s/^v//)
11
- publishVersion=' set every version := "' $myVer ' "'
23
+
24
+ tagVer=$( echo $TRAVIS_TAG | sed s/# .*// | sed s/^v//)
25
+ publishVersion=' set every version := "' $tagVer ' "'
26
+
27
+ scalaVer=$( echo $TRAVIS_TAG | sed s/[^# ]*// | sed s/^#//)
28
+ if [ " $scalaVer " != " " ]; then
29
+ publishScalaVersion=' set every crossScalaVersions := Seq("' $scalaVer ' ")'
30
+ fi
31
+
12
32
extraTarget= " +publish-signed"
13
33
14
34
cat admin/gpg.sbt >> project/plugins.sbt
15
35
admin/decrypt.sh sensitive.sbt
16
36
(cd admin/ && ./decrypt.sh secring.asc)
17
37
fi
18
38
19
- # the concurrentRestrictions should prevent spurious test failures, see https://github.com/spray/spray/pull/233
20
- sbt " $publishVersion " clean update +compile +test +publishLocal $extraTarget
39
+ sbt " $publishVersion " " $publishScalaVersion " clean update +test +publishLocal $extraTarget
0 commit comments