1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main, develop ]
8+
9+ env :
10+ SWIFT_VERSION : 5.9
11+
12+ jobs :
13+ test :
14+ name : Test
15+ runs-on : macos-latest
16+ strategy :
17+ matrix :
18+ destination :
19+ - platform=macOS
20+ - platform=iOS Simulator,name=iPhone 15
21+ - platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)
22+ - platform=tvOS Simulator,name=Apple TV 4K (3rd generation)
23+
24+ steps :
25+ - name : Checkout
26+ uses : actions/checkout@v4
27+
28+ - name : Setup Xcode
29+ uses : maxim-lobanov/setup-xcode@v1
30+ with :
31+ xcode-version : latest-stable
32+
33+ - name : Swift Package Manager Cache
34+ uses : actions/cache@v3
35+ with :
36+ path : .build
37+ key : ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
38+ restore-keys : |
39+ ${{ runner.os }}-spm-
40+
41+ - name : Build
42+ run : swift build -v
43+
44+ - name : Run Tests
45+ run : swift test --enable-code-coverage
46+
47+ - name : Generate Code Coverage Report
48+ run : |
49+ xcrun llvm-cov export -format="lcov" \
50+ .build/debug/SwiftNetworkKitPackageTests.xctest/Contents/MacOS/SwiftNetworkKitPackageTests \
51+ -instr-profile .build/debug/codecov/default.profdata > coverage.lcov
52+
53+ - name : Upload Coverage to Codecov
54+ uses : codecov/codecov-action@v3
55+ with :
56+ file : ./coverage.lcov
57+ fail_ci_if_error : false
58+
59+ lint :
60+ name : SwiftLint
61+ runs-on : macos-latest
62+
63+ steps :
64+ - name : Checkout
65+ uses : actions/checkout@v4
66+
67+ - name : SwiftLint
68+ uses : norio-nomura/action-swiftlint@3.2.1
69+ with :
70+ args : --strict
71+
72+ validate-package :
73+ name : Validate Swift Package
74+ runs-on : macos-latest
75+
76+ steps :
77+ - name : Checkout
78+ uses : actions/checkout@v4
79+
80+ - name : Validate Package
81+ run : swift package dump-package
82+
83+ - name : Check Package Dependencies
84+ run : swift package show-dependencies
85+
86+ documentation :
87+ name : Documentation
88+ runs-on : macos-latest
89+
90+ steps :
91+ - name : Checkout
92+ uses : actions/checkout@v4
93+
94+ - name : Setup Xcode
95+ uses : maxim-lobanov/setup-xcode@v1
96+ with :
97+ xcode-version : latest-stable
98+
99+ - name : Build Documentation
100+ run : |
101+ swift package --allow-writing-to-directory docs \
102+ generate-documentation --target SwiftNetworkKit \
103+ --disable-indexing \
104+ --transform-for-static-hosting \
105+ --hosting-base-path SwiftNetworkKit \
106+ --output-path docs
107+
108+ - name : Deploy to GitHub Pages
109+ if : github.ref == 'refs/heads/main'
110+ uses : peaceiris/actions-gh-pages@v3
111+ with :
112+ github_token : ${{ secrets.GITHUB_TOKEN }}
113+ publish_dir : ./docs
114+
115+ release :
116+ name : Release
117+ runs-on : macos-latest
118+ needs : [test, lint, validate-package]
119+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
120+
121+ steps :
122+ - name : Checkout
123+ uses : actions/checkout@v4
124+ with :
125+ fetch-depth : 0
126+
127+ - name : Setup Node.js
128+ uses : actions/setup-node@v3
129+ with :
130+ node-version : ' 18'
131+
132+ - name : Install semantic-release
133+ run : |
134+ npm install -g semantic-release @semantic-release/changelog @semantic-release/git
135+
136+ - name : Semantic Release
137+ env :
138+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
139+ run : npx semantic-release
0 commit comments