Skip to content

Commit 0c4cf0e

Browse files
committed
fix: add Swift setup step for Linux runners
1 parent 78451c2 commit 0c4cf0e

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

.github/workflows/swift-format.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,49 @@
11
name: Swift Format
2+
23
on:
34
push:
4-
branches: [main]
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: format-${{ github.ref }}
10+
cancel-in-progress: true
511

612
jobs:
7-
format:
13+
swift_format:
14+
name: swift-format
815
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
918
steps:
1019
- uses: actions/checkout@v5
11-
- name: Format code
20+
21+
- name: Setup Swift
22+
uses: swift-actions/setup-swift@v2
23+
with:
24+
swift-version: '6.0'
25+
26+
- name: Cache swift-format
27+
id: cache-swift-format
28+
uses: actions/cache@v4
29+
with:
30+
path: /usr/local/bin/swift-format
31+
key: ${{ runner.os }}-swift-format-${{ hashFiles('.github/workflows/swift-format.yml') }}
32+
33+
- name: Install swift-format
34+
if: steps.cache-swift-format.outputs.cache-hit != 'true'
35+
run: |
36+
git clone --depth 1 --branch main https://github.com/apple/swift-format.git
37+
cd swift-format
38+
swift build -c release
39+
sudo cp .build/release/swift-format /usr/local/bin/
40+
cd ..
41+
rm -rf swift-format
42+
43+
- name: Format
1244
run: swift-format format --recursive --in-place Sources Tests
13-
- name: Commit changes
14-
uses: stefanzweifel/git-auto-commit-action@v7
45+
46+
- uses: stefanzweifel/git-auto-commit-action@v7
1547
with:
16-
commit_message: "Run swift-format"
48+
commit_message: Run swift-format
49+
branch: 'main'

0 commit comments

Comments
 (0)