Skip to content

Commit

Permalink
[ci] Add scheduled push to nightly feed job (dotnet#23721)
Browse files Browse the repository at this point in the history
* [ci] Add scheduled push to nightly feed job

* Update eng/pipelines/maui-release.yml

* Update eng/pipelines/maui-release.yml

* Update eng/pipelines/maui-release.yml

* Update maui-release.yml

---------

Co-authored-by: Rui Marinho <me@ruimarinho.net>
  • Loading branch information
pjcollins and rmarinho authored Jul 24, 2024
1 parent d38ca87 commit 406c1ef
Showing 1 changed file with 81 additions and 1 deletion.
82 changes: 81 additions & 1 deletion eng/pipelines/maui-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ trigger:
- SECURITY.md
- THIRD-PARTY-NOTICES.TXT

schedules:
- cron: "0 5 * * *"
displayName: Run daily at 5:00 UTC
branches:
include:
- main

variables:
- template: /eng/pipelines/common/variables.yml@self
Expand Down Expand Up @@ -190,4 +196,78 @@ extends:
os: ${{ parameters.VM_IMAGE_HOST.os }}
scanArtifacts: ['${{ parameters.PackPlatform.binariesArtifact }}']


- ${{ if eq(variables['Build.Reason'], 'Manual') }}:
- stage: nightly
displayName: Nightly
dependsOn: ['sdk_insertion']
jobs:
- job: push_nightly
displayName: Push to nightly feed
pool: ${{ parameters.VM_IMAGE_HOST }}
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

0 comments on commit 406c1ef

Please sign in to comment.