File: release-pypi.yml

package info (click to toggle)
lsprotocol 2025.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,408 kB
  • sloc: python: 7,567; cs: 1,225; sh: 15; makefile: 4
file content (180 lines) | stat: -rw-r--r-- 6,453 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Release
trigger: none
pr: none

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

parameters:
  - name: publishPackage
    displayName: 🚀 Publish Package
    type: boolean
    default: false

variables:
  ARTIFACT_NAME_WHEEL: wheel
  architecture: x64
  python.version: '3.8'
  TeamName: lsprotocol

extends:
  template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate
  parameters:
    sdl:
      sourceAnalysisPool: VSEngSS-MicroBuild2022-1ES
    pool:
      name: AzurePipelines-EO
      demands:
        - ImageOverride -equals 1ESPT-Ubuntu22.04
      os: Linux
    customBuildTags:
      - ES365AIMigrationTooling
    stages:
      - stage: Build
        displayName: Build
        jobs:
          - job: Build

            templateContext:
              outputs:
                - output: pipelineArtifact
                  targetPath: $(Build.StagingDirectory)/dist
                  sbomBuildDropPath: $(Build.StagingDirectory)/dist
                  artifactName: $(ARTIFACT_NAME_WHEEL)

            steps:
              - checkout: self
                fetchDepth: 1
                fetchTags: false

              - task: UsePythonVersion@0
                inputs:
                  versionSpec: '$(python.version)'
                  architecture: '$(architecture)'
                displayName: 'Use Python $(python.version) $(architecture)'

              - script: python -m pip install nox
                displayName: Install nox

              - script: python -m nox --session build_python_package
                displayName: Build package (sdist and wheels)

              - powershell: |
                  python -m pip install toml-cli
                  $releaseVersion = & toml get --toml-path packages/python/pyproject.toml project.version
                  echo "releaseVersion: $releaseVersion"
                  echo "##vso[task.setvariable variable=releaseVersion;isOutput=true]$releaseVersion"
                displayName: Get release version
                name: getReleaseVersionStep

              - script: ls -al packages/python/dist

              - task: CopyFiles@2
                displayName: Copy wheel and tarball
                inputs:
                  sourceFolder: packages/python/dist
                  targetFolder: $(Build.StagingDirectory)/dist
                  contents: |
                    lsprotocol-$(getReleaseVersionStep.releaseVersion)-py3-none-any.whl
                    lsprotocol-$(getReleaseVersionStep.releaseVersion).tar.gz

      - stage: CreateTag
        displayName: Create Tag
        dependsOn: Build
        variables:
          releaseVersion: $[ stageDependencies.Build.Build.outputs['getReleaseVersionStep.releaseVersion'] ]
        jobs:
          - job: CreateTag
            steps:
              - checkout: self
                fetchDepth: 1
                fetchTags: false
                persistCredentials: true

              - script: |
                  git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
                  git config user.name "Azure Piplines"
                  git fetch --depth 1 origin $(Build.SourceBranchName)
                  git tag -a $(releaseVersion) -m "Release $(releaseVersion)" origin/$(Build.SourceBranchName)
                  git push origin $(releaseVersion)
                displayName: Create git tag

      - stage: CreateRelease
        displayName: Create GitHub Release
        dependsOn:
          - Build
          - CreateTag
        variables:
          releaseVersion: $[ stageDependencies.Build.Build.outputs['getReleaseVersionStep.releaseVersion'] ]
        jobs:
          - job: CreateRelease
            templateContext:
              type: releaseJob
              isProduction: true
              inputs:
                - input: pipelineArtifact
                  artifactName: $(ARTIFACT_NAME_WHEEL)
                  targetPath: $(Build.StagingDirectory)/dist
            steps:
              - task: GitHubRelease@1 #https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/github-release-v1?view=azure-pipelines
                displayName: Create GitHub Release
                inputs:
                  gitHubConnection: GitHub-lsprotocol
                  repositoryName: microsoft/lsprotocol
                  action: create
                  target: $(Build.SourceBranchName)
                  title: $(releaseVersion)
                  tag: $(releaseVersion)
                  tagSource: userSpecifiedTag
                  isDraft: true
                  addChangeLog: false
                  assets: $(Build.StagingDirectory)/dist/*

      - stage: WaitForValidation
        dependsOn: CreateRelease
        condition: and(succeeded(), ${{ parameters.publishPackage }})
        jobs:
          - job: wait_for_validation
            displayName: Wait for manual validation
            pool: server
            steps:
              - task: ManualValidation@0
                timeoutInMinutes: 1440 # task times out in 1 day
                inputs:
                  notifyUsers: erikd@microsoft.com
                  instructions: Please test the latest draft release and then publish it.
                  onTimeout: reject

      - stage: Release
        dependsOn: WaitForValidation
        jobs:
          - job: PublishToPyPi
            displayName: Release to PyPi

            pool:
              name: VSEngSS-MicroBuild2022-1ES # This pool is required to have the certs needed to publish to PyPi using ESRP.
              os: windows
              image: server2022-microbuildVS2022-1es

            templateContext:
              type: releaseJob
              isProduction: true
              inputs:
                - input: pipelineArtifact
                  artifactName: $(ARTIFACT_NAME_WHEEL)
                  targetPath: $(Build.StagingDirectory)/dist

            steps:
              - template: MicroBuild.Publish.yml@MicroBuildTemplate
                parameters:
                  intent: PackageDistribution
                  contentType: PyPi
                  contentSource: Folder
                  folderLocation: $(Build.StagingDirectory)/dist
                  waitForReleaseCompletion: true
                  owners: erikd@microsoft.com
                  approvers: grwheele@microsoft.com