Skip to content

Commit

Permalink
[#4] Set up CD pipeline for deploying iOS staging build to TestFlight
Browse files Browse the repository at this point in the history
  • Loading branch information
Thieurom committed Aug 1, 2023
1 parent 31b1744 commit 6a1ceab
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 117 deletions.
61 changes: 0 additions & 61 deletions .github/workflows/ios_deploy_staging_to_firebase.yml

This file was deleted.

69 changes: 69 additions & 0 deletions .github/workflows/ios_deploy_staging_to_testflight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: iOS - Deploy Staging build to TestFlight
on:
push:
branches:
- develop

jobs:
build_and_upload_staging_to_testflight:
name: Build and upload iOS Staging build to TestFlight
runs-on: macOS-latest
steps:
- name: Check out
uses: actions/checkout@v3

- name: Install SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Set up Flutter environment
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.10.5'
- run: flutter --version

- name: Set up deployment environment
env:
ENV_STAGING: ${{ secrets.ENV_STAGING }}
run: echo "$ENV_STAGING" > .env.staging

- name: Get Flutter dependencies
run: flutter pub get

- name: Run code generator
run: flutter packages pub run build_runner build --delete-conflicting-outputs

- name: Cache Ruby gems
uses: actions/cache@v3
id: bunlderCache
with:
path: ios/vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-gems-

- name: Cache Pods
uses: actions/cache@v3
id: cocoapodCache
with:
path: ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: ${{ runner.os }}-pods-

- name: Install iOS dependencies
run: cd ios && bundle install --path vendor/bundle && bundle exec pod install

- name: Sync certificates and profiles
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSPHRASE }}
run: cd ios && bundle exec fastlane sync_appstore_staging_signing

- name: Build and Deploy to TestFlight
env:
BUILD_NUMBER: ${{ secrets.GITHUB_RUN_NUMBER }}
TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPSTORE_CONNECT_API_KEY_ID: ${{ secrets.APPSTORE_CONNECT_API_KEY_ID }}
APPSTORE_CONNECT_ISSUER_ID: ${{ secrets.APPSTORE_CONNECT_ISSUER_ID }}
APPSTORE_CONNECT_API_KEY_CONTENT: ${{ secrets.APPSTORE_CONNECT_API_KEY_CONTENT }}
run: cd ios && bundle exec fastlane build_and_upload_staging_to_testflight
53 changes: 0 additions & 53 deletions .github/workflows/ios_deploy_to_testflight.yml

This file was deleted.

2 changes: 2 additions & 0 deletions ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ DerivedData/
fastlane/README.md
fastlane/report.xml
.envfile
.bundle
vendor/bundle

# Exceptions to above rules.
!default.mode1v3
Expand Down
16 changes: 16 additions & 0 deletions ios/fastlane/Constants/Environments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ def self.CI
ENV['CI']
end

def self.BUILD_NUMBER
ENV["BUILD_NUMBER"]
end

def self.MANUAL_VERSION
ENV['MANUAL_VERSION']
end
Expand All @@ -15,6 +19,18 @@ def self.TEAM_ID
ENV['TEAM_ID']
end

def self.APPSTORE_CONNECT_API_KEY_ID
ENV['APPSTORE_CONNECT_API_KEY_ID']
end

def self.APPSTORE_CONNECT_ISSUER_ID
ENV['APPSTORE_CONNECT_ISSUER_ID']
end

def self.APPSTORE_CONNECT_API_KEY_CONTENT
ENV['APPSTORE_CONNECT_API_KEY_CONTENT']
end

#################
### Firebase ###
#################
Expand Down
16 changes: 13 additions & 3 deletions ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ platform :ios do
# Testflight

desc 'Build and upload Staging app to Test Flight'
lane :build_and_upload_testflight_app do
lane :build_and_upload_staging_to_testflight_app do
set_app_version
bump_build
builder.build_app_store(
Expand Down Expand Up @@ -138,10 +138,10 @@ platform :ios do
end
end

desc 'set build number with number of commits'
desc 'set build number'
private_lane :bump_build do
increment_build_number(
build_number: number_of_commits,
build_number: Environments.BUILD_NUMBER,
xcodeproj: Constants.PROJECT_PATH
)
end
Expand All @@ -155,4 +155,14 @@ platform :ios do
notes: ""
)
end

desc 'set App Store Connect API Key'
private_lane :set_appstore_connect_api_key do
app_store_connect_api_key(
key_id: Environments.APPSTORE_CONNECT_API_KEY_ID,
issuer_id: Environments.APPSTORE_CONNECT_ISSUER_ID,
key_content: Environments.APPSTORE_CONNECT_API_KEY_CONTENT,
is_key_content_base64: true
)
end
end

0 comments on commit 6a1ceab

Please sign in to comment.