Add push command to the repository
This commit is contained in:
Родитель
4282daa642
Коммит
831d7d5093
|
@ -0,0 +1,2 @@
|
|||
@ECHO OFF
|
||||
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0push.ps1' %*; exit $LASTEXITCODE"
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env powershell
|
||||
#requires -version 4
|
||||
[cmdletbinding(SupportsShouldProcess = $true)]
|
||||
param(
|
||||
[string]$NuGetFeed = 'https://dotnet.myget.org/F/aspnetcore-tools/api/v2/package',
|
||||
[string]$AzureStorageAccount = 'aspnetcore'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version 2
|
||||
|
||||
if ($env:BUILD_IS_PERSONAL) {
|
||||
$WhatIfPreference = $true
|
||||
Write-Host -ForegroundColor Yellow 'Automatically setting -WhatIf for personal builds'
|
||||
}
|
||||
|
||||
Import-Module -Force -Scope Local $PSScriptRoot/sdk/KoreBuild/KoreBuild.psd1
|
||||
|
||||
$artifacts = Join-Path $PSScriptRoot 'artifacts'
|
||||
|
||||
Get-ChildItem "$artifacts/build/*.nupkg" | Push-NuGetPackage -Feed $NuGetFeed -ApiKey $env:APIKEY -WhatIf:$WhatIfPreference
|
||||
|
||||
$settings = [xml] (Get-Content (Join-Path $PSScriptRoot 'version.props'))
|
||||
$channelName = $settings.Project.PropertyGroup.KoreBuildChannel
|
||||
|
||||
Write-Host "Pushing azure artifacts for '$channelName' channel"
|
||||
|
||||
& "$PSScriptRoot/scripts/UploadBlobs.ps1" `
|
||||
-Channel $channelName `
|
||||
-ArtifactsDir $artifacts `
|
||||
-AzureStorageAccount $AzureStorageAccount `
|
||||
-WhatIf:$WhatIfPreference
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env powershell
|
||||
#requires -version 4
|
||||
[cmdletbinding(SupportsShouldProcess = $true)]
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ArtifactsDir,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Feed
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version 1
|
||||
|
||||
Import-Module -Force -Scope Local $PSScriptRoot/../sdk/KoreBuild/KoreBuild.psd1
|
||||
|
||||
Get-ChildItem "$ArtifactsDir/build/*.nupkg" | Push-NuGetPackages -Feed $Feed
|
|
@ -1,13 +1,17 @@
|
|||
#!/usr/bin/env powershell
|
||||
#requires -version 4
|
||||
[cmdletbinding(SupportsShouldProcess = $true)]
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
$ArtifactsDir,
|
||||
$ContainerName = 'buildtools'
|
||||
[string]$ArtifactsDir,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Channel,
|
||||
[string]$ContainerName = 'buildtools',
|
||||
[string]$AzureStorageAccount = $env:AZURE_STORAGE_ACCOUNT
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version 1
|
||||
Set-StrictMode -Version 2
|
||||
|
||||
function Join-Paths($path, $childPaths) {
|
||||
$childPaths | ForEach-Object { $path = Join-Path $path $_ }
|
||||
|
@ -39,12 +43,12 @@ if (!(Get-Command 'az' -ErrorAction Ignore)) {
|
|||
|
||||
$korebuildDir = Join-Path (Resolve-Path $ArtifactsDir) 'korebuild'
|
||||
|
||||
if (!($env:AZURE_STORAGE_ACCOUNT)) {
|
||||
Write-Error 'Expected $env:AZURE_STORAGE_ACCOUNT to be set'
|
||||
if (!$AzureStorageAccount) {
|
||||
Write-Error 'Expected -AzureStorageAccount or $env:AZURE_STORAGE_ACCOUNT to be set'
|
||||
}
|
||||
|
||||
if (!($env:AZURE_STORAGE_SAS_TOKEN)) {
|
||||
Write-Error 'Expected $env:AZURE_STORAGE_SAS_TOKEN to be set'
|
||||
Write-Warning 'Expected $env:AZURE_STORAGE_SAS_TOKEN to be set'
|
||||
}
|
||||
|
||||
if (!(Test-Path $korebuildDir)) {
|
||||
|
@ -52,24 +56,19 @@ if (!(Test-Path $korebuildDir)) {
|
|||
exit 0
|
||||
}
|
||||
|
||||
$dryrun = ''
|
||||
if ($env:BUILD_IS_PERSONAL) {
|
||||
Write-Host "Running publish as a dryrun for personal builds"
|
||||
$dryrun = '--dryrun'
|
||||
}
|
||||
|
||||
$globs = (
|
||||
@{
|
||||
pattern = 'artifacts/*.zip'
|
||||
contentType = 'application/zip'
|
||||
otherArgs = @()
|
||||
},
|
||||
@{
|
||||
pattern = '*/badge.svg'
|
||||
pattern = "channels/$Channel/badge.svg"
|
||||
contentType = 'image/svg+xml'
|
||||
otherArgs = ('--content-cache-control', 'no-cache, no-store, must-revalidate')
|
||||
},
|
||||
@{
|
||||
pattern = '*/latest.txt'
|
||||
pattern = "channels/$Channel/latest.txt"
|
||||
contentType = 'text/plain'
|
||||
otherArgs = ('--content-cache-control', 'no-cache, no-store, must-revalidate')
|
||||
}
|
||||
|
@ -77,16 +76,22 @@ $globs = (
|
|||
|
||||
$globs | ForEach-Object {
|
||||
$otherArgs = $_.otherArgs
|
||||
__exec az storage blob upload-batch `
|
||||
$dryrun `
|
||||
--verbose `
|
||||
--pattern $_.pattern `
|
||||
--content-type $_.contentType `
|
||||
--destination "$ContainerName/korebuild" `
|
||||
--source $korebuildDir `
|
||||
@otherArgs
|
||||
if (!(Get-ChildItem -Recurse (Join-Path $korebuildDir $_.pattern) -ErrorAction Ignore)) {
|
||||
Write-Warning "Expected files in $korebuildDir/$($_.pattern) but found none"
|
||||
}
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error 'Failed to upload Azure artifacts'
|
||||
if ($PSCmdlet.ShouldProcess("$korebuildDir/$($_.pattern) as $($_.contentType)", "Push to Azure")) {
|
||||
__exec az storage blob upload-batch `
|
||||
--account-name $AzureStorageAccount `
|
||||
--verbose `
|
||||
--pattern $_.pattern `
|
||||
--content-type $_.contentType `
|
||||
--destination "$ContainerName/korebuild" `
|
||||
--source $korebuildDir `
|
||||
@otherArgs
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error 'Failed to upload Azure artifacts'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,8 +218,9 @@ function Push-NuGetPackage {
|
|||
}
|
||||
|
||||
if (!$ApiKey) {
|
||||
Write-Warning 'The parameter -ApiKey was missing and $env:APIKey was not set. The API key may be required to push to the remote feed.'
|
||||
Write-Warning 'The parameter -ApiKey was missing. This may be required to push to the remote feed.'
|
||||
}
|
||||
|
||||
if ($Packages | ? { $_ -like '*.symbols.nupkg' }) {
|
||||
Write-Warning "Push-NuGetPackage does not yet support pushing symbols packages."
|
||||
}
|
||||
|
@ -274,6 +275,9 @@ function Push-NuGetPackage {
|
|||
if ($remaining -le 0) {
|
||||
throw
|
||||
}
|
||||
else {
|
||||
Write-Host "Push failed. Retries left $remaining"
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$remaining--
|
||||
|
|
Загрузка…
Ссылка в новой задаче