forked from bkacjios/m-overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.bat
123 lines (91 loc) · 3.41 KB
/
release.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
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
@echo OFF
REM Release name
SET NAME=m-overlay
REM Architecture
REM auto, x64, x86
SET BIT=x64
SET INNO_SETUP_DIR="C:\Program Files (x86)\Inno Setup 6"
SET LOVE_64_DIR="C:\Program Files\LOVE"
SET LOVE_32_DIR="C:\Program Files (x86)\LOVE"
IF "%BIT%"=="x64" (
if exist %LOVE_64_DIR% SET LOVE_DIR=%LOVE_64_DIR%
)
IF "%BIT%"=="x86" (
if exist %LOVE_32_DIR% SET LOVE_DIR=%LOVE_32_DIR%
)
if not exist %LOVE_DIR% goto :exit
where /q 7z || ECHO Could not find 7Zip, please download and install: https://www.7-zip.org/download.html and add it to PATH && goto :exit
SET INSTALLER_DIR=.\installer
SET BUILD_DIR=.\build
SET BUILD_OUTPUT_DIR=%BUILD_DIR%\%BIT%
SET SOURCE_DIR=.\source
SET LAUNCHER_DIR=.\launcher
SET RELEASES_DIR=.\releases
SET TOOLS_DIR=.\tools
REM Clean build directory
echo Cleaning build directory...
if exist %BUILD_DIR% rmdir /S /Q %BUILD_DIR%
mkdir %BUILD_DIR%
mkdir %BUILD_OUTPUT_DIR%
SET BRANCH=dirty
SET COMMIT=1
SET VERSION=v0.0.0
REM Get GIT commit number
FOR /F "tokens=* USEBACKQ" %%F IN (`git -C %SOURCE_DIR% rev-list --count --first-parent HEAD`) DO (
SET COMMIT=%%F
)
REM Get latest tag
FOR /F "tokens=* USEBACKQ" %%F IN (`git -C %SOURCE_DIR% describe --tags`) DO (
echo %%F
SET VERSION=%%F
)
IF "%VERSION:~0,1%"=="v" (
echo Stripping 'v' from VERSION
SET VERSION=%VERSION:~1%
)
if not exist %RELEASES_DIR%\%VERSION% mkdir %RELEASES_DIR%\%VERSION%
echo %VERSION% > %SOURCE_DIR%\version.txt
REM Get GIT branch
FOR /F "tokens=* USEBACKQ" %%F IN (`git -C %SOURCE_DIR% rev-parse --abbrev-ref HEAD`) DO (
SET BRANCH=%%F
)
SET PATH=%PATH%;%INNO_SETUP_DIR%;%TOOLS_DIR%
SET EXE_NAME=%NAME%-%BIT%.exe
SET EXE_PATH=%BUILD_OUTPUT_DIR%\%EXE_NAME%
SET APPLICATION_LOVE=%BUILD_DIR%\application.love
SET LAUNCHER_LOVE=%BUILD_DIR%\%NAME%-%BIT%-installer.love
echo Zipping files in %SOURCE_DIR% into %APPLICATION_LOVE%
if exist %APPLICATION_LOVE% del %APPLICATION_LOVE%
7z a -tzip -mx=9 -xr!*.git -xr!*.dll %APPLICATION_LOVE% "%SOURCE_DIR%\*"
7z a -tzip -mx=9 -xr!*.git -xr!*.dll %LAUNCHER_LOVE% "%LAUNCHER_DIR%\*"
copy %APPLICATION_LOVE% %RELEASES_DIR%\%VERSION% /y
copy %LAUNCHER_LOVE% %RELEASES_DIR%\%VERSION% /y
echo Copying LOVE2D binaries and license to %BUILD_OUTPUT_DIR%
copy %LOVE_DIR%\license.txt %BUILD_OUTPUT_DIR%
xcopy /d %LOVE_DIR%\*.dll %BUILD_OUTPUT_DIR% /y
xcopy /d %SOURCE_DIR%\*.dll %BUILD_OUTPUT_DIR% /y
del %BUILD_OUTPUT_DIR%\sqlite3.dll
echo Copying love.exe to build directory
copy /b %LOVE_DIR%\love.exe %BUILD_DIR%
echo Customizing love.exe
rcedit-x64 "%BUILD_DIR%\love.exe" --set-icon "%INSTALLER_DIR%\icon.ico"
rcedit-x64 "%BUILD_DIR%\love.exe" --set-file-version "%VERSION%"
rcedit-x64 "%BUILD_DIR%\love.exe" --set-version-string "FileDescription" "M'Overlay"
rcedit-x64 "%BUILD_DIR%\love.exe" --set-version-string "InternalName" "%NAME%-%BIT%"
rcedit-x64 "%BUILD_DIR%\love.exe" --set-version-string "OriginalFilename" "%EXE_NAME%"
REM Merging love.exe with application.love
echo Merging love.exe + %APPLICATION_LOVE% into %EXE_PATH%
if exist %EXE_PATH% del %EXE_PATH%
copy /b "%BUILD_DIR%\love.exe"+%APPLICATION_LOVE% %EXE_PATH%
SET PORTABLE_ZIP="%RELEASES_DIR%\%VERSION%\%NAME%-%BIT%-portable.zip"
REM Remove old zip if it exists
if exist %PORTABLE_ZIP% del %PORTABLE_ZIP%
REM Create a release zip
7z a -tzip -mx=9 %PORTABLE_ZIP% "%BUILD_OUTPUT_DIR%\*"
if exist %INNO_SETUP_DIR% (
echo Building installer
iscc release.iss
move "%RELEASES_DIR%\m-overlay-x64-installer.exe" "%RELEASES_DIR%\%VERSION%"
)
:exit
@PAUSE