1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#!/bin/bash -e
# NOTE: this is a quick backport of the 2.11.x script to 2.10.x -- some comments may be out dated
# requirements:
# - ~/.sonatype-curl that consists of user = USER:PASS
# - ~/.credentials (for sonatype)
# realm=Sonatype Nexus Repository Manager
# host=oss.sonatype.org
# user=lamp
# password=
# publishToSonatype
# set to anything but "yes" to avoid publishing to sonatype
# overridden to "no" when no SCALA_VER_BASE is passed and HEAD is not tagged with a valid version tag
#
baseDir=${WORKSPACE-`pwd`}
scriptsDir="$baseDir/scripts"
. $scriptsDir/common
##### sonatype interface
stApi="https://oss.sonatype.org/service/local"
function st_curl(){
curl -H "Content-Type: application/json" -H "accept: application/json,application/vnd.siesta-error-v1+json,application/vnd.siesta-validation-errors-v1+json" -K ~/.sonatype-curl -s -o - $@
}
function st_stagingReposOpen() {
st_curl "$stApi/staging/profile_repositories" | jq '.data[] | select(.profileName == "org.scala-lang") | select(.type == "open")'
}
function st_stagingRepoDrop() {
repo=$1
message=$2
echo "{\"data\":{\"description\":\"$message\",\"stagedRepositoryIds\":[\"$repo\"]}}" | st_curl -X POST -d @- "$stApi/staging/bulk/drop"
}
function st_stagingRepoClose() {
repo=$1
message=$2
echo "{\"data\":{\"description\":\"$message\",\"stagedRepositoryIds\":[\"$repo\"]}}" | st_curl -X POST -d @- "$stApi/staging/bulk/close"
}
## BUILD STEPS:
determineScalaVersion() {
cd $WORKSPACE
if [ -z "$SCALA_VER_BASE" ]; then
echo "No SCALA_VER_BASE specified."
scalaTag=$(git describe --exact-match ||:)
SCALA_BINARY_VER=${SCALA_BINARY_VER-"$scala_binary_version"}
if [ -z "$scalaTag" ]
then
echo "No tag found, building nightly snapshot."
parseScalaProperties "build.number"
SCALA_VER_BASE="$version_major.$version_minor.$version_patch"
SCALA_VER_SUFFIX="-$(git rev-parse --short HEAD)-nightly"
SCALADOC_SOURCE_LINKS_VER=$(git rev-parse HEAD)
# TODO: publish nightly snapshot using this script
publishToSonatype="no"
echo "repo_ref=2.11.x" >> $baseDir/jenkins.properties # for the -dist downstream jobs that build the actual archives
else
echo "HEAD is tagged as $scalaTag."
# borrowed from https://github.com/cloudflare/semver_bash/blob/master/semver.sh
local RE='v*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)' # don't change this to make it more accurate, it's not worth it
SCALA_VER_BASE="$(echo $scalaTag | sed -e "s#$RE#\1.\2.\3#")"
SCALA_VER_SUFFIX="$(echo $scalaTag | sed -e "s#$RE#\4#")"
SCALADOC_SOURCE_LINKS_VER=$scalaTag
if [ "$SCALA_VER_BASE" == "$scalaTag" ]; then
echo "Could not parse version $scalaTag"
exit 1
fi
publishToSonatype=${publishToSonatype-"yes"} # unless forced previously, publish
fi
else
publishToSonatype=${publishToSonatype-"yes"} # unless forced previously, publish
# if version base/suffix are provided, we assume a corresponding tag exists for the scaladoc source links
SCALADOC_SOURCE_LINKS_VER="v$SCALA_VER_BASE$SCALA_VER_SUFFIX"
fi
SCALA_VER="$SCALA_VER_BASE$SCALA_VER_SUFFIX"
echo "version=$SCALA_VER" >> $baseDir/jenkins.properties
echo "sbtDistVersionOverride=-Dproject.version=$SCALA_VER" >> $baseDir/jenkins.properties
echo "Building Scala $SCALA_VER."
}
distro() {
cd $WORKSPACE
echo "### Building the distribution"
ant -Dmaven.version.number=$SCALA_VER\
-Dbuild.release=1\
-Dscaladoc.git.commit=$SCALADOC_SOURCE_LINKS_VER\
distpack-opt
(cd $WORKSPACE/dists/ && tar cvzhf ../scala-dist-$SCALA_VER.tar.gz .)
s3Upload scala-dist-$SCALA_VER.tar.gz
}
s3Upload() {
file="$1"
contentType="application/x-compressed-tar"
host=$(grep host ~/.s3credentials | cut -d= -f2)
s3curl --id typesafe --contentType "${contentType}" --put "${file}" -- -k https://${host}/scala/tmp/${file}
}
# assumes we just bootstrapped, and current directory is $baseDir
# publishes locker to sonatype, then builds modules again (those for which version numbers were provided),
# and publishes those to sonatype as well
# finally, the staging repos are closed
publishSonatype() {
# stage to sonatype, along with all modules -Dmaven.version.suffix/-Dbuild.release not necessary,
# since we're just publishing an existing build
echo "### Publishing to sonatype"
(cd $WORKSPACE/dists/maven/latest/ && ant deploy.signed)
open=$(st_stagingReposOpen)
allOpenUrls=$(echo $open | jq '.repositoryURI' | tr -d \")
allOpen=$(echo $open | jq '.repositoryId' | tr -d \")
echo "Closing open repos: $allOpen"
for repo in $allOpen; do st_stagingRepoClose $repo; done
echo "Closed sonatype staging repos: $allOpenUrls."
}
#### MAIN
determineScalaVersion
distro
if [ "$publishToSonatype" == "yes" ]
then publishSonatype
fi
|