This guide will help you create new releases on GitHub for your Swift Packages that host binary executable assets. This is a multistep process that consists of:
- Staging a draft release on Github
- Uploading your binary artifacts to the draft release
- Updating the Package.swift to point to the uploaded assets in a staging branch
- Finalizing the Github release
- Install the GitHub CLI
brew install gh
- Install jq
brew install jq
-
Navigate to your repository on GitHub.com
-
Click on the
Releases
on your main GitHub page for your repo. -
Click
Draft a new release
-
Add a tag for your release (e.g.
1.0.0
) and remember this value -
Ensure the target is your primary branch (e.g.
main
ordevelop
, etc…) -
Drag each of your binary artifacts to the box that says
Attach binaries by dropping them here or selecting them
-
Click
Save Draft
… DO NOT PUBLISH THIS RELEASE YET
- Navigate to your cloned copy of the repository on your computer via the Terminal.
- Create and checkout a new branch for the Package.swift updates
- Run the following command, replacing
<release tag>
with tag value created in the previous step.
gh release view <release tag> --json assets | \
jq '.assets[] | { name: .name, url: (.apiUrl + ".zip") }'
Here is an example of the above command with actual output:
gh release view 1.1.2 --json assets | \
jq '.assets[] | { name: .name, url: (.apiUrl + ".zip") }'
{
"name": "MyBinaryLibrary.1.1.2.xcframework.zip",
"url": "https://api.github.com/repos/your_org/your-lib/releases/assets/93024549.zip"
}
{
"name": "MyBinaryLibrary.1.1.2.xcframework.zip",
"url": "https://api.github.com/repos/your_org/your-lib/releases/assets/93028050.zip"
}
- Update each binary target in your Package.swift with the url values in the output above.
- Ensure you update the checksum in Package.swift, if needed, using the value produced with this command:
swift package compute-checksum MyBinaryLibrary.1.1.2.xcframework.zip
- To test that your Package.swift is valid, open the package in Xcode and it should successfully resolve the package with the new binary files.
- Commit and push your changes
- Create a pull request and follow standard review policies for your package
- Merge the pull request
- Return to your draft release
- Ensure the tag is set to the value you expect and the target branch is pointing to your main branch
- Press the
Publish Release
button.
I love you <3