forked from 7mind/izumi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.build.sh
174 lines (138 loc) · 4.18 KB
/
.build.sh
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env bash
set -xe
# `++ 2.13.0 compile` has a different semantic than `;++2.13.0;compile`
# Strict aggregation applies ONLY to former,
# and ONLY if crossScalaVersions := Nil is set in root project and ALL nested aggregates
# see https://github.com/sbt/sbt/issues/3698#issuecomment-475955454
# and https://github.com/sbt/sbt/pull/3995/files
# TL;DR strict aggregation in sbt is broken; this is a workaround
SONATYPE_SECRET=.secrets/credentials.sonatype-nexus.properties
function scala3 {
echo "Using Scala 3..."
VERSION_COMMAND="++ $SCALA3 "
}
function scala213 {
echo "Using Scala 2.13..."
VERSION_COMMAND="++ $SCALA213 "
}
function scala212 {
echo "Using Scala 2.12..."
VERSION_COMMAND="++ $SCALA212 "
}
function scalaall {
VERSION_COMMAND="+"
}
function csbt {
COMMAND="time sbt -batch -no-colors -v $*"
eval $COMMAND
}
function coverage {
csbt "'${VERSION_COMMAND}clean'" coverage "'${VERSION_COMMAND}Test/compile'" "'${VERSION_COMMAND}test'" "'${VERSION_COMMAND}coverageReport'" || exit 1
}
function test {
csbt "'${VERSION_COMMAND}clean'" "'${VERSION_COMMAND}Test/compile'" "'${VERSION_COMMAND}test'" || exit 1
}
function site-publish {
if [[ "$CI_BRANCH" == "develop" || "$CI_TAG" =~ ^v.*$ ]] ; then
echo "Publishing site from branch=$CI_BRANCH; tag=$CI_BRANCH_TAG"
csbt "'project docs'" +clean "'${VERSION_COMMAND}ghpagesSynchLocal'" "'${VERSION_COMMAND}ghpagesPushSite'" || exit 1
else
echo "Skipping publishing site, because $CI_BRANCH is not 'develop' nor a tag"
return 0
fi
}
function site-test {
echo "Not publishing site, because $CI_BRANCH is not 'develop' nor a tag"
csbt "'project docs'" "'${VERSION_COMMAND}clean'" "'${VERSION_COMMAND}makeSite'" || exit 1
}
function publishScala {
#copypaste
if [[ "$CI_PULL_REQUEST" != "false" ]] ; then
echo "Skipping publish on pull request"
return 0
fi
if [[ ! -f "$SONATYPE_SECRET" ]] ; then
echo "Skipping publish on missing credentials"
return 0
fi
if [[ ! ("$CI_BRANCH" == "develop" || "$CI_BRANCH_TAG" =~ ^v.*$ ) ]] ; then
echo "Skipping publish on non-tag / non-develop branch"
return 0
fi
echo "PUBLISH SCALA LIBRARIES..."
if [[ "$CI_BRANCH_TAG" =~ ^v.*$ ]] ; then
echo "PUBLISH RELEASE"
csbt +clean "'${VERSION_COMMAND}package'" "'${VERSION_COMMAND}publishSigned'" sonatypeBundleRelease || exit 1
else
echo "PUBLISH SNAPSHOT"
csbt "'show credentials'" "'${VERSION_COMMAND}clean'" "'${VERSION_COMMAND}package'" "'${VERSION_COMMAND}publishSigned'" || exit 1
fi
}
function secrets {
if [[ "$CI_PULL_REQUEST" == "false" ]] ; then
echo "Unpacking secrets"
mkdir .secrets
echo "$SONATYPE_CREDENTIALS_FILE" > "$SONATYPE_SECRET"
openssl aes-256-cbc -K ${OPENSSL_KEY} -iv ${OPENSSL_IV} -in secrets.tar.enc -out secrets.tar -d
tar xvf secrets.tar
echo "Secrets unpacked"
else
echo "Skipping secrets"
fi
}
function init {
export SCALA211=$(cat project/Deps.sc | grep 'val scala211 ' | sed -r 's/.*\"(.*)\".**/\1/')
export SCALA212=$(cat project/Deps.sc | grep 'val scala212 ' | sed -r 's/.*\"(.*)\".**/\1/')
export SCALA213=$(cat project/Deps.sc | grep 'val scala213 ' | sed -r 's/.*\"(.*)\".**/\1/')
export SCALA3=$(cat project/Deps.sc | grep 'val scala300 ' | sed -r 's/.*\"(.*)\".**/\1/')
# details on github runners: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
export _JAVA_OPTIONS="-Xmx4000M -XX:ReservedCodeCacheSize=384M -XX:NonProfiledCodeHeapSize=256M -XX:MaxMetaspaceSize=1024M"
printenv
java -version
}
init
for i in "$@"
do
case $i in
nothing)
echo "Doing nothing..."
;;
3)
scala3
;;
2.13)
scala213
;;
2.12)
scala212
;;
2.11)
scala211
;;
scala-all)
scalaall
;;
coverage)
coverage
;;
test)
test
;;
publishScala)
publishScala
;;
site-publish)
site-publish
;;
site-test)
site-test
;;
secrets)
secrets
;;
*)
echo "Unknown option"
exit 1
;;
esac
done