-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
107 lines (81 loc) · 2.59 KB
/
build.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
@echo off
setlocal
echo Compiling...
rmdir /S /Q build 2>nul
timeout /t 2 /nobreak 1>nul
mkdir dist 2>nul
mkdir build
set "AHK=C:\Program Files\AutoHotkey"
set "BASE=AutoHotkeyU64.exe"
copy "%AHK%\Compiler\Ahk2Exe.exe" .
copy "%AHK%\%BASE%" .
set "PROJECT=neo-mousekeys"
Ahk2Exe.exe /base %BASE% /in "%PROJECT%.ahk" /out "build\%PROJECT%.exe"
if %errorlevel% equ 0 (
echo Compilation successful.
) else (
echo Compilation failed.
)
echo Copying additional files...
echo:
echo Copying options.ini...
xcopy /Q options.ini build
del "Ahk2Exe.exe"
del "%BASE%"
echo Zipping...
echo:
set "INPUT=build"
set /p VERSION=<version
set "OUTPUT=%PROJECT%-v%VERSION%.zip"
@REM powershell -command "Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::CreateFromDirectory('%INPUT%', '%OUTPUT%')"
@REM powershell -Command "$compress = @{ Path = '%INPUT%'; CompressionLevel = 'NoCompression'; DestinationPath = '%OUTPUT%' }; Compress-Archive @compress"
"C:\Program Files\7-Zip\7z.exe" a -tzip -mx0 %OUTPUT% ".\%INPUT%\*"
for /f %%a in ('powershell -command "(certutil -hashfile %OUTPUT% MD5)[1]"') do set "MD5=%%a"
for /f %%a in ('powershell -command "(certutil -hashfile %OUTPUT% SHA1)[1]"') do set "SHA1=%%a"
for /f %%a in ('powershell -command "(certutil -hashfile %OUTPUT% SHA256)[1]"') do set "SHA256=%%a"
echo:
move %OUTPUT% dist
echo Done compiling.
echo:
set "HASHES=Hashes (%OUTPUT%): & echo MD5: %MD5% & echo SHA1: %SHA1% & echo SHA256: %SHA256%"
setlocal enabledelayedexpansion
set /p choice="Upload 'dist/%OUTPUT%' to VirusTotal? (y/n): "
if /i "!choice!"=="y" (
if defined VT_API_KEY (
curl --request POST ^
--url https://www.virustotal.com/api/v3/files ^
--header "accept: application/json" ^
--header "content-type: multipart/form-data" ^
--header "x-apikey: %VT_API_KEY%" ^
--form "file=@dist/%OUTPUT%"
echo:
echo:
echo File uploaded to VirusTotal.
set "HASHES=%HASHES% & echo VirusTotal: https://www.virustotal.com/gui/file/%SHA256%"
echo:
) else (
echo Error: VT_API_KEY is not set in PATH.
)
) else (
echo No files were uploaded to VirusTotal.
)
echo:
echo %HASHES%
cmd /c "echo %HASHES%" | clip
echo:
set /p choice="Delete ./build? (y/n): "
if /i "!choice!"=="y" (
rmdir /S /Q build 2>nul
)
echo:
set /p choice="Open explorer and GitHub? (y/n): "
set "BROWSER=C:\Progra~1\Google\Chrome\Application\chrome.exe"
set "URL=https://github.com/vieuxtemps/%PROJECT%/releases/new"
if /i "!choice!"=="y" (
explorer.exe dist
timeout /t 1 /nobreak 1>nul
start "" %BROWSER% %URL%
)
echo Done.
echo:
pause