Skip to content

Commit 54a9c3a

Browse files
authored
Merge pull request #117 from kkebo/add-macos-ci
ci: add build-macos
2 parents eda74fc + 3e10b10 commit 54a9c3a

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ jobs:
2020
- run: ./scripts/ci-install-swift.sh
2121
- run: swift --version
2222
- run: swift build -c release --triple aarch64-none-none-elf --toolset toolset.json
23+
build-macos:
24+
runs-on: macos-26
25+
steps:
26+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
27+
- run: ./scripts/ci-install-swift.sh
28+
- run: swift --version
29+
- run: swift build -c release --triple aarch64-none-none-elf --toolset toolset.json
2330
lint:
2431
runs-on: ubuntu-24.04-arm
2532
steps:
@@ -38,4 +45,4 @@ jobs:
3845
steps:
3946
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4047
- run: shellcheck -V
41-
- run: git ls-files -z '*.sh' | xargs -0 --no-run-if-empty shellcheck
48+
- run: git ls-files -z '*.sh' | xargs -0 --no-run-if-empty shellcheck -x

scripts/ci-install-swift.sh

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,46 @@
22

33
set -euxo pipefail
44

5-
sudo apt-get update && sudo apt-get install --no-install-recommends -y libcurl4-openssl-dev
5+
install_swiftly_macos() {
6+
curl -O https://download.swift.org/swiftly/darwin/swiftly.pkg
7+
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory
8+
~/.swiftly/bin/swiftly init -y --skip-install -n
9+
# shellcheck source=/dev/null
10+
. "$HOME/.swiftly/env.sh"
11+
hash -r
12+
}
613

7-
curl -O "https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz"
8-
tar zxf "swiftly-$(uname -m).tar.gz"
9-
./swiftly init -y --skip-install -n
10-
# shellcheck disable=SC1091
11-
. "$HOME/.local/share/swiftly/env.sh"
12-
hash -r
14+
install_swiftly_linux() {
15+
curl -O "https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz"
16+
tar zxf "swiftly-$(uname -m).tar.gz"
17+
./swiftly init -y --skip-install -n
18+
# shellcheck source=/dev/null
19+
. "$HOME/.local/share/swiftly/env.sh"
20+
hash -r
21+
}
1322

14-
echo "PATH=$PATH" >> "$GITHUB_ENV" && echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> "$GITHUB_ENV" && echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> "$GITHUB_ENV" && echo "SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR" >> "$GITHUB_ENV"
23+
if [[ "$(uname)" == "Darwin" ]]; then
24+
install_swiftly_macos
25+
elif [[ -f /etc/os-release ]]; then
26+
# shellcheck source=/etc/os-release
27+
. /etc/os-release
28+
if [[ "$NAME" == "Ubuntu" ]]; then
29+
sudo apt-get update && sudo apt-get install --no-install-recommends -y libcurl4-openssl-dev
30+
install_swiftly_linux
31+
else
32+
echo "Unsupported Linux Distribution: $NAME"
33+
exit 1
34+
fi
35+
else
36+
echo "Unsupported OS: $(uname)"
37+
exit 1
38+
fi
39+
40+
cat <<EOF >> "$GITHUB_ENV"
41+
PATH=$PATH
42+
SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR
43+
SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR
44+
SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR
45+
EOF
1546

1647
swiftly install -y

0 commit comments

Comments
 (0)