Skip to content

Commit 38f38cb

Browse files
committed
Use Swiftly to install Swift (#108)
Updates the various GitHub workflows to use a common "Install Swift" action using swiftly and a .swift-version file at the repo root. This allows us to drop the swift version from each of the workflows and makes it easier for users to reproduec the CI environment. Future: - Add a workflow which auto updates this file. - Update READMEs to suggest install swift using swiftly.
1 parent 274a772 commit 38f38cb

File tree

8 files changed

+67
-60
lines changed

8 files changed

+67
-60
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'Install Swift'
2+
description: 'Installs the Swift specified by a .swift-version file'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Install apt dependencies
8+
shell: bash
9+
run: |
10+
SUDO=$(if [[ $EUID -ne 0 ]]; then echo sudo; fi)
11+
$SUDO apt-get -qq update
12+
$SUDO apt-get -qq -y install curl gpg binutils git unzip gnupg2 \
13+
libc6-dev libcurl4-openssl-dev libedit2 libgcc-13-dev libpython3-dev \
14+
libstdc++-13-dev libxml2-dev libncurses-dev libz3-dev pkg-config \
15+
tzdata zlib1g-dev
16+
env:
17+
DEBIAN_FRONTEND: noninteractive
18+
19+
- name: Install Swiftly
20+
shell: bash
21+
run: |
22+
UNAME=$(uname -m)
23+
24+
export SWIFTLY_HOME_DIR="$HOME/.local/share/swiftly"
25+
echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $GITHUB_ENV
26+
echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $HOME/.bashrc
27+
28+
export SWIFTLY_BIN_DIR="$HOME/.local/share/swiftly/bin"
29+
echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $GITHUB_ENV
30+
echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $HOME/.bashrc
31+
32+
curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
33+
tar zxf "swiftly-$UNAME.tar.gz"
34+
./swiftly init --skip-install --assume-yes --quiet-shell-followup
35+
36+
echo "PATH=$SWIFTLY_BIN_DIR:$PATH" >> $GITHUB_ENV
37+
echo "PATH=\$SWIFTLY_BIN_DIR:\$PATH" >> $HOME/.bashrc
38+
39+
- name: Install Swift
40+
shell: bash
41+
run: |
42+
swiftly install
43+
swift --version

.github/workflows/build-esp.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
build-esp:
1414
runs-on: ubuntu-24.04
1515
container: espressif/idf:latest
16+
1617
strategy:
1718
fail-fast: false
1819
matrix:
1920
example: [esp32-led-blink-sdk, esp32-led-strip-sdk]
20-
swift: [swift-DEVELOPMENT-SNAPSHOT-2024-12-04-a]
2121

2222
steps:
2323
- name: Checkout repo
@@ -26,13 +26,8 @@ jobs:
2626
- name: Install apt dependencies
2727
run: apt-get -qq update && apt-get -qq -y install pkg-config
2828

29-
- name: Install ${{ matrix.swift }}
30-
run: |
31-
wget -q https://download.swift.org/development/ubuntu2404/${{ matrix.swift }}/${{ matrix.swift }}-ubuntu24.04.tar.gz
32-
tar xzf ${{ matrix.swift }}-ubuntu24.04.tar.gz
33-
export PATH="`pwd`/${{ matrix.swift }}-ubuntu24.04/usr/bin/:$PATH"
34-
echo "PATH=$PATH" >> $GITHUB_ENV
35-
swiftc --version
29+
- name: Install Swift
30+
uses: ./.github/actions/install-swift
3631

3732
- name: Build ${{ matrix.example }}
3833
run: |

.github/workflows/build-nuttx.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
example: [nuttx-riscv-blink]
20-
swift: [swift-DEVELOPMENT-SNAPSHOT-2024-12-22-a]
2120

2221
steps:
2322
- name: Checkout repo
@@ -50,18 +49,11 @@ jobs:
5049
echo "PATH=$PATH" >> $GITHUB_ENV
5150
riscv-none-elf-gcc --version
5251
53-
- name: Install ${{ matrix.swift }}
54-
run: |
55-
wget -q https://download.swift.org/development/ubuntu2404/${{ matrix.swift }}/${{ matrix.swift }}-ubuntu24.04.tar.gz
56-
tar xzf ${{ matrix.swift }}-ubuntu24.04.tar.gz
57-
export PATH="`pwd`/${{ matrix.swift }}-ubuntu24.04/usr/bin/:$PATH"
58-
echo "PATH=$PATH" >> $GITHUB_ENV
59-
swiftc --version
60-
61-
- name: Config ${{ matrix.example }}
62-
working-directory: ${{ matrix.example }}
63-
run: cmake -B build -GNinja -DBOARD_CONFIG=rv-virt:leds_swift -DENABLE_NUTTX_TRACE=ON
52+
- name: Install Swift
53+
uses: ./.github/actions/install-swift
6454

6555
- name: Build ${{ matrix.example }}
6656
working-directory: ${{ matrix.example }}
67-
run: cmake --build build
57+
run: |
58+
cmake -B build -GNinja -DBOARD_CONFIG=rv-virt:leds_swift -DENABLE_NUTTX_TRACE=ON
59+
cmake --build build

.github/workflows/build-pico-sdk.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
jobs:
1313
build-pico-sdk:
1414
runs-on: ubuntu-24.04
15+
1516
strategy:
1617
fail-fast: false
1718
matrix:
@@ -22,7 +23,6 @@ jobs:
2223
board: pico_w
2324
- name: harmony
2425
board: pico_w
25-
swift: [swift-DEVELOPMENT-SNAPSHOT-2024-12-04-a]
2626

2727
steps:
2828
- name: Checkout repo
@@ -46,14 +46,8 @@ jobs:
4646
curl -sL https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-$ARCH-arm-none-eabi.tar.xz -O
4747
tar xf arm-gnu-toolchain-14.2.rel1-$ARCH-arm-none-eabi.tar.xz
4848
49-
- name: Install ${{ matrix.swift }}
50-
run: |
51-
wget -q https://download.swift.org/development/ubuntu2404/${{ matrix.swift }}/${{ matrix.swift }}-ubuntu24.04.tar.gz
52-
tar xzf ${{ matrix.swift }}-ubuntu24.04.tar.gz
53-
export PATH="`pwd`/${{ matrix.swift }}-ubuntu24.04/usr/bin/:$PATH"
54-
echo "PATH=$PATH" >> $GITHUB_ENV
55-
which swiftc
56-
swiftc --version
49+
- name: Install Swift
50+
uses: ./.github/actions/install-swift
5751

5852
- name: Clone Pico SDK
5953
run: |
@@ -78,7 +72,7 @@ jobs:
7872
echo "PICO_TOOLCHAIN_PATH=`pwd`/arm-gnu-toolchain-14.2.rel1-$ARCH-arm-none-eabi" >> $GITHUB_ENV
7973
8074
- name: Build ${{ matrix.example.name }}
75+
working-directory: ${{ matrix.example.name }}
8176
run: |
82-
cd ${{ matrix.example.name }}
8377
cmake -B build -G Ninja .
8478
cmake --build build

.github/workflows/build-rpi-baremetal.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ on:
88
schedule:
99
# Build on Mondays at 9am PST every week
1010
- cron: '0 17 * * 1'
11+
1112
jobs:
1213
build-rpi-baremetal:
1314
runs-on: ubuntu-24.04
15+
1416
strategy:
1517
fail-fast: false
1618
matrix:
17-
example: [rpi5-blink, rpi4b-blink]
18-
swift: [swift-DEVELOPMENT-SNAPSHOT-2024-12-04-a]
19+
example: [rpi4b-blink, rpi5-blink]
1920

2021
steps:
2122
- name: Checkout repo
@@ -24,16 +25,9 @@ jobs:
2425
- name: Install apt dependencies
2526
run: sudo apt-get -qq update && sudo apt-get -qq -y install make llvm
2627

27-
- name: Install ${{ matrix.swift }}
28-
run: |
29-
wget -q https://download.swift.org/development/ubuntu2404/${{ matrix.swift }}/${{ matrix.swift }}-ubuntu24.04.tar.gz
30-
tar xzf ${{ matrix.swift }}-ubuntu24.04.tar.gz
31-
export PATH="`pwd`/${{ matrix.swift }}-ubuntu24.04/usr/bin/:$PATH"
32-
echo "PATH=$PATH" >> $GITHUB_ENV
33-
which swiftc
34-
swiftc --version
28+
- name: Install Swift
29+
uses: ./.github/actions/install-swift
3530

3631
- name: Build ${{ matrix.example }}
37-
run: |
38-
cd ${{ matrix.example }}
39-
make
32+
working-directory: ${{ matrix.example }}
33+
run: make

.github/workflows/build-stm.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
example: [stm32-blink]
20-
swift: [swift-DEVELOPMENT-SNAPSHOT-2025-03-04-a]
2120

2221
steps:
2322
- name: Checkout repo
@@ -31,13 +30,8 @@ jobs:
3130
- name: Install uv
3231
uses: astral-sh/setup-uv@v5
3332

34-
- name: Install ${{ matrix.swift }}
35-
run: |
36-
wget -q https://download.swift.org/development/ubuntu2404/${{ matrix.swift }}/${{ matrix.swift }}-ubuntu24.04.tar.gz
37-
tar xzf ${{ matrix.swift }}-ubuntu24.04.tar.gz
38-
export PATH="`pwd`/${{ matrix.swift }}-ubuntu24.04/usr/bin/:$PATH"
39-
echo "PATH=$PATH" >> $GITHUB_ENV
40-
swiftc --version
33+
- name: Install Swift
34+
uses: ./.github/actions/install-swift
4135

4236
- name: Build ${{ matrix.example }}
4337
working-directory: ${{ matrix.example }}

.github/workflows/build-zephyr.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
example: [nrfx-blink-sdk]
20-
swift: [swift-DEVELOPMENT-SNAPSHOT-2024-12-04-a]
2120

2221
steps:
2322
- name: Checkout repo
@@ -34,13 +33,8 @@ jobs:
3433
app-path: ${{ matrix.example }}
3534
toolchains: arm-zephyr-eabi
3635

37-
- name: Install ${{ matrix.swift }}
38-
run: |
39-
wget -q https://download.swift.org/development/ubuntu2404/${{ matrix.swift }}/${{ matrix.swift }}-ubuntu24.04.tar.gz
40-
tar xzf ${{ matrix.swift }}-ubuntu24.04.tar.gz
41-
export PATH="`pwd`/${{ matrix.swift }}-ubuntu24.04/usr/bin/:$PATH"
42-
echo "PATH=$PATH" >> $GITHUB_ENV
43-
swiftc --version
36+
- name: Install Swift
37+
uses: ./.github/actions/install-swift
4438

4539
- name: Build ${{ matrix.example }}
4640
working-directory: ${{ matrix.example }}

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
main-snapshot-2025-04-12

0 commit comments

Comments
 (0)