Skip to content

Set of predefined commands for multiplatform Swift packages

License

Notifications You must be signed in to change notification settings

CaptureContext/swift-package-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swift-package-action logo

swift-package-action

Set of predefined commands for multiplatform Swift packages.

If you develop a bunch swift packages it may be tricky to keep CI clean and updated for all of them, but a dedicated action can reduce code duplication and simplify CI support. This repository was inspired by CI setup of The Composable Architecture.

Getting started 🚀

You can include the action in your workflow to trigger on any event that GitHub actions supports.

The with portion of the workflow must be configured for the action.


with.command

Command for the action, basically it's the name of MAKE workflow. For additional details check out Makefile

Type: required

Supported values:

  • xcodebuild
  • xcodebuild-raw
  • build-for-library-evolution
  • test-docs
    • [unchecked, experimental] for @2.0, please submit an issue if you face any
  • benchmark
    • [unchecked, experimental] for @2.0, please submit an issue if you face any
  • github-build-docs
    • [unchecked, experimental] for @2.0, please submit an issue if you face any
  • swift-format
    • [unchecked] for @2.0, but should work fine
    • Requires GitHub Secrets to be set up for committing changes
    • Uses swift-format
    • Commits changes to main branch, this behavior is not configurable, at least yet
    • Commit message is [swift-format] and is not configurable, at least yet

Note

Commands with unchecked and experimental tags is in todo for verification. These flags mean that at some point these commands were used locally, but their use on CI was not validated. Currently we're in the process of migrating our repos to this action, but not every package uses these commands, however any potential issues for those commands should be fixed soon.


with.subcommand

Subcommand for the action, basically only used as argument for xcodebuild/xcodebuild-raw commands

Type: optional

Default value: ''

Supported values:

  • ''
  • test
  • any other xcodebuild argument

with.xcode

Xcode version

Type: optional

Default value: 16.2


with.cache-derived-data

Argument that specifies if action should cache DerivedData

Type: optional

Default value: false

Supported values:

  • false
  • true

with.workspace

Path to xcworkspace. It is recommended to create a workspace at the root of the package and ensure that all required schemes are present.

Type: optional

Default value: .swiftpm/xcode/package.xcworkspace


with.scheme

Scheme/PackageTarget for the action.

<package-name>-package usually suits for building and for testing

Type:

  • required
  • optional for swift-format command

with.platform

Target platform for the action

Type:

  • optional
  • required for the following commands
    • xcodebuild
    • xcodebuild-raw
    • test-docs

Supported values:

  • iOS
  • macOS
  • macCatalyst
  • watchOS
  • tvOS
  • visionOS

with.config

Build configuration for the action.

Type: optional

Default value: Debug


with.beautify

Specifies if xcodebuild output should be beautified. Uses xcbeautify

Type: optional

Default value: quiet

Supported values:

  • quiet
  • true
  • false

with.working-directory

Relative path to target directory

Type: optional

Default value: '.'


🧩 Step examples:

Full:

- name: Test CoolStuff
  uses: capturecontext/[email protected]
  with:
    xcode: 16.2
    workspace: 'Package.xcworkspace' # custom workspace at the root of a repo
    cache-derived-data: true
    command: xcodebuild
    subcommand: test
    scheme: cool-stuff-package # likely to be a name of the package
    platform: iOS
    config: Debug
    beautify: true
    working-directory: '.'

Short:

- name: Test CoolStuff
  uses: capturecontext/[email protected]
  with:
    workspace: 'Package.xcworkspace'
    cache-derived-data: true
    command: xcodebuild
    subcommand: test
    scheme: cool-stuff-package
    platform: iOS

📚 Workflow examples

License 🪪

This action is released under the MIT license. See LICENSE for details.

See ACKNOWLEDGEMENTS.md for inspiration references and their licences.