-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.bat
114 lines (83 loc) · 3 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
@echo OFF
REM Release name
SET NAME=m-target
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 RELEASES_DIR=.\releases
SET TOOLS_DIR=.\tools
if not exist %BUILD_DIR% mkdir %BUILD_DIR%
if not exist %RELEASES_DIR% mkdir %RELEASES_DIR%
if not exist %BUILD_OUTPUT_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%
)
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 ZIP="%RELEASES_DIR%\%VERSION%\%NAME%-%BIT%.love"
REM SET ZIP=%BUILD_DIR%\%NAME%.love
echo Zipping files in %SOURCE_DIR% into %ZIP%
if exist %ZIP% del %ZIP%
REM timeout /t 3 /nobreak
7z a -tzip -mx=9 -xr!*.git -xr!*.dll %ZIP% "%SOURCE_DIR%\*"
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
echo Copying love.exe %BUILD_DIR%
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-version-string "FileDescription" "M'Target"
rcedit-x64 "%BUILD_DIR%\love.exe" --set-file-version "%VERSION%"
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 We have to merge AFTER rcedit, since rcedit destroys the merged data
echo Merging love.exe + %ZIP% into %EXE_PATH%
copy /b "%BUILD_DIR%\love.exe"+%ZIP% %EXE_PATH%
SET ZIP="%RELEASES_DIR%\%VERSION%\%NAME%-%BIT%-portable.zip"
REM Remove old zip if it exists
if exist %ZIP% del %ZIP%
REM Create a release zip
7z a -tzip -mx=9 %ZIP% "%BUILD_OUTPUT_DIR%\*"
if exist %INNO_SETUP_DIR% (
echo Building installer
iscc release.iss
move "%RELEASES_DIR%\m-target-x64-installer.exe" "%RELEASES_DIR%\%VERSION%"
)
:exit
@PAUSE