Skip to content

Commit da1fda7

Browse files
committed
Only create the stage if there are artifacts to release
1 parent fa4ab88 commit da1fda7

File tree

1 file changed

+161
-160
lines changed

1 file changed

+161
-160
lines changed

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

Lines changed: 161 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -18,167 +18,168 @@ parameters:
1818
stages:
1919
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
2020
- ${{ if in(variables['Build.Reason'], 'Manual', '') }}:
21-
- stage: Release_Batch
22-
displayName: "Releasing: ${{length(parameters.Artifacts)}} crates"
23-
dependsOn: ${{parameters.DependsOn}}
24-
condition: and(succeeded(), ne(variables['SetDevVersion'], 'true'), ne(variables['Skip.Release'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-rust-pr'))
25-
variables:
26-
- template: /eng/pipelines/templates/variables/globals.yml
27-
- template: /eng/pipelines/templates/variables/image.yml
28-
- template: /eng/pipelines/templates/variables/rust.yml
29-
30-
pool:
31-
name: $(LINUXPOOL)
32-
image: $(LINUXVMIMAGE)
33-
os: linux
34-
35-
jobs:
36-
- job: TagRepository
37-
displayName: "Create release tag"
38-
condition: and(succeeded(), ne(variables['Skip.TagRepository'], 'true'))
39-
40-
steps:
41-
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
42-
43-
- download: current
44-
displayName: Download ${{parameters.PipelineArtifactName}} artifact
45-
artifact: ${{parameters.PipelineArtifactName}}
46-
47-
- template: /eng/common/pipelines/templates/steps/retain-run.yml
48-
49-
- ${{ each artifact in parameters.Artifacts }}:
50-
- script: |
51-
echo "##vso[build.addbuildtag]${{artifact.name}}"
52-
displayName: Add build tag '${{artifact.name}}'
53-
54-
- template: /eng/common/pipelines/templates/steps/create-tags-and-git-release.yml
55-
parameters:
56-
ArtifactLocation: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/${{artifact.name}}
57-
PackageRepository: Crates.io
58-
ReleaseSha: $(Build.SourceVersion)
59-
WorkingDirectory: $(Pipeline.Workspace)/_work
60-
61-
- deployment: PublishPackage
62-
displayName: "Publish to Crates.io"
63-
condition: and(succeeded(), ne(variables['Skip.PublishPackage'], 'true'))
64-
templateContext:
65-
type: releaseJob # Required, this indicates this deployment job is a release job
66-
isProduction: true # Required, must be 'true' or 'false'
67-
inputs: # All input build artifacts must be declared here
68-
- input: pipelineArtifact # Required, type of the input artifact
69-
artifactName: ${{parameters.PipelineArtifactName}} # Required, name of the pipeline artifact
70-
targetPath: $(Pipeline.Workspace)/drop # Optional, specifies where the artifact is downloaded to
71-
${{if parameters.TestPipeline}}:
72-
environment: none
73-
${{else}}:
74-
environment: cratesio
75-
# This timeout shouldn't be necessary once we're able to parallelize better. Right now,
76-
# this is here to ensure larger areas (30+) libraries don't time out.
77-
timeoutInMinutes: 120
78-
dependsOn: TagRepository
21+
- ${{ if gt(length(parameters.Artifacts), 0) }}:
22+
- stage: Release_Batch
23+
displayName: "Releasing: ${{length(parameters.Artifacts)}} crates"
24+
dependsOn: ${{parameters.DependsOn}}
25+
condition: and(succeeded(), ne(variables['SetDevVersion'], 'true'), ne(variables['Skip.Release'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-rust-pr'))
26+
variables:
27+
- template: /eng/pipelines/templates/variables/globals.yml
28+
- template: /eng/pipelines/templates/variables/image.yml
29+
- template: /eng/pipelines/templates/variables/rust.yml
30+
7931
pool:
80-
name: azsdk-pool
81-
image: ubuntu-24.04
32+
name: $(LINUXPOOL)
33+
image: $(LINUXVMIMAGE)
8234
os: linux
83-
strategy:
84-
runOnce:
85-
deploy:
86-
steps:
87-
- ${{ each artifact in parameters.Artifacts }}:
88-
- pwsh: |
89-
$ArtifactName = '${{artifact.name}}'
90-
$ArtifactRootPath = '$(Pipeline.Workspace)/drop'
91-
$OutDir = '$(Pipeline.Workspace)/esrp-release'
92-
93-
if (Test-Path $OutDir) {
94-
Write-Host "Cleaning output directory: $OutDir"
95-
Remove-Item -Path $OutDir -Recurse -Force
96-
}
97-
New-Item -ItemType Directory -Path $OutDir -Force | Out-Null
98-
99-
Write-Host "Artifact name: $ArtifactName"
100-
101-
$packageMetadataPath = "$ArtifactRootPath/PackageInfo/$ArtifactName.json"
102-
if (!(Test-Path $packageMetadataPath)) {
103-
Write-Error "Package metadata file not found: $packageMetadataPath"
104-
exit 1
105-
}
106-
107-
$packageMetadata = Get-Content -Raw $packageMetadataPath | ConvertFrom-Json
108-
$packageVersion = $packageMetadata.version
109-
Write-Host "Package version: $packageVersion"
110-
111-
$cratePath = "$ArtifactRootPath/$ArtifactName/$ArtifactName-$packageVersion.crate"
112-
Copy-Item `
113-
-Path $cratePath `
114-
-Destination $OutDir
115-
Write-Host "Contents of $OutDir"
116-
Get-ChildItem -Path $OutDir | ForEach-Object { Write-Host $_.FullName }
117-
displayName: 'Copy crate for ESRP: ${{artifact.name}}'
118-
119-
- task: EsrpRelease@10
120-
displayName: 'ESRP Release: ${{artifact.name}}'
121-
inputs:
122-
connectedservicename: 'Azure SDK PME Managed Identity'
123-
ClientId: '5f81938c-2544-4f1f-9251-dd9de5b8a81b'
124-
DomainTenantId: '975f013f-7f24-47e8-a7d3-abc4752bf346'
125-
Usemanagedidentity: true
126-
KeyVaultName: 'kv-azuresdk-codesign'
127-
SignCertName: 'azure-sdk-esrp-release-certificate'
128-
intent: 'packagedistribution'
129-
contenttype: 'Rust'
130-
contentsource: 'Folder'
131-
folderlocation: '$(Pipeline.Workspace)/esrp-release'
132-
waitforreleasecompletion: true
133-
owners: ${{ coalesce(variables['Build.RequestedForEmail'], '[email protected]') }}
134-
approvers: ${{ coalesce(variables['Build.RequestedForEmail'], '[email protected]') }}
135-
serviceendpointurl: 'https://api.esrp.microsoft.com/'
136-
mainpublisher: 'ESRPRELPACMANTEST'
137-
138-
- job: UpdatePackageVersion
139-
displayName: "API Review and Package Version Update"
140-
condition: and(succeeded(), ne(variables['Skip.UpdatePackageVersion'], 'true'))
141-
dependsOn: PublishPackage
142-
steps:
143-
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
144-
parameters:
145-
paths:
146-
- "/*"
147-
148-
- template: /eng/pipelines/templates/steps/use-rust.yml@self
149-
parameters:
150-
Toolchain: nightly
151-
152-
- download: current
153-
displayName: Download ${{parameters.PipelineArtifactName}} artifact
154-
artifact: ${{parameters.PipelineArtifactName}}
155-
156-
- ${{each artifact in parameters.Artifacts }}:
157-
- template: /eng/common/pipelines/templates/steps/create-apireview.yml
35+
36+
jobs:
37+
- job: TagRepository
38+
displayName: "Create release tag"
39+
condition: and(succeeded(), ne(variables['Skip.TagRepository'], 'true'))
40+
41+
steps:
42+
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
43+
44+
- download: current
45+
displayName: Download ${{parameters.PipelineArtifactName}} artifact
46+
artifact: ${{parameters.PipelineArtifactName}}
47+
48+
- template: /eng/common/pipelines/templates/steps/retain-run.yml
49+
50+
- ${{ each artifact in parameters.Artifacts }}:
51+
- script: |
52+
echo "##vso[build.addbuildtag]${{artifact.name}}"
53+
displayName: Add build tag '${{artifact.name}}'
54+
55+
- template: /eng/common/pipelines/templates/steps/create-tags-and-git-release.yml
56+
parameters:
57+
ArtifactLocation: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/${{artifact.name}}
58+
PackageRepository: Crates.io
59+
ReleaseSha: $(Build.SourceVersion)
60+
WorkingDirectory: $(Pipeline.Workspace)/_work
61+
62+
- deployment: PublishPackage
63+
displayName: "Publish to Crates.io"
64+
condition: and(succeeded(), ne(variables['Skip.PublishPackage'], 'true'))
65+
templateContext:
66+
type: releaseJob # Required, this indicates this deployment job is a release job
67+
isProduction: true # Required, must be 'true' or 'false'
68+
inputs: # All input build artifacts must be declared here
69+
- input: pipelineArtifact # Required, type of the input artifact
70+
artifactName: ${{parameters.PipelineArtifactName}} # Required, name of the pipeline artifact
71+
targetPath: $(Pipeline.Workspace)/drop # Optional, specifies where the artifact is downloaded to
72+
${{if parameters.TestPipeline}}:
73+
environment: none
74+
${{else}}:
75+
environment: cratesio
76+
# This timeout shouldn't be necessary once we're able to parallelize better. Right now,
77+
# this is here to ensure larger areas (30+) libraries don't time out.
78+
timeoutInMinutes: 120
79+
dependsOn: TagRepository
80+
pool:
81+
name: azsdk-pool
82+
image: ubuntu-24.04
83+
os: linux
84+
strategy:
85+
runOnce:
86+
deploy:
87+
steps:
88+
- ${{ each artifact in parameters.Artifacts }}:
89+
- pwsh: |
90+
$ArtifactName = '${{artifact.name}}'
91+
$ArtifactRootPath = '$(Pipeline.Workspace)/drop'
92+
$OutDir = '$(Pipeline.Workspace)/esrp-release'
93+
94+
if (Test-Path $OutDir) {
95+
Write-Host "Cleaning output directory: $OutDir"
96+
Remove-Item -Path $OutDir -Recurse -Force
97+
}
98+
New-Item -ItemType Directory -Path $OutDir -Force | Out-Null
99+
100+
Write-Host "Artifact name: $ArtifactName"
101+
102+
$packageMetadataPath = "$ArtifactRootPath/PackageInfo/$ArtifactName.json"
103+
if (!(Test-Path $packageMetadataPath)) {
104+
Write-Error "Package metadata file not found: $packageMetadataPath"
105+
exit 1
106+
}
107+
108+
$packageMetadata = Get-Content -Raw $packageMetadataPath | ConvertFrom-Json
109+
$packageVersion = $packageMetadata.version
110+
Write-Host "Package version: $packageVersion"
111+
112+
$cratePath = "$ArtifactRootPath/$ArtifactName/$ArtifactName-$packageVersion.crate"
113+
Copy-Item `
114+
-Path $cratePath `
115+
-Destination $OutDir
116+
Write-Host "Contents of $OutDir"
117+
Get-ChildItem -Path $OutDir | ForEach-Object { Write-Host $_.FullName }
118+
displayName: 'Copy crate for ESRP: ${{artifact.name}}'
119+
120+
- task: EsrpRelease@10
121+
displayName: 'ESRP Release: ${{artifact.name}}'
122+
inputs:
123+
connectedservicename: 'Azure SDK PME Managed Identity'
124+
ClientId: '5f81938c-2544-4f1f-9251-dd9de5b8a81b'
125+
DomainTenantId: '975f013f-7f24-47e8-a7d3-abc4752bf346'
126+
Usemanagedidentity: true
127+
KeyVaultName: 'kv-azuresdk-codesign'
128+
SignCertName: 'azure-sdk-esrp-release-certificate'
129+
intent: 'packagedistribution'
130+
contenttype: 'Rust'
131+
contentsource: 'Folder'
132+
folderlocation: '$(Pipeline.Workspace)/esrp-release'
133+
waitforreleasecompletion: true
134+
owners: ${{ coalesce(variables['Build.RequestedForEmail'], '[email protected]') }}
135+
approvers: ${{ coalesce(variables['Build.RequestedForEmail'], '[email protected]') }}
136+
serviceendpointurl: 'https://api.esrp.microsoft.com/'
137+
mainpublisher: 'ESRPRELPACMANTEST'
138+
139+
- job: UpdatePackageVersion
140+
displayName: "API Review and Package Version Update"
141+
condition: and(succeeded(), ne(variables['Skip.UpdatePackageVersion'], 'true'))
142+
dependsOn: PublishPackage
143+
steps:
144+
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
158145
parameters:
159-
ArtifactPath: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}
160-
Artifacts: ${{parameters.Artifacts}}
161-
ConfigFileDir: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/PackageInfo
162-
MarkPackageAsShipped: true
163-
ArtifactName: ${{parameters.PipelineArtifactName}}
164-
SourceRootPath: $(System.DefaultWorkingDirectory)
165-
PackageName: ${{artifact.name}}
166-
167-
# Apply the version increment to each library, which updates the Cargo.toml and changelog files.
168-
- task: PowerShell@2
169-
displayName: Increment ${{artifact.name}} version
170-
inputs:
171-
targetType: filePath
172-
filePath: $(Build.SourcesDirectory)/eng/scripts/Update-PackageVersion.ps1
173-
arguments: >
174-
-ServiceDirectory '${{parameters.ServiceDirectory}}'
175-
-PackageName '${{artifact.name}}'
176-
177-
- template: /eng/common/pipelines/templates/steps/create-pull-request.yml
146+
paths:
147+
- "/*"
148+
149+
- template: /eng/pipelines/templates/steps/use-rust.yml@self
178150
parameters:
179-
PRBranchName: increment-package-version-${{parameters.ServiceDirectory}}-$(Build.BuildId)
180-
CommitMsg: "Increment package version after release of ${{ artifact.name }}"
181-
PRTitle: "Increment versions for ${{parameters.ServiceDirectory}} releases"
182-
CloseAfterOpenForTesting: '${{parameters.TestPipeline}}'
183-
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
184-
BaseBranchName: main
151+
Toolchain: nightly
152+
153+
- download: current
154+
displayName: Download ${{parameters.PipelineArtifactName}} artifact
155+
artifact: ${{parameters.PipelineArtifactName}}
156+
157+
- ${{each artifact in parameters.Artifacts }}:
158+
- template: /eng/common/pipelines/templates/steps/create-apireview.yml
159+
parameters:
160+
ArtifactPath: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}
161+
Artifacts: ${{parameters.Artifacts}}
162+
ConfigFileDir: $(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/PackageInfo
163+
MarkPackageAsShipped: true
164+
ArtifactName: ${{parameters.PipelineArtifactName}}
165+
SourceRootPath: $(System.DefaultWorkingDirectory)
166+
PackageName: ${{artifact.name}}
167+
168+
# Apply the version increment to each library, which updates the Cargo.toml and changelog files.
169+
- task: PowerShell@2
170+
displayName: Increment ${{artifact.name}} version
171+
inputs:
172+
targetType: filePath
173+
filePath: $(Build.SourcesDirectory)/eng/scripts/Update-PackageVersion.ps1
174+
arguments: >
175+
-ServiceDirectory '${{parameters.ServiceDirectory}}'
176+
-PackageName '${{artifact.name}}'
177+
178+
- template: /eng/common/pipelines/templates/steps/create-pull-request.yml
179+
parameters:
180+
PRBranchName: increment-package-version-${{parameters.ServiceDirectory}}-$(Build.BuildId)
181+
CommitMsg: "Increment package version after release of ${{ artifact.name }}"
182+
PRTitle: "Increment versions for ${{parameters.ServiceDirectory}} releases"
183+
CloseAfterOpenForTesting: '${{parameters.TestPipeline}}'
184+
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
185+
BaseBranchName: main

0 commit comments

Comments
 (0)