Skip to content

Commit

Permalink
Test release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
BramDC3 committed Sep 11, 2024
1 parent 90cdfaa commit a2b4cab
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 69 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/default-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: default-workflow
on: [push]
# TODO:
# on:
# push:
# branches:
# - main
on:
push:
branches:
- main
jobs:
test:
name: Run tests
Expand Down Expand Up @@ -90,6 +88,4 @@ jobs:

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

# - name: Decode and save FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json
# run: echo "${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_JSON }}" | base64 -d > ./FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json

186 changes: 186 additions & 0 deletions .github/workflows/release-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: release-workflow
on: [push]
# TODO:
# on:
# push:
# branches:
# - release/*
jobs:
# test:
# name: Run tests
# runs-on: ubuntu-latest
# 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: Run virtual machine tests
# run: bundle exec fastlane run_vm_tests

# build_android:
# name: Build Android release
# runs-on: ubuntu-latest
# needs: test
# 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: 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

# - name: Upload build artifact
# uses: actions/upload-artifact@v4
# with:
# name: app-release-apk
# path: ./build/app/outputs/flutter-apk/app-release.apk

# distribute_android:
# name: Distribute Android release
# runs-on: ubuntu-latest
# needs: build_android
# 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: 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

# - name: Download build artifact
# uses: actions/download-artifact@v4
# with:
# name: app-release-apk
# path: ./build/app/outputs/flutter-apk

# - name: Distribute release
# run: bundle exec fastlane android distribute_firebase

build_ios:
name: Build iOS release
runs-on: macos-latest
# needs: test
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: Decode and save GoogleServices-Info.plist
run: echo "${{ secrets.GOOGLESERVICE_INFO_PLIST }}" | base64 -d > ./ios/Runner/GoogleService-Info.plist

- name: Decode and save App Store Connect API key
run: echo "${{ secrets.APP_STORE_CONNECT_API_KEY }}" | base64 -d > ./APP_STORE_CONNECT_API_KEY.p8

- name: Set `MATCH_PASSWORD` environment variable
run: echo "MATCH_PASSWORD=${{ secrets.MATCH_PASSWORD }}" >> $GITHUB_ENV

- name: Build release
run: |
echo "${{ secrets.CERTIFICATES_REPO_SSH_KEY }}" > private_key
chmod 600 private_key
ssh-keygen -lf private_key
eval "$(ssh-agent -s)"
ssh-add private_key
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
bundle exec fastlane ios build_release
- name: Zip ipa file
run: zip ./build/ios/ipa/cocktailr.zip ./build/ios/ipa/cocktailr.ipa

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: cocktailr-ipa-zipped
path: ./build/ios/ipa/cocktailr.zip

distribute_ios:
name: Distribute iOS release
runs-on: macos-latest
needs: 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: 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

- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: cocktailr-ipa-zipped
path: ./build/ios/ipa/cocktailr.zip

- name: Unzip ipa file
run: unzip ./build/ios/ipa/cocktailr.zip -d ./build/ios/ipa

- name: Distribute release
run: bundle exec fastlane ios distribute_firebase
6 changes: 6 additions & 0 deletions APP_STORE_CONNECT_API_KEY.p8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----BEGIN PRIVATE KEY-----
MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgTKOGjUuJGMAIT2SY
3Auu0XK1u1z1EWwYLDZD3sf6PMegCgYIKoZIzj0DAQehRANCAASyT1gLu8uYkAdd
AR0C/uUBDCXD51XHrmdDRbs5IiSwzNXeLlU3ABd3nmPg5LSmEhbru8rCNU8+h4hY
X4OTRuAg
-----END PRIVATE KEY-----
76 changes: 75 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ platform :android do
lane :distribute_firebase do
Dir.chdir("..") do
android_artifact_path = File.expand_path("./build/app/outputs/flutter-apk/app-release.apk", Dir.pwd)
service_credentials_file = File.expand_path("./FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_KEY.json", Dir.pwd)
service_credentials_file = File.expand_path("./FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json", Dir.pwd)

firebase_app_distribution(
app: "1:30086613147:android:9d5c7c6b5005dcdddb1e3e",
Expand All @@ -43,6 +43,37 @@ end

### iOS ###
platform :ios do
### Certificates & Provisioning Profiles ###
desc "Run match command for the given type"
lane :match_for_type do |options|
app_store_connect_api_key_filepath = File.expand_path("./APP_STORE_CONNECT_API_KEY.p8", Dir.pwd)

app_store_connect_api_key = app_store_connect_api_key(
key_id: "W3A5H672YF",
issuer_id: "cbd3c437-ddc9-4d9c-a6e5-1618213abb22",
key_filepath: app_store_connect_api_key_filepath,
duration: 1200,
in_house: false,
)

match(
type: options[:type],
git_url: "git@github.com:BramDC3/cocktailr-app-match.git",
app_identifier: "com.crowncorp.cocktailr",
api_key: app_store_connect_api_key,
)
end

desc "Run match development"
lane :match_development do
match_for_type(type: "development")
end

desc "Run match adhoc"
lane :match_adhoc do
match_for_type(type: "adhoc")
end

### Build ###
desc "Build iOS debug (for simulator)"
lane :build_debug do
Expand All @@ -54,15 +85,58 @@ platform :ios do
desc "Build iOS release"
lane :build_release do
Dir.chdir("..") do
setup_ci

match_adhoc

sh("fvm flutter build ipa --release --export-options-plist ios/Runner/ExportOptions.plist")

# Current directory
puts "Current directory: #{Dir.pwd}"

# Contents of ipa folder
puts "Contents of ipa folder"
sh("ls -la ./build/ios/ipa")

ipa_path = File.expand_path("./build/ios/ipa/cocktailr.ipa", Dir.pwd)
# Check if ipa file exists
puts "Checking if ipa file exists"
if !File.file?(ipa_path)
puts "IPA file not found at path: #{ipa_path}"
end

# Check if it's a directory
puts "Checking if ipa file is a directory"
if File.directory?(ipa_path)
puts "IPA file is a directory at path: #{ipa_path}"
end
end
end

### Distribute ###
desc "Distribute to Firebase App Distribution"
lane :distribute_firebase do
Dir.chdir("..") do
# Current directory
puts "Current directory: #{Dir.pwd}"

# Contents of ipa folder
puts "Contents of ipa folder"
sh("ls -la ./build/ios/ipa")

ipa_path = File.expand_path("./build/ios/ipa/cocktailr.ipa", Dir.pwd)
# Check if ipa file exists
puts "Checking if ipa file exists"
if !File.file?(ipa_path)
puts "IPA file not found at path: #{ipa_path}"
end

# Check if it's a directory
puts "Checking if ipa file is a directory"
if File.directory?(ipa_path)
puts "IPA file is a directory at path: #{ipa_path}"
end

service_credentials_file = File.expand_path("./FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT.json", Dir.pwd)

firebase_app_distribution(
Expand Down
11 changes: 0 additions & 11 deletions fastlane/Matchfile

This file was deleted.

Loading

0 comments on commit a2b4cab

Please sign in to comment.