DevOps for Mobile Apps Demo - November 1, 2021

Recording

https://youtu.be/O3LOSClDuiI

Mission

DevOps for Mobile Apps Single-Engineer Group

Our goal is to improve the experience for Developers targeting mobile platforms by providing CI/CD capabilities and workflows that improve the experience of provisioning and deploying mobile apps.

Demos like this one are published each week, you can find previous demos and see new ones when they are finished in the Weekly Demos issue.

Current Update - Code Signing and Beta Releases with Fastlane

iOS Pipeline

https://gitlab.com/gitlab-org/incubation-engineering/devops-for-mobile-apps/gitlab_unfiltered/-/merge_requests/4

https://gitlab.com/gitlab-org/incubation-engineering/devops-for-mobile-apps/gitlab_unfiltered/-/pipelines/397911226

Fastlane Match

A new approach to iOS and macOS code signing: Share one code signing identity across your development team to simplify your codesigning setup and prevent code signing issues.

Once Match is set up and the Matchfile has been added, configure the MATCH_PASSWORD in the GitLab project.

App Store Connect API

The App Store Connect API is a REST API that enables the automation of actions you take in App Store Connect.

https://developer.apple.com/documentation/appstoreconnectapi

See the Creating an App Store Connect API Key section: https://www.runway.team/blog/how-to-build-the-perfect-fastlane-pipeline-for-ios

Once set up, configure the following environment variables in the GitLab project:

  • APP_STORE_CONNECT_API_KEY_ISSUER_ID
  • APP_STORE_CONNECT_API_KEY_KEY_ID
  • APP_STORE_CONNECT_API_KEY_KEY

Fastlane beta deploy

.gitlab-ci.yml

beta_ios:
  image: macos-11-xcode-12
  stage: beta
  script:
    - flutter upgrade
    - bundle install
    - flutter pub get
    - cd ios
    - pod install
    - flutter build ios --dart-define=YOU_TUBE_API_KEY=${YOU_TUBE_API_KEY} --dart-define=YOU_TUBE_CHANNEL_ID=${YOU_TUBE_CHANNEL_ID}  --release --no-codesign
    - bundle exec fastlane ios beta
  tags: 
    - shared-macos-amd64
  when: manual
  allow_failure: true
  only:
    refs:
      - master  

Fastfile

desc "Push a new beta build to TestFlight"
lane :beta do
  setup_ci

  match(type: 'appstore')

  app_store_connect_api_key(
    is_key_content_base64: true
  )

  # use https://github.com/tianhaoz95/fastlane-plugin-flutter_version to set version
  increment_version_number(
    xcodeproj: "Runner.xcodeproj",
    version_number: flutter_version()["version_name"] # Version Name
  )
  increment_build_number(
    xcodeproj: "Runner.xcodeproj",
    build_number: flutter_version()["version_code"] # Version Code
  )

  build_app(workspace: "Runner.xcworkspace", scheme: "Runner")
  
  upload_to_testflight
end

Command Reference:

  1. http://docs.fastlane.tools/actions/setup_ci/
  2. https://docs.fastlane.tools/actions/match/
  3. https://docs.fastlane.tools/actions/app_store_connect_api_key/
  4. https://github.com/tianhaoz95/fastlane-plugin-flutter_version
  5. https://docs.fastlane.tools/actions/build_app/
  6. https://docs.fastlane.tools/actions/upload_to_testflight/

Note: A Distribution Certificate is also needed to release to the app store. Instructions to setup a Distribution Certificate can be found here: https://support.staffbase.com/hc/en-us/articles/115003458931-Creating-the-iOS-Distribution-Certificate

Potential Contributions to Fastlane

Additional Resources

Flutter

Fastlane

Up Next

  • Improve the build efficiency and fix the double compile problem with the beta release step
  • Set up a beta release pipeline for the Android version of the app
Edited by Darby Frey