• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@setlocal
2@echo off
3
4set D=%~dp0
5set PCBUILD=%D%..\..\PCbuild\
6
7set HOST=
8set USER=
9set TARGET=
10set DRYRUN=false
11set NOUPLOAD=
12set NOGPG=
13set NOPURGE=
14set NOTEST=
15
16:CheckOpts
17if "%1" EQU "-h" goto Help
18if "%1" EQU "-o" (set HOST=%~2) && shift && shift && goto CheckOpts
19if "%1" EQU "--host" (set HOST=%~2) && shift && shift && goto CheckOpts
20if "%1" EQU "-u" (set USER=%~2) && shift && shift && goto CheckOpts
21if "%1" EQU "--user" (set USER=%~2) && shift && shift && goto CheckOpts
22if "%1" EQU "-t" (set TARGET=%~2) && shift && shift && goto CheckOpts
23if "%1" EQU "--target" (set TARGET=%~2) && shift && shift && goto CheckOpts
24if "%1" EQU "--dry-run" (set DRYRUN=true) && shift && goto CheckOpts
25if "%1" EQU "--skip-upload" (set NOUPLOAD=true) && shift && goto CheckOpts
26if "%1" EQU "--skip-gpg" (set NOGPG=true) && shift && goto CheckOpts
27if "%1" EQU "--skip-purge" (set NOPURGE=true) && shift && goto CheckOpts
28if "%1" EQU "--skip-test" (set NOTEST=true) && shift && goto CheckOpts
29if "%1" EQU "-T" (set NOTEST=true) && shift && goto CheckOpts
30if "%1" NEQ "" echo Unexpected argument "%1" & exit /B 1
31
32if not defined PLINK where plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc"
33if not defined PLINK where /R "%ProgramFiles(x86)%\PuTTY" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc"
34if not defined PLINK where /R "%ProgramFiles%\PuTTY" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc"
35if not defined PLINK where /R "%ProgramFiles(x86)%" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc"
36if not defined PLINK where /R "%ProgramFiles%" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc"
37if not defined PLINK echo Cannot locate plink.exe & exit /B 1
38echo Found plink.exe at %PLINK%
39
40if not defined PSCP where pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc"
41if not defined PSCP where /R "%ProgramFiles(x86)%\PuTTY" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc"
42if not defined PSCP where /R "%ProgramFiles%\PuTTY" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc"
43if not defined PSCP where /R "%ProgramFiles(x86)%" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc"
44if not defined PSCP where /R "%ProgramFiles%" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc"
45if not defined PSCP echo Cannot locate pscp.exe & exit /B 1
46echo Found pscp.exe at %PSCP%
47
48if defined NOGPG (
49    set GPG=
50    echo Skipping GPG signature generation because of --skip-gpg
51) else  (
52    if not defined GPG where gpg2 > "%TEMP%\gpg.loc" 2> nul && set /P GPG= < "%TEMP%\gpg.loc" & del "%TEMP%\gpg.loc"
53    if not defined GPG where /R "%PCBUILD%..\externals\windows-installer" gpg2 > "%TEMP%\gpg.loc" 2> nul && set /P GPG= < "%TEMP%\gpg.loc" & del "%TEMP%\gpg.loc"
54    if not defined GPG echo Cannot locate gpg2.exe. Signatures will not be uploaded & pause
55    echo Found gpg2.exe at %GPG%
56)
57
58call "%PCBUILD%find_msbuild.bat" %MSBUILD%
59if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2)
60pushd "%D%"
61if not defined NOUPLOAD (
62    %MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x86
63    if errorlevel 1 goto :failed
64    %MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x64 /p:IncludeDoc=false
65    if errorlevel 1 goto :failed
66)
67if not defined NOPURGE (
68    %MSBUILD% /v:m /nologo uploadrelease.proj /t:Purge
69)
70if not defined NOTEST (
71    call :test x86
72    if errorlevel 1 goto :failed
73    call :test x64
74    if errorlevel 1 goto :failed
75)
76%MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x86
77if errorlevel 1 goto :failed
78%MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x64 /p:IncludeDoc=false
79if errorlevel 1 goto :failed
80
81popd
82exit /B 0
83
84:test
85%MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=%1
86if errorlevel 1 (
87    echo Test failed - purging and retrying
88    %MSBUILD% /v:m /nologo uploadrelease.proj /t:Purge
89    if errorlevel 1 exit /B
90    %MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=%1
91)
92exit /B
93
94:failed
95popd
96exit /B
97
98:Help
99echo uploadrelease.bat --host HOST --user USERNAME [--target TARGET] [--dry-run] [-h]
100echo.
101echo    --host (-o)      Specify the upload host (required)
102echo    --user (-u)      Specify the user on the host (required)
103echo    --target (-t)    Specify the target directory on the host
104echo    --dry-run        Display commands and filenames without executing them
105echo    --skip-gpg       Does not generate GPG signatures before uploading
106echo    --skip-purge     Does not perform CDN purge after uploading
107echo    --skip-test (-T) Does not perform post-upload tests
108echo    -h               Display this help information
109echo.
110