Skip to content

Instantly share code, notes, and snippets.

@YOCKOW
Last active November 14, 2025 08:17
Show Gist options
  • Select an option

  • Save YOCKOW/352b3594bfcb2c06d953647adaf65e78 to your computer and use it in GitHub Desktop.

Select an option

Save YOCKOW/352b3594bfcb2c06d953647adaf65e78 to your computer and use it in GitHub Desktop.
GitHub Actions' Workflow for Swift Package.
name: CI
on:
push:
branches:
- '**'
tags-ignore:
- '**'
paths:
- '**/*.swift'
- '**/*.c'
- '**/*.h'
- '.github/workflows/*.yml'
pull_request:
paths:
- '**/*.swift'
- '**/*.c'
- '**/*.h'
- '.github/workflows/*.yml'
jobs:
test:
defaults:
run:
working-directory: '.'
strategy:
matrix:
os:
- ubuntu-24.04
- macOS-26
swift-version:
- '6.2.1'
- '6.1.3'
- '6.0.3'
swift-compat-ver:
- '6'
- '5'
- '4.2'
- '4'
exclude:
- os: macOS-26
swift-version: '6.1.3'
- os: macOS-26
swift-version: '6.0.3'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Use a cache for ".build" directory.
uses: actions/cache@v4
with:
path: .build
key: build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.swift-version }}-${{ matrix.swift-compat-ver }}-${{ hashFiles('**/*.swift') }}
restore-keys: |
build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.swift-version }}-${{ matrix.swift-compat-ver }}-
build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.swift-version }}-
build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.os }}-
build-${{ github.workspace }}-${{ runner.os }}-
build-${{ github.workspace }}-
- uses: YOCKOW/Action-setup-swift@main
with:
swift-version: ${{ matrix.swift-version }}
## NEEDS WORKAROUND FOR https://github.com/swiftlang/swift-package-manager/issues/8064
# DEBUG mode
- name: Build with debug mode.
id: debug_build
run: swift build --configuration debug -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Retry build with debug mode if necessary
if: steps.debug_build.outcome == 'failure'
run: swift build --configuration debug -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Test with debug mode.
id: debug_test
run: swift test --configuration debug -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Retry test with debug mode if necessary
if: steps.debug_test.outcome == 'failure'
run: |
rm -rf $(cd .build/debug && pwd -P)
swift test --configuration debug -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
# RELEASE mode
- name: Build with release mode.
id: release_build
run: swift build --configuration release -Xswiftc -enable-testing -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Retry build with release mode if necessary
if: steps.release_build.outcome == 'failure'
run: swift build --configuration release -Xswiftc -enable-testing -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Test with release mode.
id: release_test
run: swift test --configuration release -Xswiftc -enable-testing -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Retry test with release mode if necessary
if: steps.release_test.outcome == 'failure'
run: |
rm -rf $(cd .build/release && pwd -P)
swift test --configuration release -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment