|
1 | 1 | parameters: |
2 | | -- name: CondaArtifacts |
3 | | - type: object |
4 | 2 | - name: DependsOn |
5 | 3 | type: string |
6 | 4 | default: Build |
| 5 | +- name: ArtifactName |
| 6 | + type: string |
| 7 | + default: 'conda' |
7 | 8 |
|
8 | 9 | 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 |
18 | 32 |
|
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' |
22 | 40 |
|
23 | | - strategy: |
24 | | - runOnce: |
25 | | - deploy: |
26 | | - steps: |
27 | | - - checkout: self |
28 | | - - ${{ each artifact in parameters.CondaArtifacts }}: |
29 | 41 | - pwsh: | |
30 | | - Write-Host "${{ artifact.name }} is ${{ artifact.inBatch }}" |
| 42 | + Get-ChildItem -Recurse $(Pipeline.Workspace)/${{parameters.ArtifactName}} -Filter "*.conda" |
31 | 43 | 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 |
0 commit comments