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 each new revisions and on new tags, so a tagged revision is built
8
+ # twice. Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds.
9
+ # Checking the local clone would not work because git on travis does not fetch tags.
9
10
10
- if [ " $TRAVIS_JDK_VERSION " == " $PUBLISH_JDK " ] && [[ " $TRAVIS_TAG " =~ ^v[0-9]+\. [0-9]+\. [0-9]+ (-[A-Za-z0-9-]+)? ]]; then
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_JDK_VERSION " == " $PUBLISH_JDK " ] && [[ " $TRAVIS_TAG " =~ $tagPat ]]; then
11
22
echo " Going to release from tag $TRAVIS_TAG !"
12
- myVer=$( echo $TRAVIS_TAG | sed -e s/^v//)
13
- 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
+
14
32
extraTarget= " +publish-signed"
15
33
cat admin/gpg.sbt >> project/plugins.sbt
16
34
cp admin/publish-settings.sbt .
@@ -22,4 +40,4 @@ if [ "$TRAVIS_JDK_VERSION" == "$PUBLISH_JDK" ] && [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.
22
40
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -o ut admin/secring.asc -d
23
41
fi
24
42
25
- sbt " $publishVersion " clean update +test +publishLocal $extraTarget
43
+ sbt " $publishVersion " " $publishScalaVersion " clean update +test +publishLocal $extraTarget
0 commit comments