File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -33,12 +33,27 @@ jobs:
33
33
- name : 🛠️ Setup Swift
34
34
uses : swift-actions/setup-swift@v2
35
35
36
+ - name : Cache Swift Format
37
+ uses : actions/cache@v4
38
+ with :
39
+ path : ~/.cache/swift-format
40
+ key : swift-format-${{ runner.os }}-${{ env.SWIFT_FORMAT_VERSION }}
41
+
36
42
- name : 📦 Install Swift Format
37
43
run : |
38
- git clone --branch $SWIFT_FORMAT_VERSION --depth 1 https://github.com/swiftlang/swift-format.git
39
- cd swift-format
40
- swift build -c release
41
- sudo mv .build/release/swift-format /usr/local/bin/
44
+ if [ -f ~/.cache/swift-format ]; then
45
+ echo "Using the cached Swift Format."
46
+ sudo cp -f ~/.cache/swift-format /usr/local/bin/swift-format
47
+ else
48
+ echo "Swift Format is not cached, building and installing..."
49
+ git clone --branch $SWIFT_FORMAT_VERSION --depth 1 https://github.com/swiftlang/swift-format.git
50
+ cd swift-format
51
+ swift build --disable-sandbox -c release
52
+ sudo cp -f .build/release/swift-format /usr/local/bin/
53
+
54
+ echo "Caching the built swift-format"
55
+ cp -f .build/release/swift-format ~/.cache/swift-format
56
+ fi
42
57
43
58
- name : 🔍 Verify Swift Format installation
44
59
run : swift-format --version
You can’t perform that action at this time.
0 commit comments