Skip to content

Instantly share code, notes, and snippets.

@ChrisXu
Last active January 16, 2019 22:14
Show Gist options
  • Select an option

  • Save ChrisXu/23e05c6fe469c6a8aaf6 to your computer and use it in GitHub Desktop.

Select an option

Save ChrisXu/23e05c6fe469c6a8aaf6 to your computer and use it in GitHub Desktop.

Revisions

  1. ChrisXu revised this gist Feb 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,7 @@

    ## Files structure

    you files will look like this
    Your files will look like this

    - Repo Root
    - Project folder
  2. ChrisXu revised this gist Feb 14, 2016. 1 changed file with 21 additions and 2 deletions.
    23 changes: 21 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -24,9 +24,28 @@
    6. Export `iOS Provisioning Profile (Distribution)` into travis/profile/distribution_profile.mobileprovision
    7. Create the folder "travis/scripts"
    8. Copy add-key.sh, remove-key.sh and sign-and-upload.sh into travis/scripts
    9. Download `submit` into travis/ at [my dropbox file](https://www.dropbox.com/s/3aa8pj4bhknwjg3/submit?dl=0).
    9. Download [submit]((https://www.dropbox.com/s/3aa8pj4bhknwjg3/submit?dl=0)) into travis/.
    - I manually pull out the 'submit' file in Crashlytics.framework(3.6.0). Please let me know if it has new update, I will renew the file
    10. Execute travis encrypt "DIST_PWD=YOUR_DISTRIBUTION_PASSWORD" --add
    11. Execute travis encrypt "FABRIC_API_KEY=YOUR_FABRIC_API_KEY" --add
    12. Execute travis encrypt "FABRIC_BUILD_SECRET=YOUR_FABRIC_BUILD_SECRET" --add
    13. Commit
    13. Commit

    ## Files structure

    you files will look like this

    - Repo Root
    - Project folder
    - `.travis.yml`
    - travis
    - `submit`
    - certs
    - `ios_distribution.cet`
    - `ios_distribution.p12`
    - profile
    - `distribution_profile.mobileprovision`
    - scripts
    - `add-key.sh`
    - `remove-key.sh`
    - `sign-and-upload.sh`
  3. ChrisXu revised this gist Feb 14, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    ## Ref
    - https://www.objc.io/issues/6-build-tools/travis-ci/
    - https://gist.github.com/johanneswuerbach/5559514
    - [Travis CI for iOS](https://www.objc.io/issues/6-build-tools/travis-ci/)
    - [Deploy an iOS app to testflight using Travis CI](https://gist.github.com/johanneswuerbach/5559514)

    ## Instructions

    ###Deploy an app automatically to Fabric Beta using Travis-CI.
    ####Deploy an app automatically to Fabric Beta using Travis-CI.

    1. Copy the .travis.yml into your repo
    2. Replace the following fields
    @@ -24,7 +24,7 @@
    6. Export `iOS Provisioning Profile (Distribution)` into travis/profile/distribution_profile.mobileprovision
    7. Create the folder "travis/scripts"
    8. Copy add-key.sh, remove-key.sh and sign-and-upload.sh into travis/scripts
    9. Download `submit` into travis/ at here.(https://www.dropbox.com/s/3aa8pj4bhknwjg3/submit?dl=0)
    9. Download `submit` into travis/ at [my dropbox file](https://www.dropbox.com/s/3aa8pj4bhknwjg3/submit?dl=0).
    - I manually pull out the 'submit' file in Crashlytics.framework(3.6.0). Please let me know if it has new update, I will renew the file
    10. Execute travis encrypt "DIST_PWD=YOUR_DISTRIBUTION_PASSWORD" --add
    11. Execute travis encrypt "FABRIC_API_KEY=YOUR_FABRIC_API_KEY" --add
  4. ChrisXu created this gist Feb 14, 2016.
    26 changes: 26 additions & 0 deletions .travis.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    language: objective-c
    osx_image: xcode7.2
    xcode_sdk: iphonesimulator9.2

    env:
    global:
    - LANG=en_US.UTF-8
    - WORKSPACE="YOUR_APP_WORKSPACE/YOUR_APP_PROJECT.xcworkspace"
    - SCHEME="YOUR_BUILDSCHEME"
    - APP_NAME="YOUR_APP_NAME"
    - EMAILS="tester@mail, someone@mail"
    - GROUP_ALIASES="$FABRIC_GROUP"
    - PROFILE_NAME="distribution_profile"
    - 'DEVELOPER_NAME="iPhone Distribution: NAME_OF_THE_DEVELOPER (CODE)"'
    matrix:
    - DESTINATION="generic/platform=iOS" SDK="iphoneos"
    before_script:
    - "./travis/scripts/add-key.sh"
    script:
    - xctool clean build -workspace "$WORKSPACE" -scheme
    "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release OBJROOT=$PWD/build
    SYMROOT=$PWD/build ONLY_ACTIVE_ARCH=NO 'CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist'
    after_success:
    - "./travis/scripts/sign-and-upload.sh"
    after_script:
    - "./travis/scripts/remove-key.sh"
    32 changes: 32 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    ## Ref
    - https://www.objc.io/issues/6-build-tools/travis-ci/
    - https://gist.github.com/johanneswuerbach/5559514

    ## Instructions

    ###Deploy an app automatically to Fabric Beta using Travis-CI.

    1. Copy the .travis.yml into your repo
    2. Replace the following fields
    - WORKSPACE
    - SCHEME (build scheme)
    - APP_NAME
    - DEVELOPER_NAME
    - PROFILE_NAME
    - EMAILS (those who you want to notify)
    - GROUP_ALIASES (group for tester on Fabric)
    3. Create the folder "travis/certs"
    4. Export the following things from the Keychain app
    - "Apple Worldwide Developer Relations Certification Authority" into travis/certs/apple.cer
    - Your iPhone Distribution certificate into travis/certs/ios_distribution.cer
    - Your iPhone Distribution private key into travis/certs/ios_distribution.p12 (choose a password)
    5. Create the folder "travis/profile"
    6. Export `iOS Provisioning Profile (Distribution)` into travis/profile/distribution_profile.mobileprovision
    7. Create the folder "travis/scripts"
    8. Copy add-key.sh, remove-key.sh and sign-and-upload.sh into travis/scripts
    9. Download `submit` into travis/ at here.(https://www.dropbox.com/s/3aa8pj4bhknwjg3/submit?dl=0)
    - I manually pull out the 'submit' file in Crashlytics.framework(3.6.0). Please let me know if it has new update, I will renew the file
    10. Execute travis encrypt "DIST_PWD=YOUR_DISTRIBUTION_PASSWORD" --add
    11. Execute travis encrypt "FABRIC_API_KEY=YOUR_FABRIC_API_KEY" --add
    12. Execute travis encrypt "FABRIC_BUILD_SECRET=YOUR_FABRIC_BUILD_SECRET" --add
    13. Commit
    20 changes: 20 additions & 0 deletions add-key.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    # Create a custom keychain
    security create-keychain -p travis ios-build.keychain

    # Make the custom keychain default
    security default-keychain -s ios-build.keychain

    # Unlock the keychain
    security unlock-keychain -p travis ios-build.keychain

    # Set keychain timeout to 1 hour for long builds
    security set-keychain-settings -t 3600 -l ~/Library/Keychains/ios-build.keychain

    # Add certificates to keycahin adn allow codesign to access them
    security import ./travis/certs/apple.cer -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign
    security import ./travis/certs/ios_distribution.cer -k ~/Library/Keychains/ios-build.keychain -T /usr/bin/codesign
    security import ./travis/certs/ios_distribution.p12 -k ~/Library/Keychains/ios-build.keychain -P $DIST_PWD -T /usr/bin/codesign

    # Put the provisioning profile in place
    mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
    cp ./travis/profile/* ~/Library/MobileDevice/Provisioning\ Profiles/
    5 changes: 5 additions & 0 deletions remove-key.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # Delete keychain
    security delete-keychain ios-build.keychain

    # Remove provisioning profile
    rm -f ~/Library/MobileDevice/Provisioning\ Profiles/*
    45 changes: 45 additions & 0 deletions sign-and-upload.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    #!/bin/sh

    # Skip uploading if it is a pull request. you can mark this if you don't need it
    if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
    echo "This is a pull request. No deployment will be done."
    exit 0
    fi

    # Skip uploading if it is not on master. you can mark this if you don't need it
    if [[ "$TRAVIS_BRANCH" != "master" ]]; then
    echo "Testing on a branch other than master. No deployment will be done."
    exit 0
    fi

    # Construct the infomation for this build
    COMMIT_MESSAGE=`git log -1 --no-merges --pretty="%h - %s"`
    GIT_REVISION=$(git rev-parse --short HEAD)
    RELEASE_DATE=`date '+%Y-%m-%d %H:%M:%S'`

    echo "********************"
    echo "* Signing *"
    echo "********************"

    PROVISIONING_PROFILE="$HOME/Library/MobileDevice/Provisioning Profiles/$PROFILE_NAME.mobileprovision"
    OUTPUTDIR="$PWD/build/Release-iphoneos"

    # Package the ipa
    xcrun -log -sdk iphoneos PackageApplication "$OUTPUTDIR/$APP_NAME.app" -o "$OUTPUTDIR/$APP_NAME.ipa" -sign "$DEVELOPER_NAME" -embed "$PROVISIONING_PROFILE"

    # Create release note file
    echo "Build: $GIT_REVISION\nDate: $RELEASE_DATE\nNote: $COMMIT_MESSAGE" > $OUTPUTDIR/release_note.txt

    RELEASE_NOTES_PATH="$OUTPUTDIR/release_note.txt"
    IPA_PATH="$OUTPUTDIR/$APP_NAME.ipa"

    echo "********************"
    echo "* Uploading *"
    echo "********************"
    # Upload the file to Fabric
    # Note: I manually pull out the 'submit' file in Crashlytics.framework(3.6.0). You might need to check the updated framework
    ./travis/submit $FABRIC_API_KEY $FABRIC_BUILD_SECRET \
    -ipaPath $IPA_PATH -emails $EMAILS \
    -notesPath $RELEASE_NOTES_PATH \
    -groupAliases $GROUP_ALIASES \
    -notifications YES