@echo off

echo "Start Build Deepin Legalization Checeker"

set ROOT=%~dp0
cd %ROOT%

echo "ROOT: %ROOT%"

if exist %ROOT%Release (
  echo "Clear Release Dir"
  rd /s /q %ROOT%Release
)
mkdir  %ROOT%Release

call %ROOT%Tools/Scripts/BuildSource.bat %ROOT%Release

echo "End Build Deepin Legalization Checeker"

echo "Start Create Update zip"
cd %ROOT%/Release
for /R %%s in (*.exe) do (
  echo "Sign" %%s
  signtool sign /v  /f D:\Develop\Tool\Sign\sha1\sha1.pfx  /t http://timestamp.wosign.com/timestamp %%s
  signtool sign /v /as /fd sha256 /f D:\Develop\Tool\Sign\sha256\sha256.pfx /tr http://timestamp.wosign.com/rfc3161 %%s
)
%ROOT%Tools/zip.exe -r deepin-legalization-checker.zip *
echo "End Create Update zip"

echo "Create Installer"
cd %ROOT%
call %NSIS_MAKE% Installer.nsi
echo "Create Install End"

cd %ROOT%/Release
for /R %%s in (*Install*.exe) do (
  echo "Sign" %%s
  signtool sign /v  /f D:\Develop\Tool\Sign\sha1\sha1.pfx  /t http://timestamp.wosign.com/timestamp %%s
  signtool sign /v /as /fd sha256 /f D:\Develop\Tool\Sign\sha256\sha256.pfx /tr http://timestamp.wosign.com/rfc3161 %%s
)
cd %ROOT%