@@ -85,82 +85,76 @@ stages:
8585 runOnce :
8686 deploy :
8787 steps :
88+ - pwsh : |
89+ Write-Host "Setting ArtifactName to empty"
90+ Write-Host "##vso[task.setvariable variable=ArtifactName;]"
91+ displayName: Initialize ArtifactName variable
92+
93+ # This loop over artifacts is used to produce the correct number
94+ # of ESRP release tasks. It has the side effect of also setting
95+ # the artifact name by looking up the index of the current
96+ # "artifact.name" in the parameters.Artifacts array, using that
97+ # as an "index" and then using that same index to look up the
98+ # actual artifact to release in the release-order.json file.
99+ - ${{ each artifact in parameters.Artifacts }} :
88100 - pwsh : |
89- Write-Host "Setting ArtifactName to empty"
90- Write-Host "##vso[task.setvariable variable=ArtifactName;]"
91- displayName: Initialize ArtifactName variable
92-
93- # This loop over the artifacts never uses `artifact` directly.
94- # It is instead used to generate the correct number of tasks
95- # for publishing each artifact in an order specified in the
96- # release-order.json file.
97- - ${{ each artifact in parameters.Artifacts }} :
98- - pwsh : |
99- $artifacts = Get-Content '$(Pipeline.Workspace)/drop/release-order.json' | ConvertFrom-Json
100-
101- # Force $artifacts to be an array (PowerShell unrolls single-item arrays)
102- if ($artifacts -isnot [Array]) {
103- $artifacts = @($artifacts)
104- }
105-
106- $artifactName = '$(ArtifactName)'
107- if (!$artifactName) {
108- $artifactName = $artifacts[0]
109- }
110-
111- Write-Host "Releasing artifact: $artifactName"
112-
113- $artifactRootPath = '$(Pipeline.Workspace)/drop'
114- $outDir = '$(Pipeline.Workspace)/esrp-release'
115-
116- if (Test-Path $outDir) {
117- Write-Host "Cleaning output directory: $outDir"
118- Remove-Item -Path $outDir -Recurse -Force
119- }
120- New-Item -ItemType Directory -Path $outDir -Force | Out-Null
121-
122- $packageMetadataPath = "$artifactRootPath/PackageInfo/$artifactName.json"
123- if (!(Test-Path $packageMetadataPath)) {
124- Write-Error "Package metadata file not found: $packageMetadataPath"
125- exit 1
126- }
127-
128- $packageMetadata = Get-Content -Raw $packageMetadataPath | ConvertFrom-Json
129- $packageVersion = $packageMetadata.version
130- Write-Host "Package version: $packageVersion"
131-
132- $cratePath = "$artifactRootPath/$artifactName/$artifactName-$packageVersion.crate"
133- Copy-Item `
134- -Path $cratePath `
135- -Destination $outDir
136- Write-Host "Contents of $outDir"
137- Get-ChildItem -Path $outDir | ForEach-Object { Write-Host $_.FullName }
138-
139- # Set next artifact to release by
140- $artifactIndex = $artifacts.IndexOf($artifactName)
141- $nextArtifactName = $artifacts[$artifactIndex + 1]
142- Write-Host "Next artifact to release: $nextArtifactName"
143- Write-Host "##vso[task.setvariable variable=ArtifactName]$nextArtifactName"
144- displayName: 'Copy crate for ESRP'
145-
146- - task : EsrpRelease@10
147- displayName : ' ESRP Release'
148- inputs :
149- connectedservicename : ' Azure SDK PME Managed Identity'
150- ClientId : ' 5f81938c-2544-4f1f-9251-dd9de5b8a81b'
151- DomainTenantId : ' 975f013f-7f24-47e8-a7d3-abc4752bf346'
152- Usemanagedidentity : true
153- KeyVaultName : ' kv-azuresdk-codesign'
154- SignCertName : ' azure-sdk-esrp-release-certificate'
155- intent : ' packagedistribution'
156- contenttype : ' Rust'
157- contentsource : ' Folder'
158- folderlocation : ' $(Pipeline.Workspace)/esrp-release'
159- waitforreleasecompletion : true
160- owners :
${{ coalesce(variables['Build.RequestedForEmail'], '[email protected] ') }} 161- approvers :
${{ coalesce(variables['Build.RequestedForEmail'], '[email protected] ') }} 162- serviceendpointurl : ' https://api.esrp.microsoft.com/'
163- mainpublisher : ' ESRPRELPACMANTEST'
101+ # From the DevOps template artifact loop calculate the current index
102+ $indexItem = '${{ artifact.name }}'
103+ [array] $indexList = ConvertFrom-Json '${{ convertToJson(parameters.Artifacts.*.name) }}'
104+ $index = $indexList.IndexOf($indexItem)
105+ Write-Host "Index of template artifact: $index"
106+
107+ [array] $artifacts = Get-Content '$(Pipeline.Workspace)/drop/release-order.json' | ConvertFrom-Json
108+
109+ $artifactName = $artifacts[$index]
110+
111+ Write-Host "Releasing artifact: $artifactName"
112+
113+ $artifactRootPath = '$(Pipeline.Workspace)/drop'
114+ $outDir = '$(Pipeline.Workspace)/esrp-release'
115+
116+ if (Test-Path $outDir) {
117+ Write-Host "Cleaning output directory: $outDir"
118+ Remove-Item -Path $outDir -Recurse -Force
119+ }
120+ New-Item -ItemType Directory -Path $outDir -Force | Out-Null
121+
122+ $packageMetadataPath = "$artifactRootPath/PackageInfo/$artifactName.json"
123+ if (!(Test-Path $packageMetadataPath)) {
124+ Write-Error "Package metadata file not found: $packageMetadataPath"
125+ exit 1
126+ }
127+
128+ $packageMetadata = Get-Content -Raw $packageMetadataPath | ConvertFrom-Json
129+ $packageVersion = $packageMetadata.version
130+ Write-Host "Package version: $packageVersion"
131+
132+ $cratePath = "$artifactRootPath/$artifactName/$artifactName-$packageVersion.crate"
133+ Copy-Item `
134+ -Path $cratePath `
135+ -Destination $outDir
136+ Write-Host "Contents of $outDir"
137+ Get-ChildItem -Path $outDir | ForEach-Object { Write-Host $_.FullName }
138+ displayName: 'Copy crate for ESRP'
139+
140+ - task : EsrpRelease@10
141+ displayName : ' ESRP Release'
142+ inputs :
143+ connectedservicename : ' Azure SDK PME Managed Identity'
144+ ClientId : ' 5f81938c-2544-4f1f-9251-dd9de5b8a81b'
145+ DomainTenantId : ' 975f013f-7f24-47e8-a7d3-abc4752bf346'
146+ Usemanagedidentity : true
147+ KeyVaultName : ' kv-azuresdk-codesign'
148+ SignCertName : ' azure-sdk-esrp-release-certificate'
149+ intent : ' packagedistribution'
150+ contenttype : ' Rust'
151+ contentsource : ' Folder'
152+ folderlocation : ' $(Pipeline.Workspace)/esrp-release'
153+ waitforreleasecompletion : true
154+ owners :
${{ coalesce(variables['Build.RequestedForEmail'], '[email protected] ') }} 155+ approvers :
${{ coalesce(variables['Build.RequestedForEmail'], '[email protected] ') }} 156+ serviceendpointurl : ' https://api.esrp.microsoft.com/'
157+ mainpublisher : ' ESRPRELPACMANTEST'
164158
165159 - job : UpdatePackageVersion
166160 displayName : " API Review and Package Version Update"
0 commit comments