feat(build): add build scripts for Linux and Windows with commit hash and build time
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/.claude
|
||||
agent.md
|
||||
config.json
|
||||
*.exe
|
||||
|
||||
# SQLite database files. They live on a network share (Y:), and git/cloud
|
||||
# sync touching them while a WAL database is open corrupts the WAL index and
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo Building for Linux (amd64)...
|
||||
|
||||
:: Get git commit hash (shortened to 7 characters, can also use full)
|
||||
for /f %%i in ('git rev-parse --short HEAD') do set COMMIT=%%i
|
||||
|
||||
:: Get UTC time
|
||||
for /f %%i in ('powershell -Command "Get-Date -Format 'yyyy-MM-ddTHH:mm:ssZ'"') do set BUILD_DATE=%%i
|
||||
|
||||
:: Set environment variables for Linux build
|
||||
set GOOS=linux
|
||||
set GOARCH=amd64
|
||||
set CGO_ENABLED=0
|
||||
|
||||
:: Build -ldflags
|
||||
set LDFLAGS=-X main.BuildTime=%BUILD_DATE% -X main.CommitHash=%COMMIT%
|
||||
|
||||
:: Set output file name
|
||||
set OUTPUT=nukumizu-linux-amd64
|
||||
|
||||
echo Commit: %COMMIT%
|
||||
echo BuildDate: %BUILD_DATE%
|
||||
echo Output: %OUTPUT%
|
||||
|
||||
go build -ldflags "%LDFLAGS%" -o "%OUTPUT%" .
|
||||
|
||||
if %errorlevel% equ 0 (
|
||||
echo Build succeeded: %OUTPUT%
|
||||
) else (
|
||||
echo Build failed.
|
||||
)
|
||||
@@ -0,0 +1,33 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo Building for Windows (amd64)...
|
||||
|
||||
:: Get git commit hash (shortened to 7 characters, can also use full)
|
||||
for /f %%i in ('git rev-parse --short HEAD') do set COMMIT=%%i
|
||||
|
||||
:: Get UTC time
|
||||
for /f %%i in ('powershell -Command "Get-Date -Format 'yyyy-MM-ddTHH:mm:ssZ'"') do set BUILD_DATE=%%i
|
||||
|
||||
:: Set environment variables for Windows build
|
||||
set GOOS=windows
|
||||
set GOARCH=amd64
|
||||
set CGO_ENABLED=0
|
||||
|
||||
:: Build -ldflags
|
||||
set LDFLAGS=-X main.BuildTime=%BUILD_DATE% -X main.CommitHash=%COMMIT%
|
||||
|
||||
:: Set output file name
|
||||
set OUTPUT=nukumizu-windows-amd64.exe
|
||||
|
||||
echo Commit: %COMMIT%
|
||||
echo BuildDate: %BUILD_DATE%
|
||||
echo Output: %OUTPUT%
|
||||
|
||||
go build -ldflags "%LDFLAGS%" -o "%OUTPUT%" .
|
||||
|
||||
if %errorlevel% equ 0 (
|
||||
echo Build succeeded: %OUTPUT%
|
||||
) else (
|
||||
echo Build failed.
|
||||
)
|
||||
@@ -21,14 +21,22 @@ import (
|
||||
"nukumizu-backend/utils"
|
||||
)
|
||||
|
||||
// CommitHash and BuildTime are set at build time using -ldflags.
|
||||
var (
|
||||
CommitHash string
|
||||
BuildTime string
|
||||
)
|
||||
|
||||
// SoftwareInfo holds build metadata.
|
||||
type SoftwareInfo struct {
|
||||
Name string
|
||||
Version string
|
||||
Developer string
|
||||
BuildVer int16
|
||||
CommitHash string
|
||||
Description string
|
||||
BuildType string
|
||||
BuildTime string
|
||||
}
|
||||
|
||||
var softwareInfo = SoftwareInfo{
|
||||
@@ -36,8 +44,10 @@ var softwareInfo = SoftwareInfo{
|
||||
Version: "0.1.0",
|
||||
Developer: "Madobi Nanami",
|
||||
BuildVer: 1,
|
||||
CommitHash: CommitHash,
|
||||
Description: "Remote server monitoring and command execution subsystem for Komari",
|
||||
BuildType: "Debug",
|
||||
BuildTime: BuildTime,
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -46,7 +56,7 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
// Log startup banner.
|
||||
postLog.Info(fmt.Sprintf("%s Ver.%s.%d.%s Developed by %s", softwareInfo.Name, softwareInfo.Version, softwareInfo.BuildVer, softwareInfo.BuildType, softwareInfo.Developer))
|
||||
postLog.Info(fmt.Sprintf("%s Ver.%s.%d.%s.%s Developed by %s at %s", softwareInfo.Name, softwareInfo.Version, softwareInfo.BuildVer, softwareInfo.BuildType, softwareInfo.CommitHash, softwareInfo.Developer, softwareInfo.BuildTime))
|
||||
|
||||
// Load configuration.
|
||||
cfg, err := config.LoadConfig(*configPath)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: Get git commit hash (shortened to 7 characters, can also use full)
|
||||
for /f %%i in ('git rev-parse --short HEAD') do set COMMIT=%%i
|
||||
|
||||
:: Get UTC time
|
||||
for /f %%i in ('powershell -Command "Get-Date -Format 'yyyy-MM-ddTHH:mm:ssZ'"') do set BUILD_DATE=%%i
|
||||
|
||||
:: Build -ldflags
|
||||
set LDFLAGS=-X main.BuildTime=%BUILD_DATE% -X main.CommitHash=%COMMIT%
|
||||
go run -ldflags "%LDFLAGS%" .
|
||||
Reference in New Issue
Block a user