@@ -4,16 +4,14 @@ description: Installs the Swift specified by a .swift-version file
44runs :
55 using : " composite"
66 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
13- env :
14- DEBIAN_FRONTEND : noninteractive
7+ - name : " Cache: Swift"
8+ id : cache-swift
9+ uses : actions/cache@v4
10+ with :
11+ path : " $HOME/.local/share/swiftly"
12+ key : swift-${{ hashFiles('.swift-version') }}
1513
16- - name : Install Swiftly
14+ - name : Setup Environment
1715 shell : bash
1816 run : |
1917 export SWIFTLY_HOME_DIR="$HOME/.local/share/swiftly"
2422 echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $GITHUB_ENV
2523 echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $HOME/.bashrc
2624
25+ echo "PATH=$SWIFTLY_BIN_DIR:$PATH" >> $GITHUB_ENV
26+ echo "PATH=\$SWIFTLY_BIN_DIR:\$PATH" >> $HOME/.bashrc
27+
28+ - if : steps.cache-swift.outputs.cache-hit != 'true'
29+ name : Install `apt` Dependencies
30+ shell : bash
31+ run : |
32+ SUDO=$(if [[ $EUID -ne 0 ]]; then echo sudo; fi)
33+ $SUDO apt-get -qq update
34+ $SUDO apt-get -qq -y install curl gpg
35+ env :
36+ DEBIAN_FRONTEND : noninteractive
37+
38+ - if : steps.cache-swift.outputs.cache-hit != 'true'
39+ name : Install Swiftly
40+ shell : bash
41+ run : |
2742 UNAME=$(uname -m)
2843 curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
2944 tar zxf "swiftly-$UNAME.tar.gz"
@@ -33,11 +48,11 @@ runs:
3348 --quiet-shell-followup \
3449 --no-modify-profile
3550
36- echo "PATH=$SWIFTLY_BIN_DIR:$PATH" >> $GITHUB_ENV
37- echo "PATH=\$SWIFTLY_BIN_DIR:\$PATH" >> $HOME/.bashrc
51+ - if : steps.cache-swift.outputs.cache-hit != 'true'
52+ name : Install Swift
53+ shell : bash
54+ run : swiftly install --post-install-file ./out.sh
3855
39- - name : Install Swift
56+ - name : Print Swift Version
4057 shell : bash
41- run : |
42- swiftly install --post-install-file ./out.sh
43- swift --version
58+ run : swift --version
0 commit comments