Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions .azure-pipelines/cd-publish-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# Build, package, and deploy msgraph-sdk-python-core to PyPI.

name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)

trigger:
branches:
include:
- main
tags:
include:
- "v*"

pr: none

variables:
pythonVersion: "3.14"

resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
sdl:
sourceAnalysisPool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-2022
os: windows
stages:
- stage: build
displayName: "Build and Package msgraph-sdk-python-core"
condition: or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.Reason'], 'Manual'))
jobs:
- job: build_python
displayName: "Build, Test, and Package"
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
steps:
- checkout: self

- task: UsePythonVersion@0
displayName: "Install Python $(pythonVersion)"
inputs:
versionSpec: "$(pythonVersion)"
addToPath: true

- script: python -m pip install --upgrade pip
displayName: "Upgrade pip"

- task: PipAuthenticate@1
displayName: "Authenticate pip to Azure Artifacts"
inputs:
artifactFeeds: "$(System.TeamProject)/msgraph-python-dev"

- script: pip install -r requirements-dev.txt
displayName: "Install dependencies"

- script: yapf -dr src
displayName: "Check code format"

- script: isort src
displayName: "Check import order"

- script: mypy src
displayName: "Static type checking with Mypy"

- script: pylint src --disable=W --rcfile=.pylintrc
displayName: "Lint with Pylint"

- script: pytest
displayName: "Run unit tests"

- script: pip install build
displayName: "Install package builder"

- script: python -m build
displayName: "Build package artifacts"

- task: CopyFiles@2
displayName: "Copy package artifacts to staging"
inputs:
CleanTargetFolder: true
sourceFolder: "$(Build.SourcesDirectory)"
targetFolder: "$(Build.ArtifactStagingDirectory)/python/msgraph_core"
Contents: |
dist/*.tar.gz
dist/*.whl
flattenFolders: true

templateContext:
outputs:
- output: pipelineArtifact
displayName: "Stage msgraph-core package artifacts"
artifactName: pypi_msgraph_core_package
targetPath: "$(Build.ArtifactStagingDirectory)/python/msgraph_core"
condition: or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.Reason'], 'Manual'))

- stage: deploy
displayName: "Publish msgraph-sdk-python-core to PyPI"
dependsOn: build
condition: or(and(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), succeeded()), eq(variables['Build.Reason'], 'Manual'))
jobs:
- deployment: publish_python_package
displayName: "Publish msgraph-core package"
environment: pypi_prod
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
templateContext:
type: releaseJob
isProduction: true
inputs:
- input: pipelineArtifact
artifactName: pypi_msgraph_core_package
targetPath: "$(Build.ArtifactStagingDirectory)/python"
strategy:
runOnce:
deploy:
steps:
- task: EsrpRelease@9
displayName: "Publish msgraph-core package via ESRP Release"
inputs:
connectedservicename: "Federated DevX ESRP Managed Identity Connection"
usemanagedidentity: false
keyvaultname: "akv-prod-eastus"
authcertname: "ReferenceLibraryPrivateCert"
signcertname: "ReferencePackagePublisherCertificate"
clientid: "65035b7f-7357-4f29-bf25-c5ee5c3949f8"
intent: "PackageDistribution"
contenttype: "PYPI"
contentsource: "Folder"
folderlocation: "$(Build.ArtifactStagingDirectory)/python"
waitforreleasecompletion: true
owners: "graphtooling+python@microsoft.com"
approvers: "graphtooling+python@microsoft.com"
serviceendpointurl: "https://api.esrp.microsoft.com"
mainpublisher: "ESRPRELPACMAN"
domaintenantid: "cdc5aeea-15c5-4db6-b079-fcadd2505dc2"
35 changes: 0 additions & 35 deletions .github/workflows/publish.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
"python.testing.pytestEnabled": true,
"azure-pipelines.1ESPipelineTemplatesSchemaFile": true
}
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ coverage[toml]==7.10.6 ; python_version >= '3.7'

cryptography==46.0.7 ; python_version >= '3.7'

dill==0.4.0 ; python_version < '3.11'
dill==0.4.0

exceptiongroup==1.3.0 ; python_version < '3.11'

Expand Down Expand Up @@ -116,7 +116,7 @@ urllib3==2.7.0 ; python_version >= '3.7'
typing-extensions==4.15.0 ; python_version >= '3.7'


wrapt==1.17.3 ; python_version < '3.11'
wrapt==1.17.3

yapf==0.43.0

Expand Down
Loading