Skip to content

Commit dc3b966

Browse files
committed
Compress-ReleaseCrate.ps1, wire into archetype-rust-release.yml
1 parent 05b3637 commit dc3b966

File tree

2 files changed

+39
-23
lines changed

2 files changed

+39
-23
lines changed

eng/pipelines/templates/stages/archetype-rust-release.yml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,15 @@ stages:
8888
parameters:
8989
Toolchain: stable
9090

91-
- pwsh: |
92-
$artifactName = '${{artifact.name}}'
93-
Write-Host "Artifact name: $artifactName"
94-
95-
$packageMetadataPath = "$(Pipeline.Workspace)/drop/PackageInfo/$artifactName.json"
96-
if (!(Test-Path $packageMetadataPath)) {
97-
Write-Error "Package metadata file not found: $packageMetadataPath"
98-
exit 1
99-
}
100-
101-
$packageMetadata = Get-Content -Raw $packageMetadataPath | ConvertFrom-Json -AsHashTable
102-
$packageVersion = $packageMetadata.version
103-
Write-Host "Package version: $packageVersion"
104-
105-
New-Item -ItemType Directory -Path '$(Pipeline.Workspace)/release' -Force | Out-Null
106-
Compress-Archive `
107-
-Path "$(Pipeline.Workspace)/drop/$artifactName-$packageVersion.crate" `
108-
-DestinationPath "$(Pipeline.Workspace)/release/release.zip"
109-
110-
Get-ChildItem -Path "$(Pipeline.Workspace)/release" | ForEach-Object { Write-Host "Release artifact: $($_.FullName)" }
111-
112-
displayName: Zip Crate for ESRP
91+
- task: PowerShell@2
92+
displayName: Compress Crate for ESRP
93+
inputs:
94+
targetType: filePath
95+
filePath: $(Build.SourcesDirectory)/eng/scripts/Compress-ReleaseCrate.ps1
96+
arguments: >
97+
-ArtifactName '${{artifact.name}}'
98+
-ArtifactRootPath '$(Pipeline.Workspace)/drop'
99+
-OutFile '$(Pipeline.Workspace)/esrp-release/release.zip'
113100
114101
- task: EsrpRelease@10
115102
displayName: 'ESRP Release'
@@ -122,10 +109,11 @@ stages:
122109
# authcertname: $(2460c5ef-Cert-Auth)
123110
# signcertname: $(2460c5ef-Cert-Signing)
124111
clientid: '5f81938c-2544-4f1f-9251-dd9de5b8a81b'
112+
Usemanagedidentity: true
125113
intent: 'packagedistribution'
126114
contenttype: 'Rust'
127115
contentsource: 'Folder'
128-
folderlocation: '$(Pipeline.Workspace)/release/release.zip'
116+
folderlocation: '$(Pipeline.Workspace)/esrp-release'
129117
waitforreleasecompletion: true
130118
owners: ${{ coalesce(variables['Build.RequestedForEmail'], '[email protected]') }}
131119
approvers: ${{ coalesce(variables['Build.RequestedForEmail'], '[email protected]') }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env pwsh
2+
3+
#Requires -Version 7.0
4+
[CmdletBinding(DefaultParameterSetName = "none")]
5+
param(
6+
[string]$ArtifactName,
7+
[string]$ArtifactRootPath,
8+
[string]$OutFile
9+
)
10+
11+
Write-Host "Artifact name: $ArtifactName"
12+
13+
$packageMetadataPath = "$ArtifactRootPath/PackageInfo/$ArtifactName.json"
14+
if (!(Test-Path $packageMetadataPath)) {
15+
Write-Error "Package metadata file not found: $packageMetadataPath"
16+
exit 1
17+
}
18+
19+
$packageMetadata = Get-Content -Raw $packageMetadataPath | ConvertFrom-Json
20+
$packageVersion = $packageMetadata.version
21+
Write-Host "Package version: $packageVersion"
22+
23+
New-Item -ItemType Directory -Path '$(Pipeline.Workspace)/release' -Force | Out-Null
24+
Compress-Archive `
25+
-Path "$ArtifactRootPath/$ArtifactName/$ArtifactName-$packageVersion.crate" `
26+
-DestinationPath $OutFile
27+
28+
Write-Host "Created archive: $OutFile"

0 commit comments

Comments
 (0)