|
13 | 13 | CARGO_TERM_COLOR: always |
14 | 14 |
|
15 | 15 | jobs: |
| 16 | + changes: |
| 17 | + name: Detect changes |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + core: ${{ steps.filter.outputs.core }} |
| 21 | + desktop: ${{ steps.filter.outputs.desktop }} |
| 22 | + android: ${{ steps.filter.outputs.android }} |
| 23 | + ios: ${{ steps.filter.outputs.ios }} |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - uses: dorny/paths-filter@v3 |
| 27 | + id: filter |
| 28 | + with: |
| 29 | + filters: | |
| 30 | + core: |
| 31 | + - 'crates/hostsync-core/**' |
| 32 | + - 'Cargo.toml' |
| 33 | + - 'Cargo.lock' |
| 34 | + - '.github/workflows/ci.yml' |
| 35 | + desktop: |
| 36 | + - 'crates/hostsync-desktop/**' |
| 37 | + android: |
| 38 | + - 'mobile/android/**' |
| 39 | + ios: |
| 40 | + - 'mobile/ios/**' |
| 41 | +
|
16 | 42 | test: |
17 | 43 | name: Test |
| 44 | + needs: changes |
| 45 | + if: needs.changes.outputs.core == 'true' || needs.changes.outputs.desktop == 'true' || needs.changes.outputs.android == 'true' || needs.changes.outputs.ios == 'true' |
18 | 46 | runs-on: ubuntu-latest |
19 | 47 | steps: |
20 | 48 | - uses: actions/checkout@v4 |
|
25 | 53 |
|
26 | 54 | build-desktop: |
27 | 55 | name: Desktop ${{ matrix.name }} |
28 | | - needs: test |
| 56 | + needs: [changes, test] |
| 57 | + if: needs.changes.outputs.core == 'true' || needs.changes.outputs.desktop == 'true' |
29 | 58 | runs-on: ${{ matrix.os }} |
30 | 59 | strategy: |
31 | 60 | matrix: |
@@ -119,7 +148,8 @@ jobs: |
119 | 148 |
|
120 | 149 | build-android: |
121 | 150 | name: Android APK |
122 | | - needs: test |
| 151 | + needs: [changes, test] |
| 152 | + if: needs.changes.outputs.core == 'true' || needs.changes.outputs.android == 'true' |
123 | 153 | runs-on: ubuntu-latest |
124 | 154 | steps: |
125 | 155 | - uses: actions/checkout@v4 |
@@ -165,7 +195,8 @@ jobs: |
165 | 195 |
|
166 | 196 | build-ios: |
167 | 197 | name: iOS IPA |
168 | | - needs: test |
| 198 | + needs: [changes, test] |
| 199 | + if: needs.changes.outputs.core == 'true' || needs.changes.outputs.ios == 'true' |
169 | 200 | runs-on: macos-latest |
170 | 201 | steps: |
171 | 202 | - uses: actions/checkout@v4 |
@@ -228,9 +259,12 @@ jobs: |
228 | 259 |
|
229 | 260 | pre-release: |
230 | 261 | name: Pre-release |
231 | | - needs: [build-desktop, build-android, build-ios] |
| 262 | + needs: [changes, build-desktop, build-android, build-ios] |
| 263 | + if: | |
| 264 | + always() && |
| 265 | + github.event_name == 'push' && github.ref == 'refs/heads/main' && |
| 266 | + (needs.build-desktop.result == 'success' || needs.build-android.result == 'success' || needs.build-ios.result == 'success') |
232 | 267 | runs-on: ubuntu-latest |
233 | | - if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
234 | 268 | steps: |
235 | 269 | - uses: actions/checkout@v4 |
236 | 270 | - uses: actions/download-artifact@v4 |
|
0 commit comments