Swift Package Scripts has Terminal scripts that can build and test your Swift Package, build DocC documentation and deploy it to GitHub Pages, generate XCFramework zip files, and create new semantic versions.
The scripts folder contains the following scripts:
build.sh- Build a target for all or some platforms.chmod.sh- Runschmod +xon all scripts in the script folder.docc.sh- Build DocC documentation for all or some platforms.framework.sh- Build an XCFramework for all or some platforms.git_default_branch.sh- Get the default git branch name.package_name.sh- Get the name of the main Swift package.release.sh- Make a release build with several validation steps.sync_from.sh- Syncscriptsfrom a Swift Package Scripts folder.test.sh- Test a target on all or some platforms.validate_git_branch.sh- Validate the current branch.validate_release.sh- Validate the package for release.version_bump.sh- Bump the current version number and create a new tag.version_number.sh- Get the current version number from the latest tag.
Note that you have to run chmod +x <SCRIPT> to be able to run a script for the first time. You can use chmod.sh to do this for all scripts.
The .github folder contains the following GitHub Actions workflows:
build.yml- Build the package for all or some platforms.docc.yml- Build DocC documentation and deploy it to GitHub Pages.test.yml- Test the package on all or some platforms.
These workflows use main as git branch. Change this in each file to trigger the workflows for other branches. As the files are not part of the sync, you have to copy them manually.
Swift Package Scripts can be installed to your computer by cloning the repository:
git clone https://github.com/danielsaidi/SwiftPackageScripts.git
You can then navigate to the folder and sync the scripts to any older folder, using the scripts/sync_to.sh script.
./sync_to.sh ../AnotherProjectFolderThis will remove any already existing folder, and replace it with the latest version. After the first sync, you can use scripts/sync_from.sh in the project folder to sync from another folder.
You can become a sponsor to help me dedicate more time on my various open-source tools. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.
This repository has a sample package that is used to test that everything works as expected.
For more information about these scripts, and how to set up project-specific scripts, see the online here.
Feel free to reach out if you have questions or if you want to contribute in any way:
- Website: danielsaidi.com
- Mastodon: @danielsaidi@mastodon.social
- Twitter: @danielsaidi
- E-mail: daniel.saidi@gmail.com
Swift Package Scripts is available under the MIT license. See the LICENSE file for more info.