GitHub Action that will setup a Swift environment with a specific version using Swiftly. Works on both Ubuntu and macOS runners.
Important
Version 3 is currently in beta. Please report any issues you encounter. To use legacy version 2, use @v2.
To run the action with the latest swift version available, simply add the action as a step in your workflow:
- uses: swift-actions/setup-swift@v3After the environment is configured you can run swift commands using the standard run step:
- uses: swift-actions/setup-swift@v3
- name: Get swift version
run: swift --version # Swift 6.2A specific Swift version can be set using the swift-version input:
- uses: swift-actions/setup-swift@v3
with:
swift-version: "5.1"
- name: Get swift version
run: swift --version # Swift 5.1.0Also works with snapshots:
- uses: swift-actions/setup-swift@v3
with:
swift-version: "main-snapshot"Works perfect together with matrixes:
name: Swift ${{ matrix.swift }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
swift: ["5.4.3", "5.2.4"]
steps:
- uses: swift-actions/setup-swift@v3
with:
swift-version: ${{ matrix.swift }}
- name: Get swift version
run: swift --versionIf you are running on a runner that is not able to verify the GPG signature of the Swiftly package, you can skip the verification by setting the skip-verify-signature input to true.
- uses: swift-actions/setup-swift@v3
with:
skip-verify-signature: trueYAML interprets eg. 5.0 as a float, this action will then interpret that as 5 which will result in eg. Swift 5.5 being resolved. Quote your inputs! Thus:
- uses: swift-actions/setup-swift@v3
with:
swift-version: '5.0'
Not:
- uses: swift-actions/setup-swift@v3
with:
swift-version: 5.0
You have two options for keeping this action up-to-date: either you define a specific version (like v3.0.0) or use the major version tag (like v3).
We recommend using the specific version tag together with Dependabot to keep the action up-to-date. That way you will automatically get notifed when the action updates and you can read the changelog directly in the PR opened by dependabot.
If you don't plan on keeping tabs on updates or don't want to use Dependabot but still would like to always use the latest version, you can use the main version tag.
Uses MIT license. The Swift logo is a trademark of Apple Inc.