|
| 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 |
0 commit comments