Skip to content

Commit bb3a3e0

Browse files
committedOct 3, 2020
Install .swift-version toolchain on CI
1 parent 8cc56bf commit bb3a3e0

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed
 

‎.github/workflows/test.yml

-8
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ jobs:
66
strategy:
77
matrix:
88
os: [macOS-10.15, Ubuntu-18.04]
9-
include:
10-
- os: macOS-10.15
11-
toolchain: https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.3-SNAPSHOT-2020-08-10-a/swift-wasm-5.3-SNAPSHOT-2020-08-10-a-osx.tar.gz
12-
- os: Ubuntu-18.04
13-
toolchain: https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.3-SNAPSHOT-2020-08-10-a/swift-wasm-5.3-SNAPSHOT-2020-08-10-a-linux.tar.gz
149
runs-on: ${{ matrix.os }}
1510
steps:
1611
- name: Checkout
@@ -23,8 +18,5 @@ jobs:
2318
export SWIFTENV_ROOT="$HOME/.swiftenv"
2419
export PATH="$SWIFTENV_ROOT/bin:$PATH"
2520
eval "$(swiftenv init -)"
26-
swiftenv install $TOOLCHAIN_DOWNLOAD
2721
make bootstrap
2822
make test
29-
env:
30-
TOOLCHAIN_DOWNLOAD: ${{ matrix.toolchain }}

‎Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
22

33
.PHONY: bootstrap
44
bootstrap:
5+
./scripts/install-toolchain.sh
56
npm install
67

78
.PHONY: build

‎scripts/install-toolchain.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
scripts_dir="$(cd "$(dirname $0)" && pwd)"
5+
6+
swift_version="$(cat $scripts_dir/../.swift-version)"
7+
swift_tag="swift-$swift_version"
8+
9+
if [ -z "$(which swiftenv)" ]; then
10+
echo "swiftenv not installed, please install it before this script."
11+
exit 1
12+
fi
13+
14+
if [ ! -z "$(swiftenv versions | grep $swift_version)" ]; then
15+
echo "$swift_version is already installed."
16+
exit 0
17+
fi
18+
19+
case $(uname -s) in
20+
Darwin)
21+
toolchain_download="$swift_tag-osx.tar.gz"
22+
;;
23+
Linux)
24+
if [ $(grep RELEASE /etc/lsb-release) == "DISTRIB_RELEASE=18.04" ]; then
25+
toolchain_download="$swift_tag-ubuntu18.04.tar.gz"
26+
elif [ $(grep RELEASE /etc/lsb-release) == "DISTRIB_RELEASE=20.04" ]; then
27+
toolchain_download="$swift_tag-ubuntu20.04.tar.gz"
28+
else
29+
echo "Unknown Ubuntu version"
30+
exit 1
31+
fi
32+
;;
33+
*)
34+
echo "Unrecognised platform $(uname -s)"
35+
exit 1
36+
;;
37+
esac
38+
39+
toolchain_download_url="https://github.com/swiftwasm/swift/releases/download/$swift_tag/$toolchain_download"
40+
41+
swiftenv install "$toolchain_download_url"

0 commit comments

Comments
 (0)