This repository contains scripts that let you easily build and test your Swift Package, generate DocC documentation and XCFrameworks, and create new versions.
The scripts
filder contains the following scripts:
build.sh
- Run builds for all provided platforms.chmod.sh
- Runschmod +x
on all scripts in the script folder.docc.sh
- Build DocC documentation for all provided platforms.framework.sh
- Build an XCFramework for all provided platforms.git_default_branch.sh
- Get the default git branch name.package_name.sh
- Get the name of the main Swift package.test.sh
- Run the project unit tests for all provided platforms.version.sh
- Create a new version with validation and test steps.version_bump.sh
- Bump the version number and push a new version tag.version_number.sh
- Get the current git version number.version_validate_git.sh
- Validate that the repo is ready for release.version_validate_project.sh
- Validate that the project is ready for release.
Note that you may have to run chmod +x <SCRIPT>
to be able to run a script.
You can create project-specific scripts that call these scripts in pre-configured ways, for instance:
# package_version.sh
TARGET="SwiftPackageScripts"
PLATFORMS="iOS macOS tvOS watchOS xrOS"
BRANCH=${1:-"main"}
SCRIPT="scripts/version.sh"
chmod +x $SCRIPT
bash $SCRIPT $TARGET $BRANCH $PLATFORMS
You can have a look the root version.sh
for reference, and create similar files for your own project.
The .github/workflows
folder contains build
and docc
runner files, that are used by GitHub Actions to tests and update the GitHub hosted documentation on every push to the main branch.
Note that chmod +x
is required to use ./
, otherwise you have to use bash ...
.
You can build and test a package or project with the build
and test
scripts:
./scripts/build.sh TARGET [PLATFORMS]
./scripts/test.sh TARGET [PLATFORMS]
You can generate DocC documentation for a package or project with the docc
script:
./scripts/build.sh TARGET [PLATFORMS default: iOS macOS tvOS watchOS xrOS]
./scripts/test.sh TARGET [PLATFORMS]
You can generate an XCFramework for a project (not package) with the framework
script:
./scripts/framework.sh TARGET [PLATFORMS default: iOS macOS tvOS watchOS xrOS]
You can create a new version of your package or project with the version
script:
./scripts/version.sh TARGET MAIN_BRANCH [PLATFORMS default: iOS macOS tvOS watchOS xrOS]
There are more version scripts that you can run standalone as well.
This repository has a sample package that is used to test that everything works as expected.
You can find the generated, GitHub hosted documentation here.