Skip to content

Commit 37eb5db

Browse files
committed
Support for running 'archives' job
1 parent e06cc4c commit 37eb5db

File tree

6 files changed

+110
-21
lines changed

6 files changed

+110
-21
lines changed

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
# we need rpmbuild but it's unlikely to be whitelisted, according to
22
# https://github.com/travis-ci/apt-package-whitelist/pull/1700
33
sudo: required
4-
before_install:
4+
5+
install:
56
- sudo apt-get -qq update
67
- sudo apt-get install -y rpm
78

89
language: scala
910
jdk: oraclejdk8
1011

12+
env:
13+
global:
14+
# PRIV_KEY_SECRET
15+
- secure: "NlnFqZs4mvCi63GqCdUNDsx9BoiyrjgoV0cUaKlhVYp49/qAMlEaKf6JABWy/oCHoWsTyysyLEtZLsWfjAyE4+FUHSzngNUHVFBbtyudA6aKQ7jMsqkcMM/K0h+ymnhHSv8bugc8jXKFgmfYk4YTi5dZgv8CAOSQFAFUaxVdYTY="
16+
1117
script:
12-
- sbt -Dproject.version=2.12.0 "show s3Upload::mappings"
18+
- admin/build.sh
1319

1420
cache:
1521
directories:

admin/build.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# Triggering jobs for a release:
6+
# - Open https://travis-ci.org/scala/scala-dist
7+
# - On the right: "More options" - "Trigger build"
8+
# - Chose the branch and enter a title for the build in the commit message filed
9+
# - Add a `before_install` custom config (see below) to set the `mode` and `version` env vars.
10+
# Using an `env: global: ...` section does not work because that overrides the default `env`
11+
# from .travis.yml. There's no way to specify the "merge mode" (*) from the web UI, that only
12+
# works in the REST API. We use `before_install` and assume it's not used otherwise.
13+
# (*) https://docs.travis-ci.com/user/triggering-builds/#Customizing-the-build-configuration
14+
# - Available modes:
15+
# - `release` to build native packages and upload them to S3
16+
# - `archive` to copy archives to chara (for scala-lang.org)
17+
# - `update-api` to update the scaladoc api symlinks
18+
# In all of the above modes, the `version` needs to be specified.
19+
#
20+
# before_install:
21+
# - export version=2.12.4
22+
# - export mode=archives
23+
24+
25+
# Encryping files (if you need to encrypt a new file but no longer have the secret, create a new
26+
# secret and re-encrypt all files):
27+
#
28+
# 1. Generate secret
29+
# cat /dev/urandom | head -c 10000 | openssl sha1 > ./secret
30+
# 2. Save the secret on travis
31+
# travis encrypt "PRIV_KEY_SECRET=$(cat ./secret)"
32+
# 3. Encrypt the file
33+
# openssl aes-256-cbc -pass "file:./secret" -in jenkins_lightbend_chara -out jenkins_lightbend_chara.enc
34+
# 4. Decrypt the file
35+
# openssl aes-256-cbc -d -pass "pass:$PRIV_KEY_SECRET" -in admin/files/jenkins_lightbend_chara.enc > ~/.ssh/jenkins_lightbend_chara 2>/dev/null
36+
37+
38+
function ensureVersion() {
39+
local verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
40+
[[ "$version" =~ $verPat ]] || {
41+
echo "Not a valid Scala version: '$version'"
42+
exit 1
43+
}
44+
}
45+
46+
function decrypt() {
47+
# Even though we're running bash with -x, travis hides the private key from the log
48+
openssl aes-256-cbc -d -pass "pass:$PRIV_KEY_SECRET" -in $1 > $2 2>/dev/null
49+
}
50+
51+
function setupSSH() {
52+
mkdir -p ~/.ssh
53+
cp admin/files/ssh_config ~/.ssh/config
54+
echo 'chara.epfl.ch,128.178.154.107 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBLER9rqy0iCfz24+8BBBObh7FXXQJCoLLE9UuyQHNFUU4SS5FSzNjEoKXwTj8nqNy+8l0rOkj3KG8p2cLxsqjY=' >> ~/.ssh/known_hosts
55+
decrypt admin/files/jenkins_lightbend_chara.enc ~/.ssh/jenkins_lightbend_chara
56+
chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
57+
}
58+
59+
function setupS3() {
60+
echo "setup s3"
61+
}
62+
63+
if [[ "$TRAVIS_EVENT_TYPE" == "api" ]]; then
64+
ensureVersion
65+
if [[ isManualTrigger && "$mode" == "archives" ]]; then
66+
echo "Running 'archives' for $version"
67+
setupSSH
68+
ssh chara whoami
69+
# . scripts/jobs/release/website/archives
70+
elif [[ isManualTrigger && "$mode" == "update-api" ]]; then
71+
echo "Running 'update-api' for $version"
72+
setupSSH
73+
ssh chara whoami
74+
# . scripts/jobs/release/website/update-api
75+
elif [[ isManualTrigger && "$mode" == "release" ]]; then
76+
echo "Running a release for $version"
77+
setupS3
78+
else
79+
echo "Unknown build mode: '$mode'"
80+
exit 1
81+
fi
82+
else
83+
# By default, test building the packages (but don't uplaod)
84+
sbt -Dproject.version=2.12.4 "show s3Upload::mappings"
85+
fi
3.19 KB
Binary file not shown.

admin/files/ssh_config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Host chara
2+
HostName chara.epfl.ch
3+
IdentityFile /home/travis/.ssh/jenkins_lightbend_chara
4+
User scalatest

scripts/jobs/release/website/archives

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash -ex
2-
# need to re-declare it as an array, not sure how to do that directly in jenkins
3-
declare -a sshCharaArgs="$sshCharaArgs"
42

53
url="https://downloads.lightbend.com/scala/$version"
64

@@ -10,24 +8,23 @@ else archivesDir="~linuxsoft/archives/scala"
108
fi
119

1210
# make this build restartable (if interrupted, partial files may remain, and resuming isn't very reliable)
13-
[[ -n $version ]] && ssh "${sshCharaArgs[@]}" "rm -f $archivesDir/scala-*$version* && rm -rf $archivesDir/api/$version/ ||:"
11+
[[ -n $version ]] && ssh chara "rm -f $archivesDir/scala-*$version* && rm -rf $archivesDir/api/$version/ ||:"
1412

1513
cacheBuster="$(date +%s | tail -c2 | head -c1)"
16-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.msi '$url/scala-$version.msi?$cacheBuster'"
17-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.zip '$url/scala-$version.zip?$cacheBuster'"
18-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.tgz '$url/scala-$version.tgz?$cacheBuster'"
19-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.deb '$url/scala-$version.deb?$cacheBuster'"
20-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-$version.rpm '$url/scala-$version.rpm?$cacheBuster'"
21-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-docs-$version.zip '$url/scala-docs-$version.zip?$cacheBuster'"
22-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-docs-$version.tgz '$url/scala-docs-$version.tgz?$cacheBuster'"
23-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && wget -nv -O scala-docs-$version.txz '$url/scala-docs-$version.txz?$cacheBuster'"
14+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.msi '$url/scala-$version.msi?$cacheBuster'"
15+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.zip '$url/scala-$version.zip?$cacheBuster'"
16+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.tgz '$url/scala-$version.tgz?$cacheBuster'"
17+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.deb '$url/scala-$version.deb?$cacheBuster'"
18+
ssh chara "cd $archivesDir && wget -nv -O scala-$version.rpm '$url/scala-$version.rpm?$cacheBuster'"
19+
ssh chara "cd $archivesDir && wget -nv -O scala-docs-$version.zip '$url/scala-docs-$version.zip?$cacheBuster'"
20+
ssh chara "cd $archivesDir && wget -nv -O scala-docs-$version.tgz '$url/scala-docs-$version.tgz?$cacheBuster'"
21+
ssh chara "cd $archivesDir && wget -nv -O scala-docs-$version.txz '$url/scala-docs-$version.txz?$cacheBuster'"
2422

2523
echo "Expanding scala-library API docs for $version to api/$version (with subdirectories for scala-compiler and scala-reflect)."
26-
ssh "${sshCharaArgs[@]}" "cd $archivesDir && mkdir -p api/$version && tar -xvz --strip-component 2 -f scala-docs-$version.tgz -C api/$version && mv api/$version/scala-library/* api/$version/" # tar on jenkins does not support the -s option
24+
ssh chara "cd $archivesDir && mkdir -p api/$version && tar -xvz --strip-component 2 -f scala-docs-$version.tgz -C api/$version && mv api/$version/scala-library/* api/$version/" # tar on jenkins does not support the -s option
2725

2826
echo "Expanding the Scaladoc for other bundled modules"
2927
modules="scala-parser-combinators scala-swing scala-xml"
3028
for m in $modules; do
31-
ssh "${sshCharaArgs[@]}" "(set -x; cd $archivesDir && mkdir -p api/$version/$m && unzip \$(find api/$version/jars -name ${m}_'*javadoc.jar' -o -name ${m}-${version}-javadoc.jar) -d api/$version/$m;)"
29+
ssh chara "(set -x; cd $archivesDir && mkdir -p api/$version/$m && unzip \$(find api/$version/jars -name ${m}_'*javadoc.jar' -o -name ${m}-${version}-javadoc.jar) -d api/$version/$m;)"
3230
done
33-
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash -ex
2-
# need to re-declare it as an array, not sure how to do that directly in jenkins
3-
declare -a sshCharaArgs="$sshCharaArgs"
42

53
if [[ "$version" =~ ^.*-(bin|pre)-[0-9a-f]+$ ]]
64
then archivesDir="~linuxsoft/archives/scala/nightly/2.12.x"
@@ -9,8 +7,7 @@ fi
97

108
echo "Symlinking $archivesDir/api/$version to $archivesDir/api/2.12.x."
119

12-
ssh "${sshCharaArgs[@]}" "cd $archivesDir/api/ ; [[ -d $version ]] && ln -sfn $version 2.12.x"
10+
ssh chara "cd $archivesDir/api/ ; [[ -d $version ]] && ln -sfn $version 2.12.x"
1311

1412
# needs to run once on new major release:
15-
# ssh "${sshCharaArgs[@]}" "cd $archivesDir/api/ ; [[ -d $version ]] && ln -sfn 2.12.x current"
16-
13+
# ssh chara "cd $archivesDir/api/ ; [[ -d $version ]] && ln -sfn 2.12.x current"

0 commit comments

Comments
 (0)