|
| 1 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +# Build, package, and deploy msgraph-sdk-python to PyPI. |
| 5 | + |
| 6 | +name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) |
| 7 | + |
| 8 | +trigger: |
| 9 | + tags: |
| 10 | + include: |
| 11 | + - v* |
| 12 | + |
| 13 | +pr: none |
| 14 | + |
| 15 | +variables: |
| 16 | + pythonVersion: '3.14' |
| 17 | + |
| 18 | +resources: |
| 19 | + repositories: |
| 20 | + - repository: 1ESPipelineTemplates |
| 21 | + type: git |
| 22 | + name: 1ESPipelineTemplates/1ESPipelineTemplates |
| 23 | + ref: refs/tags/release |
| 24 | + |
| 25 | +extends: |
| 26 | + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates |
| 27 | + parameters: |
| 28 | + pool: |
| 29 | + name: Azure-Pipelines-1ESPT-ExDShared |
| 30 | + image: ubuntu-latest |
| 31 | + os: linux |
| 32 | + sdl: |
| 33 | + sourceAnalysisPool: |
| 34 | + name: Azure-Pipelines-1ESPT-ExDShared |
| 35 | + image: windows-2022 |
| 36 | + os: windows |
| 37 | + stages: |
| 38 | + - stage: build |
| 39 | + displayName: Build and Package msgraph-sdk-python |
| 40 | + condition: or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.Reason'], 'Manual')) |
| 41 | + jobs: |
| 42 | + - job: build_python |
| 43 | + displayName: Build and Package |
| 44 | + pool: |
| 45 | + name: Azure-Pipelines-1ESPT-ExDShared |
| 46 | + image: ubuntu-latest |
| 47 | + os: linux |
| 48 | + steps: |
| 49 | + - checkout: self |
| 50 | + |
| 51 | + - task: UsePythonVersion@0 |
| 52 | + displayName: Install Python $(pythonVersion) |
| 53 | + inputs: |
| 54 | + versionSpec: $(pythonVersion) |
| 55 | + addToPath: true |
| 56 | + |
| 57 | + - script: python -m pip install --upgrade pip |
| 58 | + displayName: Upgrade pip |
| 59 | + |
| 60 | + - task: PipAuthenticate@1 |
| 61 | + displayName: "Authenticate pip to Azure Artifacts" |
| 62 | + inputs: |
| 63 | + artifactFeeds: "$(System.TeamProject)/GraphDeveloperExperiences_Public" |
| 64 | + |
| 65 | + - script: pip install -r requirements-dev.txt |
| 66 | + displayName: Install dependencies |
| 67 | + |
| 68 | + - script: pylint msgraph --disable=W --rcfile=.pylintrc |
| 69 | + displayName: Lint with Pylint |
| 70 | + |
| 71 | + - script: python -m build |
| 72 | + displayName: Build package artifacts |
| 73 | + |
| 74 | + - task: CopyFiles@2 |
| 75 | + displayName: Copy package artifacts to staging |
| 76 | + inputs: |
| 77 | + CleanTargetFolder: true |
| 78 | + sourceFolder: $(Build.SourcesDirectory) |
| 79 | + targetFolder: $(Build.ArtifactStagingDirectory)/python/msgraph_sdk |
| 80 | + Contents: | |
| 81 | + dist/*.tar.gz |
| 82 | + dist/*.whl |
| 83 | + flattenFolders: true |
| 84 | + |
| 85 | + templateContext: |
| 86 | + outputs: |
| 87 | + - output: pipelineArtifact |
| 88 | + displayName: Stage msgraph-sdk package artifacts |
| 89 | + artifactName: pypi_msgraph_sdk_package |
| 90 | + targetPath: $(Build.ArtifactStagingDirectory)/python/msgraph_sdk |
| 91 | + condition: or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.Reason'], 'Manual')) |
| 92 | + |
| 93 | + - stage: deploy |
| 94 | + displayName: Publish msgraph-sdk-python to PyPI |
| 95 | + dependsOn: build |
| 96 | + condition: or(and(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), succeeded()), eq(variables['Build.Reason'], 'Manual')) |
| 97 | + jobs: |
| 98 | + - deployment: publish_python_package |
| 99 | + displayName: Publish msgraph-sdk package |
| 100 | + environment: pypi_prod |
| 101 | + pool: |
| 102 | + name: Azure-Pipelines-1ESPT-ExDShared |
| 103 | + image: ubuntu-latest |
| 104 | + os: linux |
| 105 | + templateContext: |
| 106 | + type: releaseJob |
| 107 | + isProduction: true |
| 108 | + inputs: |
| 109 | + - input: pipelineArtifact |
| 110 | + artifactName: pypi_msgraph_sdk_package |
| 111 | + targetPath: $(Build.ArtifactStagingDirectory)/python |
| 112 | + strategy: |
| 113 | + runOnce: |
| 114 | + deploy: |
| 115 | + steps: |
| 116 | + - task: EsrpRelease@9 |
| 117 | + displayName: Publish msgraph-sdk package via ESRP Release |
| 118 | + inputs: |
| 119 | + connectedservicename: Federated DevX ESRP Managed Identity Connection |
| 120 | + usemanagedidentity: false |
| 121 | + keyvaultname: akv-prod-eastus |
| 122 | + authcertname: ReferenceLibraryPrivateCert |
| 123 | + signcertname: ReferencePackagePublisherCertificate |
| 124 | + clientid: 65035b7f-7357-4f29-bf25-c5ee5c3949f8 |
| 125 | + intent: PackageDistribution |
| 126 | + contenttype: PYPI |
| 127 | + contentsource: Folder |
| 128 | + folderlocation: $(Build.ArtifactStagingDirectory)/python |
| 129 | + waitforreleasecompletion: true |
| 130 | + owners: 'mmainer@microsoft.com,gavinbarron@microsoft.com' |
| 131 | + approvers: 'mmainer@microsoft.com,christiano@microsoft.com,gavinbarron@microsoft.com' |
| 132 | + mainpublisher: ESRPRELPACMAN |
| 133 | + domaintenantid: cdc5aeea-15c5-4db6-b079-fcadd2505dc2 |
0 commit comments