-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrelease-android.bat
More file actions
139 lines (122 loc) · 2.99 KB
/
release-android.bat
File metadata and controls
139 lines (122 loc) · 2.99 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@echo off
setlocal EnableExtensions EnableDelayedExpansion
cd /d "%~dp0"
set "VERSION_OVERRIDE="
set "DRAFT_FLAG="
:parse_args
if "%~1"=="" goto args_done
if /i "%~1"=="--draft" (
set "DRAFT_FLAG=--draft"
shift
goto parse_args
)
set "VERSION_OVERRIDE=%~1"
shift
goto parse_args
:args_done
echo ========================================
echo FlashLog - Build ^& GitHub Release
echo ========================================
echo.
where gh >nul 2>&1
if errorlevel 1 (
echo ERROR: GitHub CLI ^(gh^) not found.
echo Install: https://cli.github.com/
exit /b 1
)
gh auth status >nul 2>&1
if errorlevel 1 (
echo ERROR: GitHub CLI not logged in. Run: gh auth login
exit /b 1
)
where node >nul 2>&1
if errorlevel 1 (
echo ERROR: Node.js not found.
exit /b 1
)
if defined VERSION_OVERRIDE (
set "PKG_VERSION=%VERSION_OVERRIDE%"
set "PKG_VERSION=!PKG_VERSION:v=!"
) else (
for /f "delims=" %%V in ('node -pe "JSON.parse(require('fs').readFileSync('package.json','utf8')).version"') do set "PKG_VERSION=%%V"
)
if not defined PKG_VERSION (
echo ERROR: Could not read version from package.json
exit /b 1
)
set "TAG=v%PKG_VERSION%"
set "RELEASE_DIR=release"
set "APK_NAME=FlashLog-%TAG%-debug.apk"
set "APK_OUT=%RELEASE_DIR%\%APK_NAME%"
echo Version tag: %TAG%
if defined DRAFT_FLAG echo Mode: draft release
echo.
where git >nul 2>&1
if not errorlevel 1 (
git diff --quiet 2>nul
if errorlevel 1 (
echo WARNING: Working tree has uncommitted changes.
echo Release tag will point at the latest commit, not local edits.
echo.
)
)
echo [1/3] Building debug APK...
call "%~dp0build-android-debug.bat"
if errorlevel 1 (
echo.
echo ERROR: APK build failed.
exit /b 1
)
set "APK_SRC=%~dp0android\app\build\outputs\apk\debug\app-debug.apk"
if not exist "%APK_SRC%" (
echo ERROR: APK not found: %APK_SRC%
exit /b 1
)
echo.
echo [2/3] Preparing release asset...
if not exist "%RELEASE_DIR%" mkdir "%RELEASE_DIR%"
copy /y "%APK_SRC%" "%APK_OUT%" >nul
if errorlevel 1 (
echo ERROR: Failed to copy APK to %APK_OUT%
exit /b 1
)
echo %APK_OUT%
echo.
echo [3/3] Publishing GitHub Release...
gh release view "%TAG%" >nul 2>&1
if errorlevel 1 (
echo Creating release %TAG% ...
gh release create "%TAG%" "%APK_OUT%" ^
--title "FlashLog %TAG%" ^
--notes-file "%~dp0scripts\release-notes-template.md" ^
%DRAFT_FLAG%
if errorlevel 1 (
echo.
echo ERROR: gh release create failed.
exit /b 1
)
) else (
echo Release %TAG% exists, uploading APK ^(--clobber^)...
gh release upload "%TAG%" "%APK_OUT%" --clobber
if errorlevel 1 (
echo.
echo ERROR: gh release upload failed.
exit /b 1
)
)
echo.
echo ========================================
echo Release published
echo ========================================
echo.
for /f "delims=" %%U in ('gh release view "%TAG%" --json url -q .url 2^>nul') do set "RELEASE_URL=%%U"
if defined RELEASE_URL (
echo URL: !RELEASE_URL!
) else (
gh release view "%TAG%"
)
echo.
echo Asset: %APK_NAME%
echo.
endlocal
exit /b 0