Skip to content

Instantly share code, notes, and snippets.

@soleo
Forked from johanneswuerbach/.travis.yml
Created September 24, 2015 16:53
Show Gist options
  • Select an option

  • Save soleo/d08257c08b180ba0d0c3 to your computer and use it in GitHub Desktop.

Select an option

Save soleo/d08257c08b180ba0d0c3 to your computer and use it in GitHub Desktop.

Revisions

  1. @johanneswuerbach johanneswuerbach revised this gist May 11, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .travis.yml
    Original file line number Diff line number Diff line change
    @@ -9,5 +9,5 @@ after_success:
    env:
    global:
    - APPNAME="NAME_OF_THE_APP"
    - DEVELOPER_NAME="iPhone Distribution: NAME_OF_THE_DEVELOPER (CODE)"
    - 'DEVELOPER_NAME="iPhone Distribution: NAME_OF_THE_DEVELOPER (CODE)"'
    - PROFILE_UUID=PROVISIONING_PROFILE_UUID
  2. @johanneswuerbach johanneswuerbach revised this gist May 11, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions testflight.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,8 @@ if [[ "$TRAVIS_BRANCH" != "master" ]]; then
    exit 0
    fi

    # Thanks @djacobs https://gist.github.com/djacobs/2411095

    PROVISIONING_PROFILE="$HOME/Library/MobileDevice/Provisioning Profiles/$PROFILE_UUID.mobileprovision"
    RELEASE_DATE=`date '+%Y-%m-%d %H:%M:%S'`
    OUTPUTDIR="$PWD/build/Release-iphoneos"
  3. @johanneswuerbach johanneswuerbach created this gist May 11, 2013.
    13 changes: 13 additions & 0 deletions .travis.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    ---
    language: objective-c
    before_script:
    - ./scripts/travis/add-key.sh
    after_script:
    - ./scripts/travis/remove-key.sh
    after_success:
    - ./scripts/travis/testflight.sh
    env:
    global:
    - APPNAME="NAME_OF_THE_APP"
    - DEVELOPER_NAME="iPhone Distribution: NAME_OF_THE_DEVELOPER (CODE)"
    - PROFILE_UUID=PROVISIONING_PROFILE_UUID
    13 changes: 13 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    Deploy an app automatically to testflight using travis ci.

    1. Copy the .travis.yml into your repo (replace app name, developer name and provisionin profile uuid)
    2. Create the folder "scripts/travis"
    3. Export the following things from the Keychain app
    1. "Apple Worldwide Developer Relations Certification Authority" into scripts/travis/apple.cer
    2. Your iPhone Distribution certificate into scripts/travis/dist.cer
    3. Your iPhone Distribution private key into scripts/travis/dist.p12 (choose a password)
    4. Execute `travis encrypt "KEY_PASSWORD=YOUR_KEY_PASSWORD" --add`
    5. Execute `travis encrypt "TEAM_TOKEN=TESTFLIGHT_TEAM_TOKEN" --add`
    6. Execute `travis encrypt "API_TOKEN=TESTFLIGHT_API_TOKEN" --add`
    7. Copy add-key.sh, remove-key.sh and testflight.sh into scripts/travis
    8. Commit
    6 changes: 6 additions & 0 deletions add-key.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    security create-keychain -p travis ios-build.keychain
    security import ./scripts/travis/apple.cer -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign
    security import ./scripts/travis/dist.cer -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign
    security import ./scripts/travis/dist.p12 -k ~/Library/Keychains/ios-build.keychain -P $KEY_PASSWORD -T /usr/bin/codesign
    mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
    cp ./scripts/travis/profile/* ~/Library/MobileDevice/Provisioning\ Profiles/
    2 changes: 2 additions & 0 deletions remove-key.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    security delete-keychain ios-build.keychain
    rm -f ~/Library/MobileDevice/Provisioning\ Profiles/*
    33 changes: 33 additions & 0 deletions testflight.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #!/bin/sh
    if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
    echo "This is a pull request. No deployment will be done."
    exit 0
    fi
    if [[ "$TRAVIS_BRANCH" != "master" ]]; then
    echo "Testing on a branch other than master. No deployment will be done."
    exit 0
    fi

    PROVISIONING_PROFILE="$HOME/Library/MobileDevice/Provisioning Profiles/$PROFILE_UUID.mobileprovision"
    RELEASE_DATE=`date '+%Y-%m-%d %H:%M:%S'`
    OUTPUTDIR="$PWD/build/Release-iphoneos"

    echo "********************"
    echo "* Signing *"
    echo "********************"
    xcrun -log -sdk iphoneos PackageApplication "$OUTPUTDIR/$APPNAME.app" -o "$OUTPUTDIR/$APPNAME.ipa" -sign "$DEVELOPER_NAME" -embed "$PROVISIONING_PROFILE"

    RELEASE_NOTES="Build: $TRAVIS_BUILD_NUMBER\nUploaded: $RELEASE_DATE"

    zip -r -9 "$OUTPUTDIR/$APPNAME.app.dSYM.zip" "$OUTPUTDIR/$APPNAME.app.dSYM"

    echo "********************"
    echo "* Uploading *"
    echo "********************"
    curl http://testflightapp.com/api/builds.json \
    -F file="@$OUTPUTDIR/$APPNAME.ipa" \
    -F dsym="@$OUTPUTDIR/$APPNAME.app.dSYM.zip" \
    -F api_token="$API_TOKEN" \
    -F team_token="$TEAM_TOKEN" \
    -F distribution_lists='Internal' \
    -F notes="$RELEASE_NOTES" -v