-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_and_package_android.bat
45 lines (32 loc) · 1.07 KB
/
build_and_package_android.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@echo off
setlocal EnableDelayedExpansion
:: Save the current directory
set "INITIAL_DIR=%CD%"
set "APP_NAME=mc_rcon_client"
:: Read version from pubspec.yaml
for /f "tokens=2" %%a in ('findstr "version: " pubspec.yaml') do set "VERSION=%%a"
if "!VERSION!" == "" (
echo Version not found in pubspec.yaml
goto end
)
echo Building !APP_NAME! version !VERSION! for Android
:: Run Flutter build for Android APK
call flutter build apk
:: Check if Flutter build was successful
if not !ERRORLEVEL! == 0 (
echo Flutter build failed
goto end
)
:: Define the APK path (modify as needed depending on your build flavor, e.g., release or debug)
set "APK_PATH=.\build\app\outputs\flutter-apk\app-release.apk"
:: Optionally, copy the APK to a designated directory (create if it does not exist)
set "OUTPUT_DIR=.\build\app"
copy "!APK_PATH!" "!OUTPUT_DIR!\!APP_NAME!-!VERSION!-android.apk"
if not !ERRORLEVEL! == 0 (
echo Failed to copy APK
goto end
)
echo APK for !APP_NAME!-!VERSION! is ready in !OUTPUT_DIR!
:end
:: Return to the initial directory
cd /d "%INITIAL_DIR%"