From 2625b7e9817299717581cdda53c5b49eabcb4314 Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Wed, 17 Feb 2016 18:19:15 -0800 Subject: [PATCH] disable caching for latest binaries --- scripts/publish/publish.ps1 | 31 ++++++++++++++++++++++--------- scripts/publish/publish.sh | 19 +++++++++++++------ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/scripts/publish/publish.ps1 b/scripts/publish/publish.ps1 index e222d6c50..f83686579 100644 --- a/scripts/publish/publish.ps1 +++ b/scripts/publish/publish.ps1 @@ -49,7 +49,7 @@ function CheckRequiredVariables return $true } -function UploadFile($Blob, $Uploadfile) +function UploadFile($Blob, $Uploadfile, $PreventCaching = $false) { Write-Host "Uploading $Uploadfile to dotnet feed." @@ -57,10 +57,17 @@ function UploadFile($Blob, $Uploadfile) { $env:HOME=Get-Location } - + + $properties = "" + + if($PreventCaching) + { + $properties = "--properties cacheControl=no-cache" + } + # use azure cli to upload to blob storage. We cannot use Invoke-WebRequest to do this becuase azure has a max limit of 64mb that can be uploaded using REST #$statusCode = (Invoke-WebRequest -URI "$Upload_URI" -Method PUT -Headers @{"x-ms-blob-type"="BlockBlob"; "x-ms-date"="2015-10-23";"x-ms-version"="2013-08-15"} -InFile $Uploadfile).StatusCode - azure storage blob upload --quiet --container $env:STORAGE_CONTAINER --blob $Blob --blobtype block --connection-string "$env:CONNECTION_STRING" --file $Uploadfile | Out-Host + azure storage blob upload --quiet $properties --container $env:STORAGE_CONTAINER --blob $Blob --blobtype block --connection-string "$env:CONNECTION_STRING" --file $Uploadfile | Out-Host if($?) { @@ -88,7 +95,7 @@ function UploadBinaries($zipFile) Write-Host "Updating the latest dotnet binaries for windows.." $zipBlobLatest = "$env:CHANNEL/Binaries/Latest/dotnet-win-x64.latest.zip" - if(-Not (UploadFile $zipBlobLatest $zipFile)) + if(-Not (UploadFile $zipBlobLatest $zipFile $true)) { return -1 } @@ -102,7 +109,7 @@ function UploadBinaries($zipFile) # upload the index file $indexBlob = "$env:CHANNEL/dnvm/latest.win.index" - if(-Not (UploadFile $indexBlob $indexFile)) + if(-Not (UploadFile $indexBlob $indexFile $true)) { return -1 } @@ -111,7 +118,7 @@ function UploadBinaries($zipFile) $versionFile = Convert-Path $PSScriptRoot\..\..\artifacts\$env:RID\stage2\.version $versionBlob = "$env:CHANNEL/dnvm/latest.win.version" - if(-Not (UploadFile $versionBlob $versionFile)) + if(-Not (UploadFile $versionBlob $versionFile $true)) { return -1 } @@ -132,7 +139,7 @@ function UploadInstallers($installerFile) Write-Host "Updating the latest dotnet installer for windows.." $installerBlobLatest = "$env:CHANNEL/Installers/Latest/dotnet-win-x64.latest.exe" - if(-Not (UploadFile $installerBlobLatest $installerFile)) + if(-Not (UploadFile $installerBlobLatest $installerFile $true)) { return -1 } @@ -145,10 +152,16 @@ function UploadVersionBadge($badgeFile) $fileName = "windows_$($env:CONFIGURATION)_$([System.IO.Path]::GetFileName($badgeFile))" Write-Host "Uploading the version badge to Latest" - UploadFile "$env:CHANNEL/Binaries/Latest/$fileName" $badgeFile + if(-Not (UploadFile "$env:CHANNEL/Binaries/Latest/$fileName" $badgeFile $true)) + { + return -1 + } Write-Host "Uploading the version badge to $env:DOTNET_CLI_VERSION" - UploadFile "$env:CHANNEL/Binaries/$env:DOTNET_CLI_VERSION/$fileName" $badgeFile + if(-Not (UploadFile "$env:CHANNEL/Binaries/$env:DOTNET_CLI_VERSION/$fileName" $badgeFile) + { + return -1 + } return 0 } diff --git a/scripts/publish/publish.sh b/scripts/publish/publish.sh index 01800ee25..aa6074710 100755 --- a/scripts/publish/publish.sh +++ b/scripts/publish/publish.sh @@ -93,12 +93,19 @@ validate_env_variables(){ upload_file_to_blob_storage_azure_cli(){ local blob=$1 local file=$2 + local preventCaching=${3:false} header "Uploading $file to blob storage" + local properties="" + + if $preventCaching ; then + $properties="--properties cacheControl=no-cache" + fi + # use azure cli to upload to blob storage. We cannot use curl to do this becuase azure has a max limit of 64mb that can be uploaded using REST # statusCode=$(curl -s -w "%{http_code}" -L -H "x-ms-blob-type: BlockBlob" -H "x-ms-date: 2015-10-21" -H "x-ms-version: 2013-08-15" $upload_URL -T $file) - azure storage blob upload --quiet --container $STORAGE_CONTAINER --blob $blob --blobtype block --connection-string "$CONNECTION_STRING" --file $file + azure storage blob upload --quiet $properties --container $STORAGE_CONTAINER --blob $blob --blobtype block --connection-string "$CONNECTION_STRING" --file $file result=$? if [ "$result" -eq "0" ]; then @@ -141,7 +148,7 @@ upload_binaries_to_blob_storage(){ echo "Updating the latest dotnet binaries.." local latestblob="$CHANNEL/Binaries/Latest/dotnet-$OSNAME-x64.latest.tar.gz" - if ! upload_file_to_blob_storage_azure_cli $latestblob $tarfile; then + if ! upload_file_to_blob_storage_azure_cli $latestblob $tarfile true; then return 1 fi @@ -149,14 +156,14 @@ upload_binaries_to_blob_storage(){ local indexContent="Binaries/$DOTNET_CLI_VERSION/$filename" local indexfile="latest.$OSNAME.index" local index_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$CHANNEL/dnvm/$indexfile$SASTOKEN" - update_file_in_blob_storage $index_URL $indexfile $indexContent + update_file_in_blob_storage $index_URL $indexfile $indexContent true # update the version file # the "@" prefix tells curl to upload the content of the file local versionContent="@$REPOROOT/artifacts/$RID/stage2/.version" local versionfile="latest.$OSNAME.version" local version_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$CHANNEL/dnvm/$versionfile$SASTOKEN" - update_file_in_blob_storage $version_URL $versionfile $versionContent + update_file_in_blob_storage $version_URL $versionfile $versionContent true return $? } @@ -175,7 +182,7 @@ upload_installers_to_blob_storage(){ local extension="${filename##*.}" local latestblob="$CHANNEL/Installers/Latest/dotnet-$OSNAME-x64.latest.$extension" - if ! upload_file_to_blob_storage_azure_cli $latestblob $installfile; then + if ! upload_file_to_blob_storage_azure_cli $latestblob $installfile true; then return 1 fi @@ -194,7 +201,7 @@ upload_version_badge(){ local badgefile=$1 local filename="${OSNAME}_${CONFIGURATION}_$(basename $badgefile)" echo "Uploading the version badge to Latest" - upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/Latest/$filename" $badgefile + upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/Latest/$filename" $badgefile true echo "Uploading the version badge to $DOTNET_CLI_VERSION" upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/$DOTNET_CLI_VERSION/$filename" $badgefile