Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
briefcase

GitHub Action

Install Swift

v0.2.0 Pre-release

Install Swift

briefcase

Install Swift

Install the given Swift version

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Install Swift

uses: slashmo/[email protected]

Learn more about this action in slashmo/install-swift

Choose a version

install-swift

This action allows installing Swift toolchains, with support for both release and development versions.

Usage

Inputs

  • version - The Swift version you want to install. This may either be a release version like 5.5, or a development snapshot like swift-DEVELOPMENT-SNAPSHOT-2021-11-12-a.

Example

- name: Install Swift
  uses: slashmo/[email protected]
  with:
    version: 5.5

After adding this step, all following steps in this job will automatically use the newly installed Swift version:

- name: Run Tests
  run: swift test # <-- uses Swift 5.5

Multiple Swift Versions

In case you want to run your GitHub Actions workflow using different versions of Swift, define a GitHub Action's matrix to spawn multiple instances of the same job:

jobs:
  test:
    name: Run Tests
    strategy:
      matrix:
        swift: [5.5, swift-DEVELOPMENT-SNAPSHOT-2021-11-12-a]
        os: [ubuntu-18.04, ubuntu-20.04, macos-latest]
        fail-fast: false
    runs-on: ${{ matrix.os }}
    steps:
    - name: Install Swift
      uses: slashmo/[email protected]
      with:
        version: ${{ matrix.swift }}
    - name: Checkout
      uses: actions/checkout@v2
    - name: Run Tests
      run: swift test

The action will automatically detect the Ubuntu version and install the correct toolchain.

Caching

install-swift automatically caches toolchains based on the version input and the detected Ubuntu version.