Auto deploys describe setting up your CI so it automatically pushes a new Podspec to CocoaPods trunk on new releases. You can read more on the discussion and suggestion that lead to this here: [Proposal] Resolve Deployment of new CocoaPods on a Community-level
This tutorial will use Circle CI as an example, but should apply to Travis or any other CI that has a release step that lets you filter out tags.
Point person: If you have any questions or you got stuck, feel free to ping @freak4pc in GitHub or Twitter; or otherwise, open an issue.
A CocoaPods Trunk token is a token generated for a user registering a session with the trunk
service.
That token can be used by a server (such as a CI provider) as an authentication mechanism for commands such as pod trunk push
, etc.
- Make sure you've added
[email protected]
as an owner of your CocoaPod, as defined in the Contribution Guide, e.g. usingpod trunk add-owner YourPodName [email protected]
.
-
If you aren't part of the
[email protected]
email list, please DM @freak4pc on Twitter or open an issue asking to add your email to the list of emails[email protected]
forwards to. -
Once you have proper email forwarding set up, register a session with trunk using the community e-mail, by using:
pod trunk register [email protected] "RxSwift Community"
. You should receive an email to the[email protected]
address, asking you to confirm your session. Tap the link.
- Once you have an approved & registered session, your next step would be getting the new CocoaPods trunk token generated for you. The token is location in your
~/.netrc
file. You can use the following command to automatically copy that token to your pasteboard:
awk '/trunk.cocoapods.org/{getline; getline; print $2}' ~/.netrc | pbcopy
-
Keep a copy of your session token somewhere safe (e.g. copy it to temporary file aside to not lose it for the next step)
-
Register a new session with your private email to overwrite the local community token. This is to ensure the token is only used by CI and not by your own computer. Use:
pod trunk register [email protected] "My Name"
and approve your session via the email link like before.
Awesome job! You now have a valid token you can provide your CI so it can push CocoaPod Specs on your (or the community's) behalf.
There are only two final steps left to this tutorial.
- In your CI Provider, set up a "Secure Environment Variable" named
COCOAPODS_TRUNK_TOKEN
with the token you acquired in the previous step. On Circle CI, this will look as follows:
- Add a release-level script that would trigger a
pod trunk push
for every new release tag you push up. On Circle CI v1, you'd add to yourcircle.yml
:
deployment:
release:
tag: /[0-9]+(\.[0-9]+)*/
commands:
- rm ~/.cocoapods/config.yaml # This hack is needed since CircleCI forces --verbose
- pod trunk push --skip-tests --allow-warnings
This code will automatically push a new version of your Podspec whenever you create a new GitHub "Release" with a new tag attached to it.
Note: If your CI itself doesn't use CocoaPods for any of its build stages, and you get an error similar to Unable to find a specification for SomeDependency depended upon by YourRepo
, you probably need to add a pod setup
before your push, like here: https://github.com/RxSwiftCommunity/RxSwiftExt/blob/master/circle.yml#L26-L28
- That's it! With your script set-up correctly, push a commit with an updated Podspec for your new version, followed by creating a new GitHub Release with a new tag name using semantic versioning.
Your CI should automatically detect it and start building your repo:
If you've done everything correctly, your CI's last step should look something like this: