Skip to content

ci: Fix composite action syntax error #10

ci: Fix composite action syntax error

ci: Fix composite action syntax error #10

name: Build, test, and docs
on:
push:
branches-ignore:
- 'gh-pages'
pull_request:
branches-ignore:
- 'gh-pages'
workflow_dispatch:
jobs:
macos:
runs-on: macos-14
steps:
- name: Force Xcode 15.4
run: sudo xcode-select -switch /Applications/Xcode_15.4.app
- uses: actions/checkout@v3
- name: Install Dependencies
run: brew install pkg-config gtk4 gtk+3 || echo "This step 'fails' every time but it's just a brew linking error - not important."
- name: Build
run: |
swift build --target GtkCodeGen && \
cd Examples && \
swift build --target SwiftCrossUI && \
swift build --target GtkBackend && \
swift build --target Gtk3Backend && \
swift build --target AppKitBackend && \
swift build --target CounterExample && \
swift build --target ControlsExample && \
swift build --target RandomNumberGeneratorExample && \
swift build --target WindowingExample && \
swift build --target GreetingGeneratorExample && \
swift build --target NavigationExample && \
swift build --target SplitExample && \
swift build --target StressTestExample && \
swift build --target SpreadsheetExample && \
swift build --target NotesExample && \
swift build --target GtkExample && \
swift build --target PathsExample
- name: Test
run: swift test --test-product swift-cross-uiPackageTests
- name: Compile AppKitBackend docs
uses: ./.github/actions/compile-docs
with:
target: AppKitBackend
upload: true
uikit:
runs-on: macos-14
strategy:
matrix:
device-type:
- iPhone
- iPad
- TV
steps:
- name: Force Xcode 15.4
run: sudo xcode-select -switch /Applications/Xcode_15.4.app
- name: Install xcbeautify
run: brew install xcbeautify
- uses: actions/checkout@v3
- name: Build
run: |
set -uo pipefail
device_type=${{ matrix.device-type }}
set +e
deviceid=$(xcrun simctl list devices $device_type available | grep -v -- -- | tail -n 1 | grep -oE '[0-9A-F\-]{36}')
if [ $? -eq 0 ]; then
set -ex
(
buildtarget () {
xcodebuild -skipMacroValidation -scheme "$1" -destination "id=$deviceid" build | xcbeautify --renderer github-actions
}
buildtarget SwiftCrossUI
buildtarget UIKitBackend
cd Examples
buildtarget CounterExample
buildtarget GreetingGeneratorExample
buildtarget NavigationExample
buildtarget StressTestExample
buildtarget NotesExample
buildtarget PathsExample
if [ $device_type != TV ]; then
# Slider is not implemented for tvOS
buildtarget ControlsExample
buildtarget RandomNumberGeneratorExample
fi
if [ $device_type = iPad ]; then
# NavigationSplitView is only implemented for iPad
buildtarget SplitExample
fi
)
else
echo "No $device_type simulators found" >&2
fi
- name: Compile UIKitBackend docs
if: ${{ matrix.device-type == 'iPhone' }}
uses: ./.github/actions/compile-docs
with:
target: UIKitBackend
upload: true
xcodebuild: true
xcodebuild-device-type: ${{ matrix.device-type }}
windows:
runs-on: windows-latest
defaults:
run: # Use powershell because bash is not supported: https://github.com/compnerd/gha-setup-swift/issues/18#issuecomment-1705524890
shell: pwsh
steps:
- name: Setup VS Dev Environment
uses: seanmiddleditch/gha-setup-vsdevenv@v5
- name: Setup
uses: compnerd/[email protected]
with:
branch: swift-6.1-release
tag: 6.1-RELEASE
- name: Compute vcpkg Triplet
id: triplet
uses: ASzc/change-string-case-action@v5
with:
string: ${{ runner.arch }}-${{ runner.os }}
- uses: actions/checkout@v3
- name: Restore Dependency Cache
id: cache
uses: actions/cache/restore@v3
with:
path: vcpkg_installed
key: vcpkg-${{ steps.triplet.outputs.lowercase }}-${{ hashFiles('vcpkg.json') }}
- name: Build and Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
env:
VCPKG_DEFAULT_TRIPLET: ${{ steps.triplet.outputs.lowercase }}
run: vcpkg install
- name: Save Dependency Cache
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: vcpkg_installed
key: vcpkg-${{ steps.triplet.outputs.lowercase }}-${{ hashFiles('vcpkg.json') }}
- name: Build SwiftCrossUI
env:
PKG_CONFIG_PATH: ${{ github.workspace }}/vcpkg_installed/${{ steps.triplet.outputs.lowercase }}/lib/pkgconfig
run: swift build --target SwiftCrossUI -v
- name: Build WinUIBackend
run: swift build --target WinUIBackend
- name: Compile WinUIBackend docs
uses: ./.github/actions/compile-docs
with:
target: WinUIBackend
upload: true
linux:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
sudo apt update && \
sudo apt install -y libgtk-4-dev libgtk-3-dev clang
- name: Build
run: |
swift build --target GtkCodeGen && \
cd Examples && \
swift build --target SwiftCrossUI && \
swift build --target GtkBackend && \
swift build --target Gtk3Backend && \
swift build --target CounterExample && \
swift build --target ControlsExample && \
swift build --target RandomNumberGeneratorExample && \
swift build --target WindowingExample && \
swift build --target GreetingGeneratorExample && \
swift build --target NavigationExample && \
swift build --target SplitExample && \
swift build --target StressTestExample && \
swift build --target SpreadsheetExample && \
swift build --target NotesExample && \
swift build --target GtkExample
- name: Test
run: swift test --test-product swift-cross-uiPackageTests
- name: Compile GtkBackend docs
if: ${{ matrix.os == 'ubuntu-24.04' }}
uses: ./.github/actions/compile-docs
with:
target: GtkBackend
upload: true
- name: Compile Gtk3Backend docs
if: ${{ matrix.os == 'ubuntu-24.04' }}
uses: ./.github/actions/compile-docs
with:
target: Gtk3Backend
upload: true
update-docs:
runs-on: macos-14
needs: [macos, uikit, windows, linux]
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
steps:
- name: Force Xcode 15.4
run: sudo xcode-select -switch /Applications/Xcode_15.4.app
- uses: actions/checkout@v3
- name: Swift Version
run: swift --version
- name: Compile SwiftCrossUI docs
uses: ./.github/actions/compile-docs
with:
target: SwiftCrossUI
upload: false
- name: Download AppKitBackend.doccarchive
uses: actions/download-artifact@v4
with:
name: AppKitBackend.doccarchive
- name: Download GtkBackend.doccarchive
uses: actions/download-artifact@v4
with:
name: GtkBackend.doccarchive
- name: Download Gtk3Backend.doccarchive
uses: actions/download-artifact@v4
with:
name: Gtk3Backend.doccarchive
- name: Download WinUIBackend.doccarchive
uses: actions/download-artifact@v4
with:
name: WinUIBackend.doccarchive
- name: Merge DocC archives
run: |
xcrun docc merge \
SwiftCrossUI.doccarchive \
AppKitBackend.doccarchive \
UIKitBackend.doccarchive \
GtkBackend.doccarchive \
Gtk3Backend.doccarchive \
--output-path gh-pages/docs
- name: Update docs if changed
run: |
set -eux
git config user.email "[email protected]"
git config user.name "stackotter"
git fetch
git worktree add --checkout gh-pages origin/gh-pages
CURRENT_COMMIT_HASH=`git rev-parse --short HEAD`
cd gh-pages
git add docs
if [ -n "$(git status --porcelain)" ]; then
echo "Documentation changes found."
git commit -m "Update GitHub Pages documentation site to '$CURRENT_COMMIT_HASH'."
git push origin HEAD:gh-pages
else
echo "No documentation changes found."
fi