Code Monkey home page Code Monkey logo

deploy-to-cocoapods-github-action's Introduction

Deploy to cocoapods

Using this GitHub Action, you can deploy automatically your pod library to Cocoapods.org

Requirements

  • Must have register to cocoapod trunk. Please refer to Getting setup with Trunk on how to register.

  • Get your trunk token by using pod trunk me --verbose from your command line.

    Example response:

    opening connection to trunk.cocoapods.org:443...
    opened
    starting SSL for trunk.cocoapods.org:443...
    SSL established, protocol: TLSv1.2, cipher: ECDHE-RSA-AES128-GCM-SHA256
    <- "GET /api/v1/sessions HTTP/1.1\r\nContent-Type: application/json; charset=utf-8\r\nAccept: application/json; charset=utf-8\r\nUser-Agent: CocoaPods/1.7.4\r\nAuthorization: Token XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nHost: trunk.cocoapods.org\r\n\r\n"
    -> "HTTP/1.1 200 OK\r\n"
    -> "Date: Sun, 22 Sep 2019 05:11:46 GMT\r\n"
    -> "Connection: keep-alive\r\n"
    -> "Strict-Transport-Security: max-age=31536000\r\n"
    -> "Content-Type: application/json\r\n"
    -> "Content-Length: 1491\r\n"
    -> "X-Content-Type-Options: nosniff\r\n"
    -> "Server: thin 1.6.2 codename Doc Brown\r\n"
    -> "Via: 1.1 vegur\r\n"
    -> "\r\n"

    Please get only the XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX as your trunk token.

  • register the your trunk token as Secrets and named it as COCOAPODS_TRUNK_TOKEN.

Usage

The workflow, usually declared in .github/workflows/deploy_to_cocoapods.yml, looks like:

name: deploy_to_cocoapods

on:
  push:
    tags:
      - '*'

jobs:
  build:

    runs-on: macOS-latest

    steps:
    - uses: actions/checkout@v1
    
    - name: Install Cocoapods
      run: gem install cocoapods
    
    # shortcut version
    - uses: michaelhenry/[email protected]
      env:
        COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

OR

name: deploy_to_cocoapods

on:
  push:
    tags:
      - '*'

jobs:
  build:

    runs-on: macOS-latest

    steps:
    - uses: actions/checkout@v1
    
    - name: Install Cocoapods
      run: gem install cocoapods
      
    - name: Deploy to Cocoapods
      run: |
        set -eo pipefail
        pod lib lint --allow-warnings
        pod trunk push --allow-warnings
      env:
        COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

Example

An actual example can be found on this Repository: Autobot.

Recommendations

I also do recommend to automatically sync your library versioning with your git tags or releases. for example this *.spec file, I provided an environment variable for LIB_VERSION to use as the actual version, else it will goes to fallback version which is 1.0

Pod::Spec.new do |s|
  s.name             = 'AutoBot'
  s.version          = ENV['LIB_VERSION'] || '1.0' #fallback to major version
  s.summary          = 'UITestCases generator and executor for iOS Application.'
...
end

on the github action, we have to update the step Deploy to Cocoapods from

...
    - name: Deploy to Cocoapods
      run: |
        set -eo pipefail
        pod lib lint --allow-warnings
        pod trunk push --allow-warnings
      env:
        COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

to

...
    - name: Deploy to Cocoapods
      run: |
        set -eo pipefail
        export LIB_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)
        pod lib lint --allow-warnings
        pod trunk push --allow-warnings
      env:
        COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

and that's all.

Cheers!

If you found some problems or encountered some troubles, please don't hessitate to let me know. I'm happy to help you!

LICENSE

MIT

deploy-to-cocoapods-github-action's People

Contributors

michaelhenry avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.