Skip to content

Commit

Permalink
Get rid of duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
BramDC3 committed Sep 11, 2024
1 parent 34eabee commit 5f9d5b7
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 164 deletions.
25 changes: 25 additions & 0 deletions .github/actions/build-android/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Build Android"
description: "Build Android"
inputs:
type:
description: 'Build type (should be debug or release)'
required: true
google_services_json:
description: 'Base64 encoded google-services.json'
required: true
runs:
using: "composite"
steps:
- name: Decode and save google-services.json
shell: bash
run: echo "${{ inputs.google_services_json }}" | base64 -d > ./android/app/google-services.json

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Build ${{ inputs.type }}
shell: bash
run: bundle exec fastlane android build_${{ inputs.type }}
23 changes: 23 additions & 0 deletions .github/actions/prepare-macos-runner/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Prepare macOS runner"
description: "Prepare macOS runner"
runs:
using: "composite"
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change

- name: Install gems
shell: bash
run: bundle install

- name: Install FVM
shell: bash
run: |
brew tap leoafarias/fvm
brew install fvm
- name: Set up FVM
shell: bash
run: fvm use
21 changes: 21 additions & 0 deletions .github/actions/prepare-ubuntu-runner/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Prepare Ubuntu runner"
description: "Prepare Ubuntu runner"
runs:
using: "composite"
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change

- name: Install gems
shell: bash
run: bundle install

- name: Install FVM
shell: bash
run: curl -fsSL https://fvm.app/install.sh | bash

- name: Set up FVM
shell: bash
run: fvm use
51 changes: 51 additions & 0 deletions .github/workflows/default-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: default-workflow
on: [push]
# on:
# push:
# branches:
# - main
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Prepare runner
uses: ./.github/actions/prepare-ubuntu-runner

- name: Run virtual machine tests
run: bundle exec fastlane run_vm_tests

build_android:
name: Build Android debug
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4

- name: Prepare runner
uses: ./.github/actions/prepare-ubuntu-runner

- name: Build debug
uses: ./.github/actions/build-android
with:
type: debug
google_services_json: ${{ secrets.GOOGLE_SERVICES_JSON }}

build_ios:
name: Build iOS debug
runs-on: macos-latest
needs: test
steps:
- uses: actions/checkout@v4

- name: Prepare runner
uses: ./.github/actions/prepare-macos-runner

- name: Decode and save GoogleServices-Info.plist
run: echo "${{ secrets.GOOGLESERVICE_INFO_PLIST }}" | base64 -d > ./ios/Runner/GoogleService-Info.plist

- name: Build debug
run: bundle exec fastlane ios build_debug

91 changes: 0 additions & 91 deletions .github/workflows/default-workflow.yml

This file was deleted.

81 changes: 15 additions & 66 deletions .github/workflows/release-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change

- name: Install gems
run: bundle install

- name: Install FVM
run: curl -fsSL https://fvm.app/install.sh | bash

- name: Set up FVM
run: fvm use
- name: Prepare runner
uses: ./.github/actions/prepare-ubuntu-runner

- name: Run virtual machine tests
run: bundle exec fastlane run_vm_tests
Expand All @@ -36,37 +25,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change

- name: Install gems
run: bundle install

- name: Install FVM
run: curl -fsSL https://fvm.app/install.sh | bash

- name: Set up FVM
run: fvm use

- name: Decode and save google-services.json
run: echo "${{ secrets.GOOGLE_SERVICES_JSON }}" | base64 -d > ./android/app/google-services.json
- name: Prepare runner
uses: ./.github/actions/prepare-ubuntu-runner

- name: Decode and save key.properties
run: echo "${{ secrets.ANDROID_KEY_PROPERTIES }}" | base64 -d > ./android/key.properties

- name: Decode and save keystore
run: echo "${{ secrets.COCKTAILR_UPLOAD_KEYSTORE_JKS }}" | base64 -d > ./android/app/cocktailr-upload-keystore.jks

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Build release
run: bundle exec fastlane android build_release
uses: ./.github/actions/build-android
with:
type: release
google_services_json: ${{ secrets.GOOGLE_SERVICES_JSON }}

- name: Upload build artifact
uses: actions/upload-artifact@v4
Expand All @@ -81,21 +53,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change

- name: Install gems
run: bundle install

- name: Install FVM
run: |
brew tap leoafarias/fvm
brew install fvm
- name: Set up FVM
run: fvm use
- name: Prepare runner
uses: ./.github/actions/prepare-macos-runner

- name: Decode and save GoogleServices-Info.plist
run: echo "${{ secrets.GOOGLESERVICE_INFO_PLIST }}" | base64 -d > ./ios/Runner/GoogleService-Info.plist
Expand Down Expand Up @@ -132,13 +91,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change

- name: Install gems
run: bundle install
- name: Prepare runner
uses: ./.github/actions/prepare-ubuntu-runner

- name: Decode and save Firebase App Distribution service account
run: echo "${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_JSON }}" | base64 -d > ./FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json
Expand All @@ -154,18 +108,13 @@ jobs:

distribute_ios:
name: Distribute iOS release
runs-on: macos-latest
runs-on: ubuntu-latest
needs: [build_android, build_ios]
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1.1" # TODO: keep this somewhere where it's easy to change

- name: Install gems
run: bundle install
- name: Prepare runner
uses: ./.github/actions/prepare-ubuntu-runner

- name: Decode and save Firebase App Distribution service account
run: echo "${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_JSON }}" | base64 -d > ./FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ ios/Runner/GoogleService-Info.plist
lib/firebase_options.dart
.firebaserc
firebase-debug.log
FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json
FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json

# App Store
APP_STORE_CONNECT_API_KEY.p8
6 changes: 0 additions & 6 deletions APP_STORE_CONNECT_API_KEY.p8

This file was deleted.

0 comments on commit 5f9d5b7

Please sign in to comment.