Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 1 | @setlocal |
| 2 | @echo off |
| 3 | |
| 4 | set D=%~dp0 |
Stefan Grönke | f1502d0 | 2017-09-25 18:58:10 +0200 | [diff] [blame] | 5 | set PCBUILD=%D%..\..\PCbuild\ |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 6 | |
| 7 | set HOST= |
| 8 | set USER= |
| 9 | set TARGET= |
| 10 | set DRYRUN=false |
Steve Dower | 2084b30 | 2017-10-05 13:35:36 -0700 | [diff] [blame] | 11 | set NOUPLOAD= |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 12 | set NOGPG= |
Steve Dower | 2084b30 | 2017-10-05 13:35:36 -0700 | [diff] [blame] | 13 | set NOPURGE= |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 14 | set NOTEST= |
| 15 | |
| 16 | :CheckOpts |
| 17 | if "%1" EQU "-h" goto Help |
| 18 | if "%1" EQU "-o" (set HOST=%~2) && shift && shift && goto CheckOpts |
| 19 | if "%1" EQU "--host" (set HOST=%~2) && shift && shift && goto CheckOpts |
| 20 | if "%1" EQU "-u" (set USER=%~2) && shift && shift && goto CheckOpts |
| 21 | if "%1" EQU "--user" (set USER=%~2) && shift && shift && goto CheckOpts |
| 22 | if "%1" EQU "-t" (set TARGET=%~2) && shift && shift && goto CheckOpts |
| 23 | if "%1" EQU "--target" (set TARGET=%~2) && shift && shift && goto CheckOpts |
| 24 | if "%1" EQU "--dry-run" (set DRYRUN=true) && shift && goto CheckOpts |
Steve Dower | 2084b30 | 2017-10-05 13:35:36 -0700 | [diff] [blame] | 25 | if "%1" EQU "--skip-upload" (set NOUPLOAD=true) && shift && goto CheckOpts |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 26 | if "%1" EQU "--skip-gpg" (set NOGPG=true) && shift && goto CheckOpts |
Steve Dower | 2084b30 | 2017-10-05 13:35:36 -0700 | [diff] [blame] | 27 | if "%1" EQU "--skip-purge" (set NOPURGE=true) && shift && goto CheckOpts |
Anselm Kruis | efb560e | 2017-10-02 17:53:55 +0200 | [diff] [blame] | 28 | if "%1" EQU "--skip-test" (set NOTEST=true) && shift && goto CheckOpts |
| 29 | if "%1" EQU "-T" (set NOTEST=true) && shift && goto CheckOpts |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 30 | if "%1" NEQ "" echo Unexpected argument "%1" & exit /B 1 |
| 31 | |
| 32 | if not defined PLINK where plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" |
| 33 | if not defined PLINK where /R "%ProgramFiles(x86)%\PuTTY" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" |
Steve Dower | 881323d | 2018-02-27 22:09:27 -0800 | [diff] [blame] | 34 | if not defined PLINK where /R "%ProgramFiles%\PuTTY" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 35 | if not defined PLINK where /R "%ProgramFiles(x86)%" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" |
Steve Dower | 881323d | 2018-02-27 22:09:27 -0800 | [diff] [blame] | 36 | if not defined PLINK where /R "%ProgramFiles%" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 37 | if not defined PLINK echo Cannot locate plink.exe & exit /B 1 |
| 38 | echo Found plink.exe at %PLINK% |
| 39 | |
| 40 | if not defined PSCP where pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" |
| 41 | if not defined PSCP where /R "%ProgramFiles(x86)%\PuTTY" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" |
Steve Dower | 881323d | 2018-02-27 22:09:27 -0800 | [diff] [blame] | 42 | if not defined PSCP where /R "%ProgramFiles%\PuTTY" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 43 | if not defined PSCP where /R "%ProgramFiles(x86)%" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" |
Steve Dower | 881323d | 2018-02-27 22:09:27 -0800 | [diff] [blame] | 44 | if not defined PSCP where /R "%ProgramFiles%" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 45 | if not defined PSCP echo Cannot locate pscp.exe & exit /B 1 |
| 46 | echo Found pscp.exe at %PSCP% |
| 47 | |
| 48 | if 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 | |
Steve Dower | 40a23e8 | 2017-06-19 10:34:25 -0700 | [diff] [blame] | 58 | call "%PCBUILD%find_msbuild.bat" %MSBUILD% |
| 59 | if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2) |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 60 | pushd "%D%" |
Steve Dower | 2084b30 | 2017-10-05 13:35:36 -0700 | [diff] [blame] | 61 | if 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 | ) |
| 67 | if not defined NOPURGE ( |
| 68 | %MSBUILD% /v:m /nologo uploadrelease.proj /t:Purge |
| 69 | ) |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 70 | if not defined NOTEST ( |
Steve Dower | 2084b30 | 2017-10-05 13:35:36 -0700 | [diff] [blame] | 71 | call :test x86 |
| 72 | if errorlevel 1 goto :failed |
| 73 | call :test x64 |
| 74 | if errorlevel 1 goto :failed |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 75 | ) |
Steve Dower | 40a23e8 | 2017-06-19 10:34:25 -0700 | [diff] [blame] | 76 | %MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x86 |
Steve Dower | 2084b30 | 2017-10-05 13:35:36 -0700 | [diff] [blame] | 77 | if errorlevel 1 goto :failed |
Steve Dower | 40a23e8 | 2017-06-19 10:34:25 -0700 | [diff] [blame] | 78 | %MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x64 /p:IncludeDoc=false |
Steve Dower | 2084b30 | 2017-10-05 13:35:36 -0700 | [diff] [blame] | 79 | if errorlevel 1 goto :failed |
| 80 | |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 81 | popd |
| 82 | exit /B 0 |
| 83 | |
Steve Dower | 2084b30 | 2017-10-05 13:35:36 -0700 | [diff] [blame] | 84 | :test |
| 85 | %MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=%1 |
| 86 | if 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 | ) |
| 92 | exit /B |
| 93 | |
| 94 | :failed |
| 95 | popd |
| 96 | exit /B |
| 97 | |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 98 | :Help |
| 99 | echo uploadrelease.bat --host HOST --user USERNAME [--target TARGET] [--dry-run] [-h] |
| 100 | echo. |
| 101 | echo --host (-o) Specify the upload host (required) |
| 102 | echo --user (-u) Specify the user on the host (required) |
| 103 | echo --target (-t) Specify the target directory on the host |
| 104 | echo --dry-run Display commands and filenames without executing them |
| 105 | echo --skip-gpg Does not generate GPG signatures before uploading |
| 106 | echo --skip-purge Does not perform CDN purge after uploading |
| 107 | echo --skip-test (-T) Does not perform post-upload tests |
| 108 | echo -h Display this help information |
| 109 | echo. |