Change setup-swift action #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Path | |
on: | |
push: | |
branches: | |
- '**' | |
tags-ignore: | |
- '**' | |
paths: | |
- '**/*.swift' | |
- '.github/workflows/*.yml' | |
pull_request: | |
paths: | |
- '**/*.swift' | |
- '.github/workflows/*.yml' | |
concurrency: | |
group: path-${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: SPM Build | |
defaults: | |
run: | |
working-directory: '.' | |
strategy: | |
matrix: | |
os: | |
- ubuntu-22.04 | |
- macOS-13 | |
- windows-2022 | |
swift-version: | |
- '5.9' | |
swift-compat-ver: | |
- '5' | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use a cache for ".build" directory. | |
uses: actions/cache@v3 | |
with: | |
path: .build | |
key: build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.swift-version }}-${{ matrix.swift-compat-ver }}-${{ hashFiles('**/*.swift') }} | |
restore-keys: | | |
build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.swift-version }}-${{ matrix.swift-compat-ver }}- | |
build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.swift-version }}- | |
build-${{ github.workspace }}-${{ runner.os }}- | |
build-${{ github.workspace }}- | |
- uses: swift-actions/setup-swift@main | |
with: | |
swift-version: ${{ matrix.swift-version }} | |
# 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: | | |
rm -rf $(cd .build/debug && pwd -P) | |
swift build --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: | | |
rm -rf $(cd .build/release && pwd -P) | |
swift build --configuration release -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }} |