Skip to content

Commit 380b5a4

Browse files
authored
Add Conda publishing to Conda build pipeline (#44944)
1 parent 3bdfb63 commit 380b5a4

File tree

2 files changed

+88
-22
lines changed

2 files changed

+88
-22
lines changed
Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,74 @@
11
parameters:
2-
- name: CondaArtifacts
3-
type: object
42
- name: DependsOn
53
type: string
64
default: Build
5+
- name: ArtifactName
6+
type: string
7+
default: 'conda'
78

89
stages:
9-
# - ${{if and(eq(variables['Build.Reason'], 'Manual'), eq(variables['System.TeamProject'], 'internal'))}}:
10-
- stage: Release
11-
displayName: 'Conda Release'
12-
dependsOn: ${{parameters.DependsOn}}
13-
condition: and(succeeded(), ne(variables['SetDevVersion'], 'true'), ne(variables['Skip.Release'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-python-pr'))
14-
jobs:
15-
- deployment: CondaRelease
16-
displayName: "Publish Conda Artifact"
17-
# environment: pypi
10+
- ${{if and(in(variables['Build.Reason'], 'Manual', ''), eq(variables['System.TeamProject'], 'internal'))}}:
11+
- stage: Release_Conda
12+
displayName: 'Release Conda Packages'
13+
dependsOn: ${{parameters.DependsOn}}
14+
condition: and(succeeded(), ne(variables['SetDevVersion'], 'true'), ne(variables['Skip.Release'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-python-pr'))
15+
jobs:
16+
- deployment: PublishCondaPackages
17+
displayName: "Publish Conda Packages to Anaconda"
18+
environment: package-publish
19+
20+
templateContext:
21+
type: releaseJob
22+
isProduction: true
23+
inputs:
24+
- input: pipelineArtifact
25+
artifactName: ${{parameters.ArtifactName}}
26+
targetPath: $(Pipeline.Workspace)/${{parameters.ArtifactName}}
27+
28+
pool:
29+
name: azsdk-pool
30+
image: ubuntu-24.04
31+
os: linux
1832

19-
pool:
20-
name: 'azsdk-pool'
21-
demands: ImageOverride -equals 'ubuntu-24.04'
33+
strategy:
34+
runOnce:
35+
deploy:
36+
steps:
37+
- task: UsePythonVersion@0
38+
inputs:
39+
versionSpec: '3.12'
2240

23-
strategy:
24-
runOnce:
25-
deploy:
26-
steps:
27-
- checkout: self
28-
- ${{ each artifact in parameters.CondaArtifacts }}:
2941
- pwsh: |
30-
Write-Host "${{ artifact.name }} is ${{ artifact.inBatch }}"
42+
Get-ChildItem -Recurse $(Pipeline.Workspace)/${{parameters.ArtifactName}} -Filter "*.conda"
3143
workingDirectory: $(Pipeline.Workspace)
32-
displayName: Output Visible Conda Artifact
44+
displayName: Output Visible Conda Artifacts
45+
46+
- script: |
47+
set -e
48+
python -m pip install anaconda-client
49+
displayName: Install anaconda-client
50+
51+
- pwsh: |
52+
$packages = Get-ChildItem -Path "$(Pipeline.Workspace)/${{parameters.ArtifactName}}/noarch" -Filter "*.conda"
53+
foreach ($package in $packages) {
54+
Write-Host "Uploading: $($package.FullName)"
55+
$success = $false
56+
for ($attempt = 1; $attempt -le 3; $attempt++) {
57+
anaconda upload --user $env:CONDA_USERNAME --skip-existing $package.FullName
58+
if ($LASTEXITCODE -eq 0) {
59+
$success = $true
60+
break
61+
}
62+
Write-Host "Attempt $attempt failed, retrying..."
63+
Start-Sleep -Seconds 5
64+
}
65+
if (-not $success) {
66+
Write-Error "Failed to upload $($package.Name) after 3 attempts"
67+
exit 1
68+
}
69+
}
70+
Write-Host "Uploaded all conda packages to Anaconda"
71+
displayName: 'Publish all Conda packages to Anaconda'
72+
env:
73+
ANACONDA_API_TOKEN: $(conda-release-apikey)
74+
CONDA_USERNAME: Microsoft

eng/pipelines/templates/stages/conda-sdk-client.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
trigger:
2+
branches:
3+
include:
4+
- main
5+
paths:
6+
include:
7+
- conda/conda-recipes/**
8+
- conda/conda-releaselogs/**
9+
- eng/pipelines/templates/stages/conda-sdk-client.yml
10+
pr:
11+
branches:
12+
include:
13+
- main
14+
paths:
15+
include:
16+
- conda/conda-recipes/**
17+
- conda/conda-releaselogs/**
18+
- eng/pipelines/templates/stages/conda-sdk-client.yml
19+
120
parameters:
221
- name: release_msal
322
displayName: 'msal'
@@ -905,3 +924,8 @@ extends:
905924
version: 1.0.0
906925
- package: azure-mgmt-workloadssapvirtualinstance
907926
version: 1.0.0
927+
928+
- template: /eng/pipelines/templates/stages/archetype-conda-release.yml@self
929+
parameters:
930+
DependsOn: Build_Universal_Dependencies
931+
ArtifactName: conda

0 commit comments

Comments
 (0)