77 - name : Setup Environment
88 shell : bash
99 run : |
10+ mkdir -p "$HOME/.local/share"
11+
1012 export SWIFTLY_TOOLCHAINS_DIR="$HOME/.local/share/swiftly/toolchains"
1113 echo "SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR" >> $GITHUB_ENV
1214 echo "SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR" >> $HOME/.bashrc
@@ -22,15 +24,15 @@ runs:
2224 echo "PATH=$SWIFTLY_BIN_DIR:$PATH" >> $GITHUB_ENV
2325 echo "PATH=\$SWIFTLY_BIN_DIR:\$PATH" >> $HOME/.bashrc
2426
25- - name : " Restore: Swift"
27+ - name : Restore Swift
2628 uses : actions/cache/restore@v4
2729 id : cache-swift
2830 with :
2931 path : " ~/.local/share/swiftly"
30- key : swift-${{ hashFiles('**/.swift-version') }}
32+ key : swift-${{ runner.os }}-${{ hashFiles('**/.swift-version', '.github/actions/install-swift/action.yml ') }}
3133
3234 - name : Install `apt` Dependencies
33- if : steps.cache-swift.outputs.cache-hit != 'true'
35+ if : runner.os == 'Linux' && steps.cache-swift.outputs.cache-hit != 'true'
3436 shell : bash
3537 run : |
3638 SUDO=$(if [[ $EUID -ne 0 ]]; then echo sudo; fi)
@@ -40,29 +42,47 @@ runs:
4042 DEBIAN_FRONTEND : noninteractive
4143
4244 - name : Install Swiftly
43- if : steps.cache-swift.outputs.cache-hit != 'true'
45+ if : runner.os == 'Linux' && steps.cache-swift.outputs.cache-hit != 'true'
4446 shell : bash
4547 run : |
48+ SWIFTLY_VERSION=1.0.1
4649 UNAME=$(uname -m)
47- curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
48- tar zxf "swiftly-$UNAME.tar.gz"
50+ SWIFTLY_TGZ=swiftly-$SWIFTLY_VERSION-$UNAME.tar.gz
51+ curl -O "https://download.swift.org/swiftly/linux/$SWIFTLY_TGZ"
52+ tar zxf "$SWIFTLY_TGZ"
4953 ./swiftly init \
5054 --skip-install \
5155 --assume-yes \
5256 --quiet-shell-followup \
5357 --no-modify-profile
5458
59+ - name : Install Swiftly
60+ if : runner.os == 'macOS' && steps.cache-swift.outputs.cache-hit != 'true'
61+ shell : bash
62+ run : |
63+ SWIFTLY_VERSION=1.0.1
64+ SWIFTLY_PKG=swiftly-$SWIFTLY_VERSION.pkg
65+ curl -O "https://download.swift.org/swiftly/darwin/$SWIFTLY_PKG"
66+ pkgutil --check-signature $SWIFTLY_PKG
67+ pkgutil --verbose --expand $SWIFTLY_PKG $SWIFTLY_HOME_DIR
68+ tar -C $SWIFTLY_HOME_DIR -xvf $SWIFTLY_HOME_DIR/swiftly-*/Payload
69+ "$SWIFTLY_BIN_DIR/swiftly" init \
70+ --skip-install \
71+ --assume-yes \
72+ --quiet-shell-followup \
73+ --no-modify-profile
74+
5575 - name : Install Swift
5676 if : steps.cache-swift.outputs.cache-hit != 'true'
5777 shell : bash
5878 run : swiftly install --post-install-file ./out.sh
5979
60- - name : " Save: Swift"
80+ - name : Save Swift
6181 if : steps.cache-swift.outputs.cache-hit != 'true'
6282 uses : actions/cache/save@v4
6383 with :
6484 path : " ~/.local/share/swiftly"
65- key : swift-${{ hashFiles('**/.swift-version') }}
85+ key : swift-${{ runner.os }}-${{ hashFiles('**/.swift-version', '.github/actions/install-swift/action.yml ') }}
6686
6787 - name : Print Swift Version
6888 shell : bash
0 commit comments