Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swift-actions/setup-swift
GitHub Action that setup a Swift environment
https://github.com/swift-actions/setup-swift
ci github-actions setup-swift swift
Last synced: 3 months ago
JSON representation
GitHub Action that setup a Swift environment
- Host: GitHub
- URL: https://github.com/swift-actions/setup-swift
- Owner: swift-actions
- License: mit
- Created: 2019-09-05T20:40:25.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-08-05T09:47:40.000Z (3 months ago)
- Last Synced: 2024-08-05T18:22:46.003Z (3 months ago)
- Topics: ci, github-actions, setup-swift, swift
- Language: TypeScript
- Homepage:
- Size: 27.7 MB
- Stars: 242
- Watchers: 5
- Forks: 48
- Open Issues: 25
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Setup Swift
[GitHub Action](https://github.com/features/actions) that will setup a [Swift](https://swift.org) environment with a specific version. Works on both Ubuntu and macOS runners.
## Usage
To run the action with the latest swift version available, simply add the action as a step in your workflow:
```yaml
- uses: swift-actions/setup-swift@v2
```After the environment is configured you can run swift commands using the standard [`run`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsrun) step:
```yaml
- uses: swift-actions/setup-swift@v2
- name: Get swift version
run: swift --version # Swift 5.10.1
```A specific Swift version can be set using the `swift-version` input:
```yaml
- uses: swift-actions/setup-swift@v2
with:
swift-version: "5.1.0"
- name: Get swift version
run: swift --version # Swift 5.1.0
```Works perfect together with matrixes:
```yaml
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@v2
with:
swift-version: ${{ matrix.swift }}
- name: Get swift version
run: swift --version
```## Note about versions
This project uses strict semantic versioning to determine what version of Swift to configure. This differs slightly from the official convention used by Swift.
For example, Swift is available as version `5.1` but using this as value for `swift-version` will be interpreted as a version _range_ of `5.1.X` where `X` is the latest patch version available for that major and minor version.
In other words specifying...
- `"5.1.0"` will resolve to version `5.1`
- `"5.1"` will resolve to latest patch version (aka `5.1.1`)
- `"5"` will resolve to latest minor and patch version (aka `5.10`)### Caveats
YAML 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@v2
with:
swift-version: '5.0'
```Not:
```
- uses: swift-actions/setup-swift@v2
with:
swift-version: 5.0
```## Keeping the action up-to-date
You have two options for keeping this action up-to-date: either you define a specific version (like `v2.0.1`) or use the major version tag (like `v2`).
### Specific version
We recommend using the specific version tag together with [Dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates) 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.
### Major version tag
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.
## Legal
Uses MIT license.
The Swift logo is a trademark of Apple Inc.