@@ -30,6 +30,15 @@ REM ------------------------------------------------
3030REM Safety checks for Release Mode
3131REM ------------------------------------------------
3232if " %IS_RELEASE% " == " true" (
33+ git status -s > temp_status.txt
34+ set /p STATUS = < temp_status.txt
35+ del temp_status.txt
36+ if not " !STATUS! " == " " (
37+ echo ❌ Error: Working directory is not clean. Commit or stash changes before releasing.
38+ git status -s
39+ exit /b 1
40+ )
41+
3342 where gh > nul 2 > nul
3443 if errorlevel 1 (
3544 echo ❌ Error: GitHub CLI (gh) not installed. Required for releases.
@@ -88,6 +97,9 @@ if not "%TINYMEM_EXTRA_BUILD_TAGS%"=="" (
8897set TAGS_FLAG = -tags " %BUILD_TAGS% "
8998set LDFLAGS = -X github.com/daverage/tinymem/internal/version.Version=%VERSION%
9099
100+ REM Clear previous releases
101+ if exist " %OUT_DIR% \*" del /q " %OUT_DIR% \*"
102+
91103echo → Windows AMD64
92104set CGO_ENABLED = 1
93105set GOOS = windows
@@ -100,6 +112,44 @@ set GOOS=windows
100112set GOARCH = arm64
101113go build %TAGS_FLAG% -ldflags " %LDFLAGS% " -o " %OUT_DIR% \tinymem-windows-arm64.exe" .\cmd\tinymem
102114
115+ REM ------------------------------------------------
116+ REM Cross-compilation (if Zig is present)
117+ REM ------------------------------------------------
118+ where zig > nul 2 > nul
119+ if not errorlevel 1 (
120+ echo → macOS ARM64 (Cross-compiling via zig cc)
121+ set CGO_ENABLED = 1
122+ set GOOS = darwin
123+ set GOARCH = arm64
124+ set CC = zig cc -target aarch64-macos
125+ go build %TAGS_FLAG% -ldflags " %LDFLAGS% " -o " %OUT_DIR% \tinymem-darwin-arm64" .\cmd\tinymem
126+
127+ echo → macOS AMD64 (Cross-compiling via zig cc)
128+ set CGO_ENABLED = 1
129+ set GOOS = darwin
130+ set GOARCH = amd64
131+ set CC = zig cc -target x86_64-macos
132+ go build %TAGS_FLAG% -ldflags " %LDFLAGS% " -o " %OUT_DIR% \tinymem-darwin-amd64" .\cmd\tinymem
133+
134+ echo → Linux AMD64 (Cross-compiling via zig cc)
135+ set CGO_ENABLED = 1
136+ set GOOS = linux
137+ set GOARCH = amd64
138+ set CC = zig cc -target x86_64-linux-musl
139+ go build %TAGS_FLAG% -ldflags " %LDFLAGS% " -o " %OUT_DIR% \tinymem-linux-amd64" .\cmd\tinymem
140+
141+ echo → Linux ARM64 (Cross-compiling via zig cc)
142+ set CGO_ENABLED = 1
143+ set GOOS = linux
144+ set GOARCH = arm64
145+ set CC = zig cc -target aarch64-linux-musl
146+ go build %TAGS_FLAG% -ldflags " %LDFLAGS% " -o " %OUT_DIR% \tinymem-linux-arm64" .\cmd\tinymem
147+
148+ set CC =
149+ ) else (
150+ echo Skipping cross-compilation (zig not found). To enable: winget install zig.zig
151+ )
152+
103153REM ------------------------------------------------
104154REM Finalize Release
105155REM ------------------------------------------------
@@ -154,4 +204,4 @@ if "%IS_RELEASE%"=="true" (
154204 echo Build complete. Artifacts in %OUT_DIR%
155205)
156206
157- exit /b 0
207+ exit /b 0
0 commit comments