Skip to content

Commit 61a6b65

Browse files
Install .swift-version toolchain on CI
1 parent 8cc56bf commit 61a6b65

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

.github/workflows/perf.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
export SWIFTENV_ROOT="$HOME/.swiftenv"
1717
export PATH="$SWIFTENV_ROOT/bin:$PATH"
1818
eval "$(swiftenv init -)"
19+
./scripts/install-toolchain.sh
1920
swiftenv install $TOOLCHAIN_DOWNLOAD
2021
make perf-tester
2122
node ci/perf-tester

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
export SWIFTENV_ROOT="$HOME/.swiftenv"
2424
export PATH="$SWIFTENV_ROOT/bin:$PATH"
2525
eval "$(swiftenv init -)"
26+
./scripts/install-toolchain.sh
2627
swiftenv install $TOOLCHAIN_DOWNLOAD
2728
make bootstrap
2829
make test

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)