@echo off
title Build Release
cd /d "%~dp0"

if not exist "bin\version.txt" (
    echo Error: bin\version.txt not found!
    pause
    exit /b
)

:: Read the version into a variable
set /p NODE_VERSION=<"bin\version.txt"

:: Trim trailing spaces (standard DOS file read quirk)
set NODE_VERSION=%NODE_VERSION: =%

set ZIP_NAME=node-win64.%NODE_VERSION%.zip

echo ==============================================
echo   Packaging Release: %ZIP_NAME%
echo ==============================================
echo.

if exist "%ZIP_NAME%" (
    echo Removing old %ZIP_NAME%...
    del /q "%ZIP_NAME%"
)

echo Compressing files...
:: Compress the bin folder and all top-level .bat files
powershell -Command "Compress-Archive -Path 'bin', '*.bat' -DestinationPath '%ZIP_NAME%' -Force"

echo.
echo Done! Successfully generated %ZIP_NAME%
pause

