-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
57 lines (44 loc) · 1.67 KB
/
build.bat
File metadata and controls
57 lines (44 loc) · 1.67 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
@echo off
setlocal enabledelayedexpansion
set "package_name=FileCleanup"
set "build_folder="
rem Define the list of target platforms
rem add linux env linux/386 linux/amd64 linux/arm
set "platforms=windows/amd64 windows/386"
rem Loop through each platform
for %%P in (%platforms%) do (
for /f "tokens=1,2 delims=/" %%A in ("%%P") do (
set "GOOS=%%A"
set "GOARCH=%%B"
rem Determine the build folder based on the platform
if "%%A" == "windows" (
set "build_folder=windows-build"
) else (
set "build_folder=linux-build"
)
rem Create the build folder if it doesn't exist
if not exist "!build_folder!" (
mkdir "!build_folder!"
)
rem Build the output name based on the platform
set "output_name=!package_name!-!GOOS!-!GOARCH!"
if "!GOOS!" == "windows" set "output_name=!output_name!.exe"
rem Build the executable
set "command=go build -o !output_name! main.go"
if "!GOOS!" == "windows" set "command=go build -o !output_name! main.go"
call !command!
rem Move the executable to the build folder
move "!output_name!" "!build_folder!\!output_name!"
rem Check for errors during build
if errorlevel 1 (
echo An error has occurred! Aborting the script execution...
exit /b 1
)
)
)
rem Zip the build folders
set "zip_name=FileCleanup.zip"
rem powershell Compress-Archive -Path "windows-build", "linux-build" -DestinationPath "!zip_name!"
powershell Compress-Archive -Path "windows-build" -DestinationPath "!zip_name!"
echo Builds have been zipped to !zip_name!
endlocal