Skip to content

[#558] Workflow for firebase deployment to development environment #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/project_workflows/deploy_dev_firebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Deploy Dev Build To Firebase

# SECRETS needed:
### SSH_PRIVATE_KEY for Match Repo
### MATCH_PASS
### FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64

on:
push:
branches: [ develop ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Run SwiftLint
uses: docker://norionomura/swiftlint:0.53.0_swift-5.7
with:
args: swiftlint --strict

build:
name: Build
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
# Set fetch-depth (default: 1) to get whole tree
with:
fetch-depth: 0

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

- name: Install Firebase-Tools
run: |
yarn global add firebase-tools
echo "$(yarn global bin)" >> $GITHUB_PATH

- name: Setup ENV file
env:
ENV: ${{ secrets.ENV }}
run: |
echo "$ENV" > .env

- name: Read Google Service Account
id: firebase_service_account
uses: timheuer/[email protected]
with:
fileName: 'firebase_service_account.json'
encodedString: ${{ secrets.FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}

- name: Bundle install
# if: steps.bundleCache.outputs.cache-hit != 'true'
run: bundle install

- name: Run Arkana
run: bundle exec arkana

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

- name: Install Pods Dependencies
run: bundle exec pod install
shell: bash

- name: Build and Test
run: bundle exec fastlane buildAndTestDev

- name: Match Ad-hoc
run: bundle exec fastlane syncAdHocDevCodeSigning
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASS }}

- name: Build App and Distribute to Firebase
run: bundle exec fastlane buildDevAndUploadToFirebase
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.firebase_service_account.outputs.filePath }}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ format('v{0}({1})-{2}', env.VERSION_NUMBER, env.BUILD_NUMBER, env.TAG_TYPE) }}
path: |
${{ env.IPA_OUTPUT_PATH }}
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: Dev_Firebase

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
3 changes: 1 addition & 2 deletions .github/project_workflows/deploy_production_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ jobs:
env:
ENV: ${{ secrets.ENV }}
run: |
touch .env
echo $ENV | base64 --decode > .env
echo "$ENV" > .env

- name: Read Google Service Account
id: firebase_service_account
Expand Down
3 changes: 1 addition & 2 deletions .github/project_workflows/deploy_staging_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ jobs:
env:
ENV: ${{ secrets.ENV }}
run: |
touch .env
echo $ENV | base64 --decode > .env
echo "$ENV" > .env

- name: Read Google Service Account
id: firebase_service_account
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_swiftui_install_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: bundle install

- name: Start Install Script for SwiftUI Template App
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface SwiftUI
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --bundle-id-dev co.nimblehq.ios.templates.dev --project-name TemplateApp --interface SwiftUI

- name: Build and Test
run: bundle exec fastlane buildAndTest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_uikit_install_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: bundle install

- name: Start Install Script for UIKit Template App
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface UIKit
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --bundle-id-dev co.nimblehq.ios.templates.dev --project-name TemplateApp --interface UIKit

- name: Build and Test
run: bundle exec fastlane buildAndTest
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test_upload_build_to_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ name: Test Upload Build to Firebase
### SSH_PRIVATE_KEY for Match Repo
### MATCH_PASS
### FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64
### STAGING_FIREBASE_APP_ID
### TEAM_ID

on:
Expand Down Expand Up @@ -54,13 +53,12 @@ jobs:
${{ runner.os }}-pods-

- name: Start Install Script for Template App
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface UIKit
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --bundle-id-dev co.nimblehq.ios.templates.dev --project-name TemplateApp --interface UIKit

- name: Start Setup Script for Template App Firebase Upload
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make-test-firebase
env:
MATCH_REPO: ${{ secrets.MATCH_REPO }}
STAGING_FIREBASE_APP_ID: ${{ secrets.STAGING_FIREBASE_APP_ID }}
TEAM_ID: ${{ secrets.TEAM_ID }}

- name: Set Up Test Project for Firebase
Expand All @@ -77,7 +75,7 @@ jobs:
GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.firebase_service_account.outputs.filePath }}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ format('v{0}({1})-{2}', env.VERSION_NUMBER, env.BUILD_NUMBER, env.TAG_TYPE) }}
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_upload_build_to_test_flight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
${{ runner.os }}-pods-

- name: Start Install Script for Template App
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface UIKit
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --bundle-id-dev co.nimblehq.ios.templates.dev --project-name TemplateApp --interface UIKit

- name: Start Setup Script for Template App TestFlight Upload
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make-test-test-flight
Expand Down
90 changes: 90 additions & 0 deletions .github/workflows/test_upload_dev_build_to_firebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Test Upload Dev Build to Firebase

# SECRETS needed:
### SSH_PRIVATE_KEY for Match Repo
### MATCH_PASS
### FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64
### TEAM_ID

on:
pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: macOS-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0

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

- name: Install Firebase-Tools
run: |
yarn global add firebase-tools
echo "$(yarn global bin)" >> $GITHUB_PATH

- name: Read Google Service Account
id: firebase_service_account
uses: timheuer/[email protected]
with:
fileName: 'firebase_service_account.json'
encodedString: ${{ secrets.FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}

- name: Bundle install
run: bundle install

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

- name: Start Install Script for Template App
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --bundle-id-dev co.nimblehq.ios.templates.dev --project-name TemplateApp --interface UIKit

- name: Start Setup Script for Template App Firebase Upload
run: swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make-test-firebase
env:
MATCH_REPO: ${{ secrets.MATCH_REPO }}
TEAM_ID: ${{ secrets.TEAM_ID }}

- name: Set Up Test Project for Firebase
run: bundle exec fastlane setUpTestProject

- name: Sync Ad Hoc Code Signing
run: bundle exec fastlane syncAdHocDevCodeSigning
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASS }}

- name: Build Dev App and Distribute to Firebase
run: bundle exec fastlane buildDevAndUploadToFirebase
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.firebase_service_account.outputs.filePath }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ format('v{0}({1})-{2}', env.VERSION_NUMBER, env.BUILD_NUMBER, env.TAG_TYPE) }}
path: |
${{ env.IPA_OUTPUT_PATH }}
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: Dev_Firebase

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
1 change: 1 addition & 0 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extension Project {
schemes: [
.productionScheme(name: name),
.stagingScheme(name: name),
.devScheme(name: name),
.kifUITestsScheme(name: name)
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
enum EnvironmentKey: String {

case matchRepo = "MATCH_REPO"
case stagingFirebaseAppId = "STAGING_FIREBASE_APP_ID"
case teamId = "TEAM_ID"
case apiKey = "API_KEY_ID"
case issuerId = "ISSUER_ID"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import Foundation
struct SetUpTestFirebase {

private let teamIdPlaceholder = "<#teamId#>"
private let devFirebaseAppIdPlaceholder = "<#devFirebaseAppId#>"
private let stagingFirebaseAppIdPlaceholder = "<#stagingFirebaseAppId#>"
private let firebaseTesterGroupsPlaceholder = "<#group1#>, <#group2#>"
private let matchRepoPlaceholder = "[email protected]:{organization}/{repo}.git"

private let firebaseTesterGroup = "nimble"
private let fileManager = FileManager.default
private let devFirebaseAppId: String = "1:394751167018:ios:bc6ca71168a46096b21153"
private let stagingFirebaseAppId: String = "1:394751167018:ios:7670aacd2a018cd5b21153"

let matchRepo: String
let stagingFirebaseAppId: String
let teamId: String

func perform() {
fileManager.replaceAllOccurrences(of: teamIdPlaceholder, to: teamId)
fileManager.replaceAllOccurrences(of: devFirebaseAppIdPlaceholder, to: devFirebaseAppId)
fileManager.replaceAllOccurrences(of: stagingFirebaseAppIdPlaceholder, to: stagingFirebaseAppId)
fileManager.replaceAllOccurrences(of: firebaseTesterGroupsPlaceholder, to: firebaseTesterGroup)
fileManager.replaceAllOccurrences(of: matchRepoPlaceholder, to: matchRepo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ class SetUpIOSProject {
private let CONSTANT_PROJECT_NAME = "{PROJECT_NAME}"
private let CONSTANT_BUNDLE_PRODUCTION = "{BUNDLE_ID_PRODUCTION}"
private let CONSTANT_BUNDLE_STAGING = "{BUNDLE_ID_STAGING}"
private let CONSTANT_BUNDLE_DEV = "{BUNDLE_ID_DEV}"
private let CONSTANT_MINIMUM_VERSION = "{TARGET_VERSION}"
private let fileManager = FileManager.default

private var bundleIdProduction = ""
private var bundleIdStaging = ""
private var bundleIdDev = ""
private var projectName = ""
private var minimumVersion = ""
private var interface: SetUpInterface.Interface?
Expand All @@ -20,12 +22,14 @@ class SetUpIOSProject {
init(
bundleIdProduction: String = "",
bundleIdStaging: String = "",
bundleIdDev: String = "",
projectName: String = "",
minimumVersion: String = "",
interface: String = ""
) {
self.bundleIdProduction = bundleIdProduction
self.bundleIdStaging = bundleIdStaging
self.bundleIdDev = bundleIdDev
self.projectName = projectName
self.minimumVersion = minimumVersion
self.interface = .init(interface)
Expand Down Expand Up @@ -110,6 +114,15 @@ class SetUpIOSProject {
onValidate: validatePackageName
)
}

if bundleIdDev.isEmpty {
tryMoveDown()
bundleIdDev = ask(
"Which is the bundle ID for the dev environment?",
note: "Ex: com.example.project.dev",
onValidate: validatePackageName
)
}

if projectName.isEmpty {
tryMoveDown()
Expand Down Expand Up @@ -159,6 +172,7 @@ class SetUpIOSProject {
}

private func replaceTextInFiles() throws {
fileManager.replaceAllOccurrences(of: CONSTANT_BUNDLE_DEV, to: bundleIdDev)
fileManager.replaceAllOccurrences(of: CONSTANT_BUNDLE_STAGING, to: bundleIdStaging)
fileManager.replaceAllOccurrences(of: CONSTANT_BUNDLE_PRODUCTION, to: bundleIdProduction)
fileManager.replaceAllOccurrences(of: CONSTANT_PROJECT_NAME, to: projectNameNoSpace)
Expand Down
Loading
Loading