Publishing to CocoaPods from Travis

How would you go to CocoaPods from Travis? I would like every tagged commit to do a pod trunk push , but is this good for a pod trunk register Travis? The backbone documents say that he is registering the car, not the user, so that inadvertently opens the Pod to push from other people who use Travis?

Does anyone have an example repo that is already doing this?

You can do this with RubyGems, using the API private keys pressed with the Travis command-line tool, as described in Deploying RubyGems .

+5
source share
2 answers

Cocoapods support Token authentication.

First you need to get the token from the password field ~/.netrc . After calling pod register you will see a section that looks like this:

 machine trunk.cocoapods.org login user@example.com password 0000000011111111 

Then you can upgrade podspec to CI using Token (which is unsafe):

 export COCOAPODS_TRUNK_TOKEN=0000000011111111 pod trunk push path/to.podspec 

You can also encrypt the token in Travis-CI with

 travis encrypt COCOAPODS_TRUNK_TOKEN=0000000011111111 --add env 

Update

Now you can set the environment variable directly in your plan settings. If you disable Display value in the build log (which is disabled by default), it treats it as a safe variable. This way, you don’t have to bother with Travis command-line tools or add unwanted files to your yaml file, or make changes without changing your repo.

Travis Environment Variables

+3
source

Thanks @Quanlong for the info on which file the password can be found.

You can extract the password from the specified file using this command

 grep -s password ~/.netrc | awk '{print $2}' 

So, if you use fastlane or any other CI set, you can set the token as follows

 ENV['COCOAPODS_TRUNK_TOKEN'] = sh "grep -s password ~/.netrc | awk '{print $2}'" 

What works in fastlane. Otherwise, you can invoke the grep some other way, perhaps system("grep ... ")

0
source

Source: https://habr.com/ru/post/1204731/


All Articles