-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathBuildBinaries-Win-x64.cmd
128 lines (82 loc) · 2.66 KB
/
BuildBinaries-Win-x64.cmd
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
@echo off
setlocal EnableDelayedExpansion
if "%~1"=="" (
echo.
echo [91mThis tool requires the following parameters:[0m
echo [91m Code signing certificate subject name[0m
echo [91m Smart card PIN[0m
exit /b 64
)
if "%~2"=="" (
echo.
echo [91mThis tool requires the following parameters:[0m
echo [91m Code signing certificate subject name[0m
echo [91m Smart card PIN[0m
exit /b 64
)
set certsub=%1
set certpin=%2
echo.
echo Creating binary files for [94mWin-x64[0m
mkdir Binary\Win-x64
echo.
echo [104;97mDeleting previous build...[0m
for /f %%i in ('dir /a:d /b Binary\Win-x64\*') do rd /s /q Binary\Win-x64\%%i
del Binary\Win-x64\* /s /f /q 1>nul
echo.
echo [104;97mSigning files...[0m
echo.
echo [94mBuilding list of files to sign...[0m
set n=0
for /f %%i in ('dir /b Release\Win-x64\*.exe') do set fileList[!n!]=Release\Win-x64\%%i && set /A n+=1
for /f %%i in ('dir /b Release\Win-x64\*.dll') do set fileList[!n!]=Release\Win-x64\%%i && set /A n+=1
for /f %%i in ('dir /a:d /b Release\Win-x64\*') do for /f %%j in ('dir /b Release\Win-x64\%%i\*.dll') do set fileList[!n!]=Release\Win-x64\%%i\%%j && set /A n+=1
echo.
echo !n! files need to be signed.
set /A max=!n!-1
set /A c=(!n!+5)/10
for /l %%i in (0,10,!n!) do (
set /A ci=%%i/10 + 1
echo.
echo [94mSigning batch !ci! out of !c![0m
set /A end=%%i+9
if !end! gtr !max! set end=!max!
set currcmd=
for /l %%j in (%%i,1,!end!) do set currcmd=!currcmd! !fileList[%%j]!
call :sign
signtool verify /pa !currcmd! || exit /b
echo.
)
echo.
echo [104;97mAll files signed and verified![0m
echo.
echo [104;97mCreating MSI installer...[0m
cd Installers\Win-x64
call make.cmd || exit /b
echo.
echo [94mSigning installer[0m
set currcmd=TreeViewer-Win-x64.msi
call :sign
signtool verify /pa !currcmd! || exit /b
echo.
echo [104;97mCreating ZIP file...[0m
move SourceDir TreeViewer-Win-x64
zip -r TreeViewer-Win-x64.zip TreeViewer-Win-x64
move TreeViewer-Win-x64 SourceDir
for /f %%i in ('dir /a:d /b SourceDir\*') do rd /s /q SourceDir\%%i
del SourceDir\* /s /f /q 1>nul
cd ..\..
move Installers\Win-x64\TreeViewer-Win-x64.msi Binary\Win-x64\
move Installers\Win-x64\TreeViewer-Win-x64.zip Binary\Win-x64\
echo.
echo [94mAll done![0m
exit /b
:sign
goto start
:retry
echo.
echo [91mRetrying[0m
echo.
:start
scsigntool -pin %certpin% sign /fd sha256 /n %certsub% /tr "http://ts.ssl.com" /td sha256 /v /a /d "TreeViewer: cross-platform software to draw phylogenetic trees" /du "https://treeviewer.org" !currcmd! || goto retry
exit /B