forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] Move to push nightly to a template (dotnet#23811)
- Loading branch information
Showing
4 changed files
with
109 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
parameters: | ||
poolName: MAUI-1ESPT | ||
vmImage: '1ESPT-Windows2022' | ||
os: windows | ||
dependsOn: [''] | ||
scanArtifacts: [] | ||
stageName: 'nightly' | ||
displayName: 'Nightly' | ||
|
||
stages: | ||
- stage: ${{ parameters.stageName }} | ||
dependsOn: ${{ parameters.dependsOn }} | ||
displayName: ${{ parameters.displayName }} | ||
jobs: | ||
- job: push_nightly_job | ||
displayName: Push to nightly feed | ||
pool: | ||
name: ${{ parameters.poolName }} | ||
vmImage: ${{ parameters.vmImage }} | ||
workspace: | ||
clean: all | ||
timeoutInMinutes: 60 | ||
steps: | ||
- checkout: none | ||
|
||
- task: UseDotNet@2 | ||
displayName: Use .NET 8.x | ||
inputs: | ||
version: 8.x | ||
|
||
- task: AzureCLI@2 | ||
displayName: Update service connection with managed identity | ||
inputs: | ||
azureSubscription: maui-nightly-feed-mi | ||
scriptType: ps | ||
scriptLocation: inlineScript | ||
inlineScript: | | ||
$accessToken = az account get-access-token --query accessToken --resource $(MauiNightlyFeedMIResourceId) -o tsv | ||
Write-Host "##vso[task.setsecret]$accessToken" | ||
Write-Host "Overwriting authorization token for the maui-nightly-feed service connection" | ||
# https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#setendpoint-modify-a-service-connection-field | ||
Write-Host "##vso[task.setendpoint id=$(MauiNightlyFeedServiceConnectionId);field=authParameter;key=apitoken]${accessToken}" | ||
- task: NuGetAuthenticate@1 | ||
displayName: NuGet Authenticate using managed identity token | ||
inputs: | ||
nuGetServiceConnections: maui-nightly-feed | ||
|
||
- task: DownloadPipelineArtifact@2 | ||
inputs: | ||
artifactName: nuget-signed | ||
downloadPath: $(Build.StagingDirectory)\nuget-signed | ||
displayName: Download nuget-signed | ||
|
||
- task: DownloadPipelineArtifact@2 | ||
inputs: | ||
artifactName: vs-msi-nugets | ||
downloadPath: $(Build.StagingDirectory)\nuget-signed | ||
displayName: Download vs-msi-nugets | ||
|
||
- powershell: | | ||
$feed = "$env:NUGET_FEED_MAUI_NIGHTLY" | ||
# Signed maui packages except manifest | ||
$nupkgs = (Get-ChildItem -Path "$(Build.StagingDirectory)\nuget-signed\" -Filter *.nupkg) | Where-Object { $_.BaseName -notlike 'Microsoft.NET.Sdk.Maui.Manifest-*' } | ||
$maxAttempts = 5 | ||
foreach($nupkg in $nupkgs) { | ||
$nupkgFile = $nupkg.FullName | ||
$attempt = 1 | ||
$waiting = $true | ||
do { | ||
try { | ||
Write-Output "dotnet push $nupkgFile" | ||
& dotnet nuget push --source $feed --api-key az --skip-duplicate $nupkgFile | ||
$waiting = $false | ||
} | ||
catch { | ||
if ($attempt -gt $maxAttempts) | ||
{ | ||
throw 'Maximum attempts reached, failing!' | ||
} | ||
Write-Output " attempt $attempt of $maxAttempts failed..." | ||
$attempt = $attempt + 1 | ||
} | ||
} while ($waiting) | ||
} | ||
displayName: Push nupkg to maui nightly feed | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters