|
| 1 | +name: Build, test, and docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + - 'gh-pages' |
| 7 | + pull_request: |
| 8 | + branches-ignore: |
| 9 | + - 'gh-pages' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + macos: |
| 14 | + runs-on: macos-14 |
| 15 | + steps: |
| 16 | + - name: Force Xcode 15.4 |
| 17 | + run: sudo xcode-select -switch /Applications/Xcode_15.4.app |
| 18 | + |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Install Dependencies |
| 22 | + run: brew install pkg-config gtk4 gtk+3 || echo "This step 'fails' every time but it's just a brew linking error - not important." |
| 23 | + |
| 24 | + - name: Build |
| 25 | + run: | |
| 26 | + swift build --target GtkCodeGen && \ |
| 27 | + cd Examples && \ |
| 28 | + swift build --target SwiftCrossUI && \ |
| 29 | + swift build --target GtkBackend && \ |
| 30 | + swift build --target Gtk3Backend && \ |
| 31 | + swift build --target AppKitBackend && \ |
| 32 | + swift build --target CounterExample && \ |
| 33 | + swift build --target ControlsExample && \ |
| 34 | + swift build --target RandomNumberGeneratorExample && \ |
| 35 | + swift build --target WindowingExample && \ |
| 36 | + swift build --target GreetingGeneratorExample && \ |
| 37 | + swift build --target NavigationExample && \ |
| 38 | + swift build --target SplitExample && \ |
| 39 | + swift build --target StressTestExample && \ |
| 40 | + swift build --target SpreadsheetExample && \ |
| 41 | + swift build --target NotesExample && \ |
| 42 | + swift build --target GtkExample && \ |
| 43 | + swift build --target PathsExample |
| 44 | +
|
| 45 | + - name: Test |
| 46 | + run: swift test --test-product swift-cross-uiPackageTests |
| 47 | + |
| 48 | + - name: Compile AppKitBackend docs |
| 49 | + uses: OWNER/compile-docs@SHA |
| 50 | + with: |
| 51 | + target: AppKitBackend |
| 52 | + upload: true |
| 53 | + |
| 54 | + uikit: |
| 55 | + runs-on: macos-14 |
| 56 | + strategy: |
| 57 | + matrix: |
| 58 | + devicetype: |
| 59 | + - iPhone |
| 60 | + - iPad |
| 61 | + - TV |
| 62 | + steps: |
| 63 | + - name: Force Xcode 15.4 |
| 64 | + run: sudo xcode-select -switch /Applications/Xcode_15.4.app |
| 65 | + |
| 66 | + - name: Install xcbeautify |
| 67 | + run: brew install xcbeautify |
| 68 | + |
| 69 | + - uses: actions/checkout@v3 |
| 70 | + |
| 71 | + - name: Build |
| 72 | + run: | |
| 73 | + set -uo pipefail |
| 74 | + devicetype=${{ matrix.devicetype }} |
| 75 | + set +e |
| 76 | + deviceid=$(xcrun simctl list devices $devicetype available | grep -v -- -- | tail -n 1 | grep -oE '[0-9A-F\-]{36}') |
| 77 | + if [ $? -eq 0 ]; then |
| 78 | + set -e |
| 79 | + ( |
| 80 | + buildtarget () { |
| 81 | + xcodebuild -scheme "$1" -destination "id=$deviceid" build | xcbeautify --renderer github-actions |
| 82 | + } |
| 83 | +
|
| 84 | + buildtarget SwiftCrossUI |
| 85 | + buildtarget UIKitBackend |
| 86 | +
|
| 87 | + cd Examples |
| 88 | +
|
| 89 | + buildtarget CounterExample |
| 90 | + buildtarget GreetingGeneratorExample |
| 91 | + buildtarget NavigationExample |
| 92 | + buildtarget StressTestExample |
| 93 | + buildtarget NotesExample |
| 94 | + buildtarget PathsExample |
| 95 | +
|
| 96 | + if [ $devicetype != TV ]; then |
| 97 | + # Slider is not implemented for tvOS |
| 98 | + buildtarget ControlsExample |
| 99 | + buildtarget RandomNumberGeneratorExample |
| 100 | + fi |
| 101 | +
|
| 102 | + if [ $devicetype = iPad ]; then |
| 103 | + # NavigationSplitView is only implemented for iPad |
| 104 | + buildtarget SplitExample |
| 105 | + fi |
| 106 | + ) |
| 107 | + else |
| 108 | + echo "No $devicetype simulators found" >&2 |
| 109 | + fi |
| 110 | +
|
| 111 | + - name: Compile UIKitBackend docs |
| 112 | + if: ${{ matrix.devicetype == "iPhone" }} |
| 113 | + uses: OWNER/compile-docs@SHA |
| 114 | + with: |
| 115 | + target: UIKitBackend |
| 116 | + upload: true |
| 117 | + xcodebuild: true |
| 118 | + xcodebuild_destination: ${{ matrix.devicetype }} |
| 119 | + |
| 120 | + windows: |
| 121 | + runs-on: windows-latest |
| 122 | + defaults: |
| 123 | + run: # Use powershell because bash is not supported: https://github.com/compnerd/gha-setup-swift/issues/18#issuecomment-1705524890 |
| 124 | + shell: pwsh |
| 125 | + |
| 126 | + steps: |
| 127 | + - name: Setup VS Dev Environment |
| 128 | + uses: seanmiddleditch/gha-setup-vsdevenv@v5 |
| 129 | + |
| 130 | + - name: Setup |
| 131 | + uses: compnerd/gha-setup-swift@v0.3.0 |
| 132 | + with: |
| 133 | + branch: swift-6.1-release |
| 134 | + tag: 6.1-RELEASE |
| 135 | + |
| 136 | + - name: Compute vcpkg Triplet |
| 137 | + id: triplet |
| 138 | + uses: ASzc/change-string-case-action@v5 |
| 139 | + with: |
| 140 | + string: ${{ runner.arch }}-${{ runner.os }} |
| 141 | + |
| 142 | + - uses: actions/checkout@v3 |
| 143 | + |
| 144 | + - name: Restore Dependency Cache |
| 145 | + id: cache |
| 146 | + uses: actions/cache/restore@v3 |
| 147 | + with: |
| 148 | + path: vcpkg_installed |
| 149 | + key: vcpkg-${{ steps.triplet.outputs.lowercase }}-${{ hashFiles('vcpkg.json') }} |
| 150 | + |
| 151 | + - name: Build and Install Dependencies |
| 152 | + if: steps.cache.outputs.cache-hit != 'true' |
| 153 | + env: |
| 154 | + VCPKG_DEFAULT_TRIPLET: ${{ steps.triplet.outputs.lowercase }} |
| 155 | + run: vcpkg install |
| 156 | + |
| 157 | + - name: Save Dependency Cache |
| 158 | + if: steps.cache.outputs.cache-hit != 'true' |
| 159 | + uses: actions/cache/save@v3 |
| 160 | + with: |
| 161 | + path: vcpkg_installed |
| 162 | + key: vcpkg-${{ steps.triplet.outputs.lowercase }}-${{ hashFiles('vcpkg.json') }} |
| 163 | + |
| 164 | + - name: Build SwiftCrossUI |
| 165 | + env: |
| 166 | + PKG_CONFIG_PATH: ${{ github.workspace }}/vcpkg_installed/${{ steps.triplet.outputs.lowercase }}/lib/pkgconfig |
| 167 | + run: swift build --target SwiftCrossUI -v |
| 168 | + |
| 169 | + - name: Build WinUIBackend |
| 170 | + run: swift build --target WinUIBackend |
| 171 | + |
| 172 | + - name: Compile WinUIBackend docs |
| 173 | + uses: OWNER/compile-docs@SHA |
| 174 | + with: |
| 175 | + target: WinUIBackend |
| 176 | + upload: true |
| 177 | + |
| 178 | + linux: |
| 179 | + strategy: |
| 180 | + matrix: |
| 181 | + os: [ubuntu-22.04, ubuntu-24.04] |
| 182 | + runs-on: ${{ matrix.os }} |
| 183 | + |
| 184 | + steps: |
| 185 | + - uses: actions/checkout@v3 |
| 186 | + |
| 187 | + - name: Install Dependencies |
| 188 | + run: | |
| 189 | + sudo apt update && \ |
| 190 | + sudo apt install -y libgtk-4-dev libgtk-3-dev clang |
| 191 | +
|
| 192 | + - name: Build |
| 193 | + run: | |
| 194 | + swift build --target GtkCodeGen && \ |
| 195 | + cd Examples && \ |
| 196 | + swift build --target SwiftCrossUI && \ |
| 197 | + swift build --target GtkBackend && \ |
| 198 | + swift build --target Gtk3Backend && \ |
| 199 | + swift build --target CounterExample && \ |
| 200 | + swift build --target ControlsExample && \ |
| 201 | + swift build --target RandomNumberGeneratorExample && \ |
| 202 | + swift build --target WindowingExample && \ |
| 203 | + swift build --target GreetingGeneratorExample && \ |
| 204 | + swift build --target NavigationExample && \ |
| 205 | + swift build --target SplitExample && \ |
| 206 | + swift build --target StressTestExample && \ |
| 207 | + swift build --target SpreadsheetExample && \ |
| 208 | + swift build --target NotesExample && \ |
| 209 | + swift build --target GtkExample |
| 210 | +
|
| 211 | + - name: Test |
| 212 | + run: swift test --test-product swift-cross-uiPackageTests |
| 213 | + |
| 214 | + - name: Compile GtkBackend docs |
| 215 | + uses: OWNER/compile-docs@SHA |
| 216 | + with: |
| 217 | + target: GtkBackend |
| 218 | + upload: true |
| 219 | + |
| 220 | + - name: Compile Gtk3Backend docs |
| 221 | + uses: OWNER/compile-docs@SHA |
| 222 | + with: |
| 223 | + target: Gtk3Backend |
| 224 | + upload: true |
| 225 | + |
| 226 | + update-docs: |
| 227 | + runs-on: macos-14 |
| 228 | + needs: macos, uikit, windows, linux |
| 229 | + if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} |
| 230 | + |
| 231 | + steps: |
| 232 | + - name: Force Xcode 15.4 |
| 233 | + run: sudo xcode-select -switch /Applications/Xcode_15.4.app |
| 234 | + |
| 235 | + - uses: actions/checkout@v3 |
| 236 | + |
| 237 | + - name: Swift Version |
| 238 | + run: swift --version |
| 239 | + |
| 240 | + - name: Compile SwiftCrossUI docs |
| 241 | + uses: OWNER/compile-docs@SHA |
| 242 | + with: |
| 243 | + target: SwiftCrossUI |
| 244 | + upload: false |
| 245 | + |
| 246 | + - name: Download AppKitBackend.doccarchive |
| 247 | + uses: actions/download-artifact@v4 |
| 248 | + with: |
| 249 | + name: AppKitBackend.doccarchive |
| 250 | + |
| 251 | + - name: Download GtkBackend.doccarchive |
| 252 | + uses: actions/download-artifact@v4 |
| 253 | + with: |
| 254 | + name: GtkBackend.doccarchive |
| 255 | + |
| 256 | + - name: Download Gtk3Backend.doccarchive |
| 257 | + uses: actions/download-artifact@v4 |
| 258 | + with: |
| 259 | + name: Gtk3Backend.doccarchive |
| 260 | + |
| 261 | + - name: Download WinUIBackend.doccarchive |
| 262 | + uses: actions/download-artifact@v4 |
| 263 | + with: |
| 264 | + name: WinUIBackend.doccarchive |
| 265 | + |
| 266 | + - name: Merge DocC archives |
| 267 | + run: | |
| 268 | + xcrun docc merge \ |
| 269 | + SwiftCrossUI.doccarchive \ |
| 270 | + AppKitBackend.doccarchive \ |
| 271 | + UIKitBackend.doccarchive \ |
| 272 | + GtkBackend.doccarchive \ |
| 273 | + Gtk3Backend.doccarchive \ |
| 274 | + --output-path gh-pages/docs |
| 275 | +
|
| 276 | + - name: Update docs if changed |
| 277 | + run: | |
| 278 | + set -eux |
| 279 | +
|
| 280 | + git config user.email "stackotter@stackotter.dev" |
| 281 | + git config user.name "stackotter" |
| 282 | +
|
| 283 | + git fetch |
| 284 | + git worktree add --checkout gh-pages origin/gh-pages |
| 285 | +
|
| 286 | + CURRENT_COMMIT_HASH=`git rev-parse --short HEAD` |
| 287 | +
|
| 288 | + cd gh-pages |
| 289 | + git add docs |
| 290 | +
|
| 291 | + if [ -n "$(git status --porcelain)" ]; then |
| 292 | + echo "Documentation changes found." |
| 293 | + git commit -m "Update GitHub Pages documentation site to '$CURRENT_COMMIT_HASH'." |
| 294 | + git push origin HEAD:gh-pages |
| 295 | + else |
| 296 | + echo "No documentation changes found." |
| 297 | + fi |
0 commit comments