Skip to content

GitHub Action to build and cache any Swift based tool in workflows.

License

Notifications You must be signed in to change notification settings

Cyberbeni/install-swift-tool

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
Jan 30, 2025
Jan 30, 2025
Jan 30, 2025
Jan 30, 2025
Oct 13, 2024
Oct 13, 2024
Dec 12, 2020
Jan 30, 2025
Jan 30, 2025
Oct 16, 2024
Oct 15, 2024
Nov 19, 2024
Oct 15, 2024
Nov 19, 2024

Repository files navigation

Description

Github action to install swift based tools, like xcbeautify or swiftformat, to be used inside workflows.

Versions

master - It should always work and contain the latest changes.

v1 - Initial version. Deprecated, use v2 with use-cache: false instead.

v2 - Adds caching (enabled by default), allows specifying commit or version. Deprecated, use v3, set branch manually if you want to use the default branch and set LINUX_SOURCEKIT_LIB_PATH manually if needed (not needed with the official runner images for more than 2 years).

v3 - Uses the Package.resolved file if no commit/branch/version is specified.

Usage

Step example:

- name: Install xcbeautify
  uses: Cyberbeni/install-swift-tool@v3
  with:
    url: https://github.com/nicklockwood/SwiftFormat
    # Version from Package.resolved is used if no commit/branch/version is provided.
    commit: '175df295d77b5bf255b0c160d380cabbe826ded4' # optional, commit hash
    branch: develop # optional, branch or tag, overridden by commit/version
    version: '*' # optional, overridden by commit, format: https://devhints.io/semver
    package-resolved-path: 'Package.resolved' # optional, default: 'Package.resolved', Package.resolved file path to use for resolving the version if no commit/branch/version is specified
    use-cache: true # optinal, default: true

Workflow example:

name: Lint

on: 
  pull_request:
  push:
    branches: master # https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache

jobs:
  swiftformat-lint:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v4
    - name: Install SwiftFormat
      uses: Cyberbeni/install-swift-tool@v3
      with:
        url: https://github.com/nicklockwood/SwiftFormat
    - name: Lint
      run: swiftformat --lint .

How to contribute

Install Node.js: https://nodejs.org/en/download/package-manager

Install yarn and download the dependencies

npm install --global yarn
yarn

Run before commit (fix any issues manually that formatting can't automatically fix)

npm run format
npm run build

Run unit tests in ./tests (the e2e tests are run on GitHub after push/pull request)

npm run test