Skip to content

Commit 7edd480

Browse files
committed
изменены переменные окружения, скрипты, инструкция упрощена
1 parent f51a0ac commit 7edd480

File tree

20 files changed

+122
-51
lines changed

20 files changed

+122
-51
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ENV=prod
1+
ENV=prod # prod, dev, test
22
CONTACT_EMAIL=[email protected]
33
CONTACT_TG=username

.github/workflows/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
flutter-version-file: pubspec.yaml
4444

4545
- name: Configure .env
46-
run: echo "$ENV_B64" | base64 --decode > .env
46+
run: echo "$ENV_B64" | base64 --decode > .env.prod
4747
env:
4848
ENV_B64: ${{ secrets.ENV_B64 }}
4949

@@ -67,7 +67,7 @@ jobs:
6767
flutter pub run build_runner build
6868
6969
- name: Build APKs
70-
run: flutter build apk --release --split-per-abi --dart-define-from-file .env
70+
run: flutter build apk --release --split-per-abi --dart-define-from-file .env.prod
7171

7272
- name: Archive APK
7373
uses: actions/upload-artifact@v4
@@ -80,4 +80,4 @@ jobs:
8080
run: |
8181
rm -f android/app/keystore.jks
8282
rm -f android/key.properties
83-
rm -f .env
83+
rm -f .env.prod

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
flutter-version-file: pubspec.yaml
5858

5959
- name: Configure .env
60-
run: echo "$ENV_B64" | base64 --decode > .env
60+
run: echo "$ENV_B64" | base64 --decode > .env.prod
6161
env:
6262
ENV_B64: ${{ secrets.ENV_B64 }}
6363

@@ -81,7 +81,7 @@ jobs:
8181
flutter pub run build_runner build
8282
8383
- name: Build APKs
84-
run: flutter build apk --release --split-per-abi --dart-define-from-file .env
84+
run: flutter build apk --release --split-per-abi --dart-define-from-file .env.prod
8585

8686
- name: Move and rename APKs
8787
run: |
@@ -124,4 +124,4 @@ jobs:
124124
run: |
125125
rm -f android/app/keystore.jks
126126
rm -f android/key.properties
127-
rm -f .env
127+
rm -f .env.prod

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ app.*.map.json
6262
release
6363

6464
# Env files
65-
.env*.local
66-
.env
65+
.env*
66+
!.env.example

.vscode/launch.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"type": "dart",
1111
"args": [
1212
"--dart-define-from-file",
13-
".env"
13+
".env.prod"
1414
]
1515
},
1616
{
@@ -20,7 +20,7 @@
2020
"flutterMode": "profile",
2121
"args": [
2222
"--dart-define-from-file",
23-
".env"
23+
".env.prod"
2424
]
2525
},
2626
{
@@ -30,7 +30,7 @@
3030
"flutterMode": "release",
3131
"args": [
3232
"--dart-define-from-file",
33-
".env"
33+
".env.prod"
3434
]
3535
},
3636
{
@@ -43,7 +43,7 @@
4343
"--web-port",
4444
"63080",
4545
"--dart-define-from-file",
46-
".env",
46+
".env.prod",
4747
"--web-browser-flag",
4848
"--disable-web-security",
4949
]

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"--release",
1111
"--split-per-abi",
1212
"--dart-define-from-file",
13-
".env"
13+
".env.prod"
1414
],
1515
"group": "build",
1616
"problemMatcher": [],

INSTRUCTIONS.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
## Pre-build
1+
## Конфигурация
22

3-
```
4-
flutter pub get
5-
```
3+
1. Создать файл `.env.prod` в корне проекта. Пример можно посмотреть в `.env.example`
64

7-
```
8-
if (Platform.isIOS) {
9-
cd ios && pod install && cd ..
10-
}
11-
```
5+
## Сборка
126

7+
apk
138
```
14-
flutter pub run build_runner build --delete-conflicting-outputs
9+
sh scripts/build.sh env=prod --no-runner
1510
```
1611

17-
## Build
18-
19-
apk
2012
```
21-
flutter build apk --release --dart-define-from-file .env --split-per-abi
13+
--env - определяет окружение для сборки
14+
--no-runner - пропустить запуск build_runner
2215
```
2316

24-
## Dev
25-
###### Testing App Links
17+
###### Тестирование deeplink через терминал
2618

2719
Android
2820
```

android/app/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ plugins {
44
id "dev.flutter.flutter-gradle-plugin"
55
}
66

7+
// Dart env variables
8+
def dartEnvironmentVariables = [];
9+
if (project.hasProperty('dart-defines')) {
10+
dartEnvironmentVariables = project.property('dart-defines')
11+
.split(',')
12+
.collectEntries { entry ->
13+
def pair = new String(entry.decodeBase64(), 'UTF-8').split('=')
14+
[(pair.first()): pair.last()]
15+
}
16+
}
17+
18+
def appName = dartEnvironmentVariables.APP_NAME ?: 'Flabr'
19+
def appIdSuffix = dartEnvironmentVariables.ENV.toString().equalsIgnoreCase('dev') ? '.dev' : ''
20+
721
// Keystore properties
822
def keystoreProperties = new Properties()
923
def keystorePropertiesFile = rootProject.file('key.properties')
@@ -51,10 +65,12 @@ android {
5165

5266
defaultConfig {
5367
applicationId = "ru.iska9der.flabr"
68+
applicationIdSuffix = appIdSuffix
5469
minSdk = Math.max(flutter.minSdkVersion, 21)
5570
targetSdk = 35
5671
versionCode = flutterVersionCode.toInteger()
5772
versionName = flutterVersionName
73+
resValue "string", "app_name", appName
5874
}
5975

6076
splits {

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<uses-permission android:name="android.permission.INTERNET" />
44
<!-- Application -->
55
<application
6-
android:label="flabr"
6+
android:label="@string/app_name"
77
android:name="${applicationName}"
88
android:icon="@mipmap/ic_launcher"
99
android:allowBackup="false"

ios/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Flutter/App.framework
1919
Flutter/Flutter.framework
2020
Flutter/Flutter.podspec
2121
Flutter/Generated.xcconfig
22+
Flutter/Environment.xcconfig
2223
Flutter/ephemeral/
2324
Flutter/app.flx
2425
Flutter/app.zip

0 commit comments

Comments
 (0)