Skip to content
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

[PR] Adding deployment guide #343

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0b0b421
fix: Upgrading the `flutter-quill` dependencies and adding multidex s…
LuchoTurtle Oct 17, 2023
e1178fc
chore: Upgrading deps.
LuchoTurtle Oct 17, 2023
757455b
chore: Add pre-requisites in deployment documentation. #342
LuchoTurtle Oct 17, 2023
d779502
chore: Add google play instructions.
LuchoTurtle Oct 17, 2023
fd3dcd7
chore: Adding app signings.
LuchoTurtle Oct 17, 2023
66a1e1d
chore: Add new rest of sections in Google.
LuchoTurtle Oct 17, 2023
19bce03
chore: Beginning Apple section.
LuchoTurtle Oct 18, 2023
90a0803
fix: Fixing service_worker.js patch file.
LuchoTurtle Oct 18, 2023
a1ea765
chore: Temporarily checking if deploy works.
LuchoTurtle Oct 18, 2023
cf9e1f9
chore: Reverting last commit.
LuchoTurtle Oct 18, 2023
81e57d5
chore: Refactoring workflows. #344
LuchoTurtle Oct 18, 2023
a922485
Merge branch 'fix_ci#344' into deployment#342
LuchoTurtle Oct 18, 2023
73ff784
chore: Only running `deploy_web` after build succeeds.
LuchoTurtle Oct 18, 2023
cb079e6
chore: Starting out Android deploy.
LuchoTurtle Oct 18, 2023
a0200e4
chore: Creating bundle. #342
LuchoTurtle Oct 18, 2023
df19266
chore: Temporarily checking if android works. #342
LuchoTurtle Oct 18, 2023
ad96f9e
chore: Trying to fix creating keystore file. #342
LuchoTurtle Oct 18, 2023
02ed0eb
chore: Trying to fix.
LuchoTurtle Oct 18, 2023
85f041c
chore: Debugging info folder. #342
LuchoTurtle Oct 18, 2023
2baae5d
chore: Check key properties keystore file. #342
LuchoTurtle Oct 18, 2023
6d73625
chore: Checking the location of key.properties.
LuchoTurtle Oct 18, 2023
3694416
chore: Checking decoded android keystore location
LuchoTurtle Oct 18, 2023
cd41693
fix: Hopefully fixing the signing error. #342
LuchoTurtle Oct 18, 2023
dc8d75a
chore: Testing if deploying works on Android. #342
LuchoTurtle Oct 23, 2023
ea4c710
fix: Making worflow only work on `main`.
LuchoTurtle Oct 23, 2023
d6e6a16
chore: Add section on pre-requisites for Android release roll out. #342
LuchoTurtle Oct 23, 2023
6846822
chore: Testing if release actually works when bumping version and not…
LuchoTurtle Oct 23, 2023
4d56c82
chore: Change pubspec see if it works now.
LuchoTurtle Oct 23, 2023
3a26a09
Revert "chore: Testing if release actually works when bumping version…
LuchoTurtle Oct 23, 2023
a9533cd
chore: Add disclaimer about version code increasing.
LuchoTurtle Oct 23, 2023
b98ffa5
chore: Adding disclaimers and comments. #342
LuchoTurtle Oct 24, 2023
11f4552
feat: Finishing Android section and changing app name to unused "org.…
LuchoTurtle Oct 24, 2023
ee23878
chore: Adding iOS workflow file. #342
LuchoTurtle Oct 25, 2023
f79dbf5
feat: Adding deployment section for iOS to guide. #342
LuchoTurtle Oct 25, 2023
d499d03
chore: Adding pre-requisites section. #342
LuchoTurtle Oct 25, 2023
88e2686
chore: Adding section to registering app. #342
LuchoTurtle Oct 25, 2023
db141b8
chore: Add rest of section for Apple. #342
LuchoTurtle Oct 25, 2023
58cb2bb
chore: Fixing version and deps.
LuchoTurtle Oct 30, 2023
2ffb242
chore: Add comment.
LuchoTurtle Oct 30, 2023
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
78 changes: 78 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build & Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3

- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.5"
channel: "stable"

- name: Install dependencies
run: flutter pub get

- name: Flutter analyze
run: flutter analyze

# Your project will need to have tests in test/ and a dependency on
# package:test for this step to succeed.
- name: Run tests
run: flutter test --coverage

- uses: codecov/codecov-action@v3
with:
files: coverage/lcov.info
verbose: true


# Continuous Deployment to Fly.io
# https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
# flutter_deploy:
# name: Deploy Flutter app
# runs-on: ubuntu-latest
#
# needs: [build]
# # https://stackoverflow.com/questions/58139406/only-run-job-on-specific-branch-with-github-actions
# if: github.ref == 'refs/heads/main'
# env:
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# steps:
# - uses: actions/checkout@v3
#
# - name: Install Flutter
# uses: subosito/flutter-action@v2
# with:
# channel: 'stable'
#
# # Your project will need to have tests in test/ and a dependency on
# # package:test for this step to succeed. Note that Flutter projects will
# # want to change this to 'flutter test'.
# - name: Check build
# run: flutter analyze
#
# - name: Create release build
# # github.com/dwyl/app/issues/315#issuecomment-1443747737
# run: flutter build web --release --web-renderer html
#
#
# # See https://github.com/dwyl/app/issues/326.
# # This will fetch files concurrently needed for the app and not wait for `flutter.js` to load
# - name: Run post-build script to download files concurrently
# run: |
# chmod +x ./build_tools/patch_web.sh
# sh ./build_tools/patch_web.sh --ignore-whitespace
#
# - uses: superfly/[email protected]
# with:
# args: "deploy"
79 changes: 0 additions & 79 deletions .github/workflows/ci.yml

This file was deleted.

86 changes: 86 additions & 0 deletions .github/workflows/deploy_android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Deploy Android (Google Play Store)
on:
# Only trigger, when the "build" workflow succeeded (only works in the Master Branch)
workflow_run:
workflows: ["Build & Test"]
types:
- completed

# Only trigger, when pushing into the `main` branch
push:
branches: [main]

# DELETE THIS
#pull_request:
# branches: [ "main" ]

permissions:
contents: write

jobs:
build-and-deploy_android:
runs-on: ubuntu-latest

steps:
- name: ⬇️ Checkout code
uses: actions/checkout@v3

# Needed to base64 decode the upload keystore
- name: ⚙️ Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: "12.x"
cache: 'gradle'
id: java

# Needed to run Flutter-based commands
- name: 🐦 Install Flutter
uses: subosito/flutter-action@v2
with:
# If the flutter version that is used in development increases, it's recommended this one increases as well
flutter-version: "3.13.5"
channel: "stable"

- name: 📚 Install dependencies
run: flutter pub get

- name: 🔒 Retrieve base64 keystore and decode it to a file
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_FILE_BASE64 }}
run: echo $KEYSTORE_BASE64 | base64 --decode > "${{ github.workspace }}/decoded_android-keystore.jks"

# Creates keystore file.
# Needs to be the same as the one defined in `android/app/build.gradle`
- name: 📝🔐 Create key.properties file
env:
KEYSTORE_PROPERTIES_PATH: ${{ github.workspace }}/android/key.properties
run: |
touch $KEYSTORE_PROPERTIES_PATH
echo 'storeFile=${{ github.workspace }}/decoded_android-keystore.jks' > $KEYSTORE_PROPERTIES_PATH
echo 'keyAlias=${{ secrets.KEYSTORE_KEY_ALIAS }}' >> $KEYSTORE_PROPERTIES_PATH
echo 'storePassword=${{ secrets.KEYSTORE_PASSWORD }}' >> $KEYSTORE_PROPERTIES_PATH
echo 'keyPassword=${{ secrets.KEYSTORE_KEY_PASSWORD }}' >> $KEYSTORE_PROPERTIES_PATH


- name: 📦 Create Android appbundle release
run: |
flutter build appbundle \
--obfuscate \
--split-debug-info=${{ github.workspace }}/build/app/outputs/symbols

- name: 🚀 Upload Android Release to Play Store
uses: r0adkll/[email protected]
with:
# MUST match the package name defined in `android/app/build.gradle`
# Change all instances of of the package name to this one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. 🙏 ❤️

packageName: org.dwyl.app

# Can be 'alpha'/'beta'/'internal'/'production'.
# 'production' is relevant to the final stable version released to ALL clients
# 'internal' can be used for development versions and testing
# 'alpha' and 'beta' can be used for pre-release/staging purposes, with a smaller userbase
track: production

releaseFiles: ${{ github.workspace }}/build/app/outputs/bundle/release/app-release.aab
serviceAccountJsonPlainText: "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_KEY_JSON }}"
92 changes: 92 additions & 0 deletions .github/workflows/deploy_ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Deploy iOS (Apple App Store)
on:
# Only trigger, when the "build" workflow succeeded (only works in the Master Branch)
workflow_run:
workflows: ["Build & Test"]
types:
- completed

# Only trigger, when pushing into the `main` branch
push:
branches: [main]

# DELETE THIS
#pull_request:
# branches: [ "main" ]

permissions:
contents: write

jobs:
build-and-deploy_ios:
runs-on: macos-latest

steps:

- name: ⬇️ Checkout repository
uses: actions/checkout@v3

- name: 🔐 Install Apple certificate and provisioning profile
env:
P12_DISTRIBUTION_CERTIFICATE_BASE64: "${{ secrets.IOS_P12_DISTRIBUTION_CERTIFICATE_BASE64 }}"
P12_DISTRIBUTION_CERTIFICATE_PASSWORD: "${{ secrets.IOS_P12_DISTRIBUTION_CERTIFICATE_PASSWORD }}"
DISTRIBUTION_PROVISIONING_PROFILE_BASE64: "${{ secrets.IOS_DISTRIBUTION_PROVISIONING_PROFILE_BASE64 }}"
KEYCHAIN_PASSWORD: "${{ secrets.IOS_RUNNER_LOCAL_KEYCHAIN_PASSWORD }}"
EXPORT_OPTIONS_BASE64: "${{ secrets.IOS_EXPORT_OPTIONS_BASE64 }}"
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PROVISIONING_PROFILE_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
EXPORT_OPTIONS_PATH="${{ github.workspace }}/app/ios/Runner/ExportOptions.plist"

# import certificate, provisioning profile and export options from secrets
echo -n "$P12_DISTRIBUTION_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$DISTRIBUTION_PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PROVISIONING_PROFILE_PATH
echo -n "$EXPORT_OPTIONS_BASE64" | base64 --decode -o $EXPORT_OPTIONS_PATH

# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH

# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_DISTRIBUTION_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH

# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PROVISIONING_PROFILE_PATH ~/Library/MobileDevice/Provisioning\ Profiles


# Needed to run Flutter-based commands
- name: 🐦 Install Flutter
uses: subosito/flutter-action@v2
with:
# If the flutter version that is used in development increases, it's recommended this one increases as well
flutter-version: "3.13.5"
channel: "stable"
id: flutter

# Setting up Melos, which will
#- name: ⚙️ Setup Melos
# uses: bluefireteam/melos-action@v2

- name: 📚 Install dependencies
run: flutter pub get

- name: 🍏📦 Create iOS appbundle release
run: |
flutter build ipa \
--release \
--export-options-plist=ios/Runner/ExportOptions.plist
--obfuscate \
--split-debug-info=${{ github.workspace }}/build/app/outputs/symbols

- name: 🍏🚀 Deploy to App Store (Testflight)
uses: apple-actions/upload-testflight-build@v1
with:
app-path: ${{ github.workspace }}/app/build/ios/ipa/flutter_ci_cd_demo.ipa
issuer-id: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
api-key-id: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}
api-private-key: ${{ secrets.APP_STORE_CONNECT_API_PRIVATE_KEY }}
21 changes: 15 additions & 6 deletions .github/workflows/deploy.yml → .github/workflows/deploy_web.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
name: Deploy to Github Pages
name: Deploy Web (GitHub Pages)
on:
# Only trigger, when the "build" workflow succeeded (only works in the Master Branch)
workflow_run:
workflows: ["Build & Test"]
types:
- completed

# Only trigger, when pushing into the `main` branch
push:
branches: [ main ]
branches: [main]

permissions:
contents: write

jobs:
build-and-deploy:
build-and-deploy_web:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: "3.13.5"
channel: "stable"

- name: Install dependencies
run: flutter pub get

# See stackoverflow.com/questions/74164386/flutter-web-shows-blank-page-on-github-deployment
- name: Install and Build
- name: Install and Build
run: flutter build web --release --web-renderer html

- name: Deploy to Github Pages
Expand Down
Loading