Skip to content

NOI community iOS app

Simon Dalvai edited this page Dec 17, 2021 · 1 revision

This is the workflow used for the iOS CI of the NOI community app.
The repo using this can be found here.

name: CI
on: [ pull_request, push ]
jobs:

  ## Test on latest MacOS
  test:
    runs-on: macos-11
    steps:

      - name: Checkout the code
        uses: actions/checkout@v2

      #   # List possible Xcode versions
      # - name: Force Xcode versions
      #   run: sudo ls /Applications/*xcode*

      # See https://xcodereleases.com/ for details (we choose the latest Release)
      - name: Force XCode 13.0.0
        run: sudo xcode-select -switch /Applications/Xcode_13.0.app

      - name: Inject GoogleService-Info.plist
        env:
          GOOGLE_SERVICE_INFO_PLIST: ${{ secrets.GOOGLE_SERVICE_INFO_PLIST }}
        run: echo "$GOOGLE_SERVICE_INFO_PLIST" > NOICommunity/GoogleService-Info.plist        

      - name: Resolve package dependencies
        run: xcodebuild -resolvePackageDependencies

      - name: List schemes (optional step to gather information)
        run: xcodebuild -list -project NOICommunity.xcodeproj

      - name: Test the app
        run: |
          set -eo pipefail
          xcodebuild clean test \
            -scheme NOICommunity \
            -destination 'platform=iOS Simulator,OS=15.0,name=iPhone 13' \
            IPHONEOS_DEPLOYMENT_TARGET='15.0' \
          | xcpretty
  ## Deploy to TestFlight
  deploy_testflight:
    name: Deploy to Testflight
    runs-on: macos-11
    if: github.ref == 'refs/heads/development'
    needs: [ test ]
    steps:

      - name: Checkout the code
        uses: actions/checkout@v2

      # See https://xcodereleases.com/ for details (we choose the latest Release, available on macos-latest)
      - name: Force XCode 13.0.0
        run: sudo xcode-select -switch /Applications/Xcode_13.0.app

      - name: Resolve package dependencies
        run: xcodebuild -resolvePackageDependencies

      - name: Inject GoogleService-Info.plist
        env:
          GOOGLE_SERVICE_INFO_PLIST: ${{ secrets.GOOGLE_SERVICE_INFO_PLIST }}
        run: echo "$GOOGLE_SERVICE_INFO_PLIST" > NOICommunity/GoogleService-Info.plist

      - name: Install gpg (if absent)
        run: gpg --version &>/dev/null || brew install gnupg

      - name: Setup provisioning profile
        env:
          IOS_KEY_PASSPHRASE: ${{ secrets.IOS_KEY_PASSPHRASE }}
        run: ./.github/secrets/decrypt_secrets.sh

      - name: Increment build number
        run: |
          set -eo pipefail
          BUILD_NUMBER=$(date "+%Y%m%d%H%M%S")
          /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" NOICommunity/Info.plist
      - name: Archive the project
        run: |
          set -eo pipefail
          xcodebuild clean archive \
            -configuration Release \
            -scheme NOICommunity \
            -sdk iphoneos \
            -archivePath "$PWD/build/NOICommunity.xcarchive" \
            -destination "generic/platform=iOS,name=Any iOS Device" \
            OTHER_CODE_SIGN_FLAGS="--keychain ~/Library/Keychains/build.keychain" \
            CODE_SIGN_STYLE=Manual \
            PROVISIONING_PROFILE='a5e85966-b44d-4f43-b01d-babf8ce192c3' \
            CODE_SIGN_IDENTITY="Apple Distribution"
      - name: Export .ipa
        run: |
          set -eo pipefail
          xcodebuild -archivePath "$PWD/build/NOICommunity.xcarchive" \
            -exportOptionsPlist exportOptions.plist \
            -exportPath $PWD/build \
            -allowProvisioningUpdates \
            -exportArchive 
      - name: Publish the App on TestFlight
        if: success()
        env:
          APPLEID_USERNAME: ${{ secrets.APPLEID_USERNAME }}
          APPLEID_PASSWORD: ${{ secrets.APPLEID_PASSWORD }}
        run: |
          xcrun altool \
            --upload-app \
            -t ios \
            -f $PWD/build/NOICommunity.ipa \
            -u "$APPLEID_USERNAME" \
            -p "$APPLEID_PASSWORD" \
            --verbose
Clone this wiki locally