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

refactor: Remove language menu #476

Merged
merged 15 commits into from
Sep 5, 2024
Merged
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
50 changes: 21 additions & 29 deletions .github/workflows/app-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy app
on:
push:
branches:
- main
- test
workflow_dispatch:
inputs:
deploy_target:
Expand Down Expand Up @@ -34,6 +34,16 @@ jobs:
with:
fetch-depth: 1

- name: Check deploy target and branch
run: |
if [[ "${{ github.ref }}" != "refs/heads/main" &&
( "${{ inputs.deploy_target }}" == "store" ||
"${{ inputs.deploy_target }}" == "ios_store" ||
"${{ inputs.deploy_target }}" == "android_store" ) ]]; then
echo "🚫 Error: Deployment to store, ios_store, or android_store is only allowed from the 'main' branch."
exit 1
fi

- name: Set output for flutter_version
id: set_output
run: |
Expand Down Expand Up @@ -133,25 +143,16 @@ jobs:
- name: Generate dart code
run: melos codegen --no-select

# Read Sentry DSN
- name: Read Sentry DSN
id: read_sentry_dsn
run: |
if [ -f ./secrets/sentry-dsn.txt ]; then
SENTRY_DSN=$(cat ./secrets/sentry-dsn.txt)
echo "SENTRY_DSN=$SENTRY_DSN" >> $GITHUB_ENV
echo "::add-mask::$SENTRY_DSN"
fi

- name: Display Build Number
run:
echo "Number is = ${{ needs.setup.outputs.build_number }}"

- name: Build and deploy
run: |
bash scripts/build.sh ${{ env.ios_target }} ${{ needs.setup.outputs.build_number }}
env:
SENTRY_DSN: ${{ env.SENTRY_DSN }}
bash scripts/build.sh \
--deploy-target ${{ env.ios_target }} \
--build-number ${{ needs.setup.outputs.build_number }} \
--upload true

- name: Clean Xcode Derived Data
run: |
Expand All @@ -175,17 +176,17 @@ jobs:
# Android deploy
android-deploy:
needs: setup
runs-on: ubuntu-latest

if: ${{ inputs.deploy_target == 'fad' || inputs.deploy_target == 'store' || inputs.deploy_target == 'android_fad' || inputs.deploy_target == 'android_store' }}

runs-on: ubuntu-latest
env:
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}

steps:
- name: Reinstall existing fastlane plugin
run: |
run: |
sudo gem uninstall fastlane-plugin-firebase_app_distribution
gem install fastlane-plugin-firebase_app_distribution --user-install

Expand Down Expand Up @@ -231,25 +232,16 @@ jobs:
- name: Generate dart code
run: melos codegen --no-select

# Read Sentry DSN
- name: Read Sentry DSN
id: read_sentry_dsn
run: |
if [ -f ./secrets/sentry-dsn.txt ]; then
SENTRY_DSN=$(cat ./secrets/sentry-dsn.txt)
echo "SENTRY_DSN=$SENTRY_DSN" >> $GITHUB_ENV
echo "::add-mask::$SENTRY_DSN"
fi

- name: Display Build Number
run:
echo "Number is = ${{ needs.setup.outputs.build_number }}"

- name: Build and deploy
run: |
bash scripts/build.sh ${{ env.android_target }} ${{ needs.setup.outputs.build_number }}
env:
SENTRY_DSN: ${{ env.SENTRY_DSN }}
bash scripts/build.sh \
--deploy-target ${{ env.android_target }} \
--build-number ${{ needs.setup.outputs.build_number }} \
--upload true

- name: Remove Flutter
run: |
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/branch-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check branch

on:
pull_request:
branches:
- main

jobs:
prevent-dev-merge:
runs-on: ubuntu-latest
steps:
- name: Check source branch
run: |
if [[ "${{ github.event.pull_request.head.ref }}" == "dev" ]]; then
echo "Merging from 'dev' to 'main' is not allowed."
exit 1
else
echo "Merge allowed."
fi
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,45 @@ All deployment scripts are gathering changelog from git commits and adding it to

### Deploy using GitHub Actions

We already have a workflow for deploying main app to Firebase App Distribution, TestFlight and Google Play closed testing. It's called `app=deploy` and it's triggered by pushing to the main branch or manually from any branch. You can choose the desired deployment when triggering the workflow manually. It will deploy to FAD when its triggered by pushing to the main branch.
We already have a workflow for deploying main app to Firebase App Distribution, TestFlight and Google Play. It's called `Deploy app`.

Deployment to fab is triggered when the `test` branch is updated, or when manually launched from any branch except main.
Deployment to store is triggered when manually launched from the `main` branch.

Deployment to FAD is triggered when the `dev` branch is updated.

Manually running the deploy `melos run deploy_fad` from any branch **except** `main`.
Running `melos run deploy_ios` deploys iOS to FAD.
Running `melos run deploy_android` deploys Android to FAD.

Deployment to store is triggered when manually launched from the `main` branch.

#### Available options for deploying in workflow:

- **ios_fad** - launches iOS deploy to FAD.
- **ios_store** - launches iOS deploy to Test Flight.
- **android_fad** - launches Android deploy to FAD.
- **android_store** - launches Android deploy to Google Play.
- **fad** - launches iOS and Android deploy to FAD.
- **store** - launches iOS and Android deploy to Test Flight and Google Play.

We also have a workflow for deploying storybook to GitHub Pages. It's called `storybook-gh-pages-deploy` and it's triggered by pushing to the main branch or manually from any branch.

### Deploy from local machine

For deployment from a local machine, melos is used.

- **build_android_store** - build Android `aab` from any branch
- **deploy_fad_ios** - build and send iOS `ipa` from any branch
- **deploy_fad_android** - build and send Android `apk` from any branch
- **deploy_fad** - build and send Android `apk` and iOS `ipa` from any branch
- **deploy_store** - build and send Android `aab` and iOS `ipa` from the main branch

The `melos deploy_store*` commands only work from the `main` branch, so as not to accidentally upload unnecessary code to production.

The `melos build_*` commands work from any branch - in case of manual build.
Unlike `deploy_store*` commands, randomly running `build_*` will only build aab and/or ipa locally and will not push anything extra or untested to the store.

```sh
# To deploy to Firebase App Distribution just run the following command:
$ melos build:deploy_fad
Expand Down
30 changes: 16 additions & 14 deletions lib/feature/profile/view/profile_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class ProfileView extends StatelessWidget {
backgroundColor: theme.colors.backgroundAlpha,
iconColor: theme.colors.content0,
),
// TODO(knightforce): temp
// _profileTile(
// leadingIcon: Assets.images.currency.path,
// title: LocaleKeys.currencyWord.tr(),
Expand All @@ -90,20 +91,21 @@ class ProfileView extends StatelessWidget {
// // ignore: no-empty-block
// onPressed: () {},
// ),
_profileTile(
leadingIcon: Assets.images.planetInner.path,
title: LocaleKeys.languageWord.tr(),
trailing: const Icon(
LucideIcons.chevronRight,
size: DimensSizeV2.d20,
),
// ignore: no-empty-block
onPressed: () => showLocalizationSheet(
context: context,
),
backgroundColor: theme.colors.backgroundAlpha,
iconColor: theme.colors.content0,
),
// TODO(knightforce): temp
// _profileTile(
// leadingIcon: Assets.images.planetInner.path,
// title: LocaleKeys.languageWord.tr(),
// trailing: const Icon(
// LucideIcons.chevronRight,
// size: DimensSizeV2.d20,
// ),
// // ignore: no-empty-block
// onPressed: () => showLocalizationSheet(
// context: context,
// ),
// backgroundColor: theme.colors.backgroundAlpha,
// iconColor: theme.colors.content0,
// ),
if (isBiometryAvailable)
StreamBuilder<bool>(
stream: service.enabledStream,
Expand Down
54 changes: 54 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,60 @@ scripts:
description: Registering new devices already added through devportal
run: bash scripts/ios-match-new-devices.sh

build_android_store:
description: Build android store
run: |
bash scripts/build.sh \
--deploy-target android_store \
--build-number auto \
--upload false

deploy_fad_ios:
description: Deploy iOS app to fad
run: |
bash scripts/build.sh \
--deploy-target ios_fad \
--build-number auto \
--upload true

deploy_fad_android:
description: Deploy Android app to fad
run: |
bash scripts/build.sh \
--deploy-target android_fad \
--build-number auto \
--upload true

deploy_fad:
description: Deploy app to fad
run: |
BUILD_NUMBER=$(bash scripts/get-build-number.sh)

bash scripts/build.sh \
--deploy-target ios_fad \
--build-number $BUILD_NUMBER \
--upload true

bash scripts/build.sh \
--deploy-target android_fad \
--build-number $BUILD_NUMBER \
--upload true

deploy_store:
description: Deploy app to store
run: |
BUILD_NUMBER=$(bash scripts/get-build-number.sh)

bash scripts/build.sh \
--deploy-target ios_store \
--build-number $BUILD_NUMBER \
--upload true

bash scripts/build.sh \
--deploy-target android_store \
--build-number $BUILD_NUMBER \
--upload true

command:
clean:
hooks:
Expand Down
66 changes: 55 additions & 11 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,60 @@
set -e
set -o pipefail

deploy_target=""
build_number=""
upload="false"

while [[ "$#" -gt 0 ]]; do
case $1 in
--deploy-target) deploy_target="$2"; shift ;;
--build-number) build_number="$2"; shift ;;
--upload) upload="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done

function build() {
source "scripts/build-binary/$1"
}

function upload() {
if [[ "$upload" == "true" ]]; then
source "scripts/deploy/$1"
fi
}

CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [[ "$upload" == "true" && "$CURRENT_BRANCH" != "main" && ("$deploy_target" == "ios_store" || "$deploy_target" == "android_store") ]]; then
echo "🚫 Error: Deployment to the store is only allowed from the 'main' branch."
exit 1
fi

if [ -f ./secrets/sentry-dsn.txt ]; then
SENTRY_DSN=$(cat ./secrets/sentry-dsn.txt)
export SENTRY_DSN
echo "SENTRY_DSN is successfully read"
else
echo "Error: Sentry DSN file not found"
exit 1
fi

if [ -z "$SENTRY_DSN" ]; then
echo "Error: env SENTRY_DSN is empty"
exit 1
fi

export SENTRY_DSN

deploy_target="$1"
build_number="$2"
if [[ "$build_number" == "auto" ]]; then
echo "Build number is 'auto', generating one automatically..."
build_number=$(bash scripts/get-build-number.sh)
echo "Generated Build Number: $build_number"
fi

if [ -z "$build_number" ]; then
if [[ -z "$build_number" || "$build_number" == "auto" ]]; then
echo "Error: Build number is not specified."
exit 1
fi
Expand All @@ -23,20 +67,20 @@ source scripts/get-changelog.sh

case "$deploy_target" in
"ios_fad")
source scripts/build-binary/fad-ipa.sh
source scripts/deploy/fad-ipa.sh
build "fad-ipa.sh"
upload "fad-ipa.sh"
;;
"ios_store")
source scripts/build-binary/store-ipa.sh
source scripts/deploy/store-ipa.sh
build "store-ipa.sh"
upload "store-ipa.sh"
;;
"android_fad")
source scripts/build-binary/fad-apk.sh
source scripts/deploy/fad-apk.sh
build "fad-apk.sh"
upload "fad-apk.sh"
;;
"android_store")
source scripts/build-binary/store-aab.sh
source scripts/deploy/store-aab.sh
build "store-aab.sh"
upload "store-aab.sh"
;;
*)
echo "Unknown deploy target: $deploy_target"
Expand Down
Loading