@@ -4,16 +4,14 @@ description: Installs the Swift specified by a .swift-version file
4
4
runs :
5
5
using : " composite"
6
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
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') }}
15
13
16
- - name : Install Swiftly
14
+ - name : Setup Environment
17
15
shell : bash
18
16
run : |
19
17
export SWIFTLY_HOME_DIR="$HOME/.local/share/swiftly"
24
22
echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $GITHUB_ENV
25
23
echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $HOME/.bashrc
26
24
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 : |
27
42
UNAME=$(uname -m)
28
43
curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
29
44
tar zxf "swiftly-$UNAME.tar.gz"
@@ -33,11 +48,11 @@ runs:
33
48
--quiet-shell-followup \
34
49
--no-modify-profile
35
50
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
38
55
39
- - name : Install Swift
56
+ - name : Print Swift Version
40
57
shell : bash
41
- run : |
42
- swiftly install --post-install-file ./out.sh
43
- swift --version
58
+ run : swift --version
0 commit comments