Changes to push windows artifacts into the dotnet blob storage

- Use timestamp of last git commit as build numbers
- Push the generated zip/msi files into dotnet blob storage
This commit is contained in:
Sridhar Periyasamy 2015-10-26 18:31:06 -07:00
parent 3b9cfb086c
commit d2f7624e00
3 changed files with 75 additions and 0 deletions

View file

@ -1,6 +1,13 @@
@echo off
setlocal EnableDelayedExpansion
REM UTC Timestamp of the last commit is used as the build number. This is for easy synchronization of build number between Windows, OSX and Linux builds.
REM Using powershell is way easier to retrive and format the timestamp in any way we want.
set LAST_COMMIT_TIMESTAMP=powershell -Command "& { $timestamp = git log -1 --format=%%ct ; $origin = New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0; $commitTime = $origin.AddSeconds($timestamp); echo $commitTime.ToString(\"yyyyMMdd-HHmmss\");}"
for /f %%i in ('%LAST_COMMIT_TIMESTAMP%') do set DOTNET_BUILD_VERSION=0.0.1-alpha-%%i
where dnvm
if %ERRORLEVEL% neq 0 (
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"

View file

@ -20,3 +20,9 @@ Add-Type -Assembly System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory($Stage2Dir, $PackageName, "Optimal", $false)
Write-Host "Packaged stage2 to $PackageName"
$PublishScript = Join-Path $PSScriptRoot "publish.ps1"
& $PublishScript -file $PackageName
exit $LastExitCode

62
scripts/publish.ps1 Normal file
View file

@ -0,0 +1,62 @@
param(
[string]$file = $(throw "Specify the full path to the file to be uploaded")
)
function CheckRequiredVariables
{
if([string]::IsNullOrEmpty($env:DOTNET_BUILD_VERSION))
{
return $false
}
# this variable is set by the CI system
if([string]::IsNullOrEmpty($env:SASTOKEN))
{
return $false
}
return $true
}
$Result = CheckRequiredVariables
if(!$Result)
{
# fail silently if the required variables are not available for publishing the file.
exit 0
}
if(![System.IO.File]::Exists($file))
{
throw "$file not found"
}
$fileName = [System.IO.Path]::GetFileName($file)
if([System.IO.Path]::GetExtension($file).ToLower() -eq ".zip")
{
$Folder = "Binaries"
}
elseif([System.IO.Path]::GetExtension($file).ToLower() -eq ".msi")
{
$Folder = "Installers"
}
Write-Host "Uploading $fileName to dotnet feed.."
Invoke-WebRequest -URI "https://dotnetcli.blob.core.windows.net/dotnet/$Folder/$env:DOTNET_BUILD_VERSION/$fileName$env:SASTOKEN" -Method PUT -Headers @{"x-ms-blob-type"="BlockBlob"; "x-ms-date"="2015-10-23";"x-ms-version"="2013-08-15"} -InFile $file
$ReturnCode = $LASTEXITCODE
if($ReturnCode -eq 0)
{
Write-Host "Successfully uploaded $file to dotnet feed."
}
{
Write-Host "Failed to upload $file to dotnet feed."
}
exit $ReturnCode