@@ -4,16 +4,15 @@ description: Installs the Swift specified by a .swift-version file
44runs :
55 using : " composite"
66 steps :
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') }}
13-
147 - name : Setup Environment
158 shell : bash
169 run : |
10+ mkdir -p "$HOME/.local/share"
11+
12+ export SWIFTLY_TOOLCHAINS_DIR="$HOME/.local/share/swiftly/toolchains"
13+ echo "SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR" >> $GITHUB_ENV
14+ echo "SWIFTLY_TOOLCHAINS_DIR=$SWIFTLY_TOOLCHAINS_DIR" >> $HOME/.bashrc
15+
1716 export SWIFTLY_HOME_DIR="$HOME/.local/share/swiftly"
1817 echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $GITHUB_ENV
1918 echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $HOME/.bashrc
@@ -25,15 +24,15 @@ runs:
2524 echo "PATH=$SWIFTLY_BIN_DIR:$PATH" >> $GITHUB_ENV
2625 echo "PATH=\$SWIFTLY_BIN_DIR:\$PATH" >> $HOME/.bashrc
2726
28- - name : " Restore: Swift"
27+ - name : Restore Swift
2928 uses : actions/cache/restore@v4
3029 id : cache-swift
3130 with :
3231 path : " ~/.local/share/swiftly"
33- key : swift-${{ hashFiles('**/.swift-version') }}
32+ key : swift-${{ runner.os }}-${{ hashFiles('**/.swift-version', '.github/actions/install-swift/action.yml ') }}
3433
3534 - name : Install `apt` Dependencies
36- if : steps.cache-swift.outputs.cache-hit != 'true'
35+ if : runner.os == 'Linux' && steps.cache-swift.outputs.cache-hit != 'true'
3736 shell : bash
3837 run : |
3938 SUDO=$(if [[ $EUID -ne 0 ]]; then echo sudo; fi)
@@ -43,29 +42,47 @@ runs:
4342 DEBIAN_FRONTEND : noninteractive
4443
4544 - name : Install Swiftly
46- if : steps.cache-swift.outputs.cache-hit != 'true'
45+ if : runner.os == 'Linux' && steps.cache-swift.outputs.cache-hit != 'true'
4746 shell : bash
4847 run : |
48+ SWIFTLY_VERSION=1.0.1
4949 UNAME=$(uname -m)
50- curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
51- 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"
5253 ./swiftly init \
5354 --skip-install \
5455 --assume-yes \
5556 --quiet-shell-followup \
5657 --no-modify-profile
5758
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+
5875 - name : Install Swift
5976 if : steps.cache-swift.outputs.cache-hit != 'true'
6077 shell : bash
6178 run : swiftly install --post-install-file ./out.sh
6279
63- - name : " Save: Swift"
80+ - name : Save Swift
6481 if : steps.cache-swift.outputs.cache-hit != 'true'
6582 uses : actions/cache/save@v4
6683 with :
6784 path : " ~/.local/share/swiftly"
68- key : swift-${{ hashFiles('**/.swift-version') }}
85+ key : swift-${{ runner.os }}-${{ hashFiles('**/.swift-version', '.github/actions/install-swift/action.yml ') }}
6986
7087 - name : Print Swift Version
7188 shell : bash
0 commit comments