@@ -98,8 +98,10 @@ extends:
98
98
99
99
- ${{ parameters.InitializationSteps }}
100
100
101
+ # Initialize-WorkingDirectory.ps1 is responsible for setting the emitterVersion output variable.
101
102
- task : PowerShell@2
102
103
displayName : ' Run initialize script'
104
+ name : initialize
103
105
inputs :
104
106
pwsh : true
105
107
filePath : $(Build.SourcesDirectory)/eng/scripts/typespec/Initialize-WorkingDirectory.ps1
@@ -117,7 +119,6 @@ extends:
117
119
118
120
- task : PowerShell@2
119
121
displayName : ' Run build script'
120
- name : ci_build
121
122
inputs :
122
123
pwsh : true
123
124
filePath : $(Build.SourcesDirectory)/eng/scripts/typespec/Build-Emitter.ps1
@@ -150,10 +151,7 @@ extends:
150
151
artifactPath : $(Build.ArtifactStagingDirectory)
151
152
152
153
# Publish stage
153
- # Responsible for publishing the packages in `build_artifacts/packages` and producing `emitter-package-lock.json`
154
- # Produces the artifact `publish_artifacts` which contains the following:
155
- # emitter-package.json: Created using the package json from the build step.
156
- # emitter-package-lock.json: Created by calling `npm install` using `emitter-package.json`
154
+ # Responsible for publishing the packages in `build_artifacts/packages`
157
155
- ${{ if parameters.ShouldPublish }} :
158
156
- stage : Publish
159
157
dependsOn :
@@ -207,36 +205,6 @@ extends:
207
205
ServiceEndpointUrl : https://api.esrp.microsoft.com
208
206
MainPublisher : ESRPRELPACMANTEST
209
207
210
- - pwsh : |
211
- npm install -g @azure-tools/typespec-client-generator-cli@latest
212
- displayName: Install tsp-client
213
-
214
- - pwsh : |
215
- Write-Host "Overrides location: $(buildArtifactsPath)/packages/overrides.json"
216
-
217
- if (Test-Path -Path '$(buildArtifactsPath)/packages/overrides.json') {
218
- Write-Host "Using overrides.json to generate emitter-package.json"
219
- tsp-client generate-config-files `
220
- --package-json '$(buildArtifactsPath)/lock-files/package.json' `
221
- --output-dir '$(Build.SourcesDirectory)' `
222
- --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}' `
223
- --overrides '$(buildArtifactsPath)/packages/overrides.json'
224
- } else {
225
- Write-Host "No overrides.json found. Running tsp-client without overrides."
226
-
227
- tsp-client generate-config-files `
228
- --package-json '$(buildArtifactsPath)/lock-files/package.json' `
229
- --output-dir '$(Build.SourcesDirectory)' `
230
- --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}'
231
- }
232
- displayName: Generate emitter-package.json and emitter-package-lock files
233
- workingDirectory: $(Build.SourcesDirectory)
234
-
235
- - template : /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
236
- parameters :
237
- artifactName : publish_artifacts
238
- artifactPath : $(Build.ArtifactStagingDirectory)
239
-
240
208
# Regenerate stage
241
209
# Responsible for regenerating the SDK code using the emitter package and the generation matrix.
242
210
- ${{ if and(parameters.ShouldPublish, parameters.ShouldRegenerate) }} :
@@ -246,7 +214,7 @@ extends:
246
214
- Publish
247
215
variables :
248
216
pullRequestTargetBranch : ' main'
249
- publishArtifactsPath : $(Pipeline.Workspace)/publish_artifacts
217
+ buildArtifactsPath : $(Pipeline.Workspace)/build_artifacts
250
218
branchName : $[stageDependencies.Build.Build.outputs['set_branch_name.branchName']]
251
219
pool : ${{ parameters.Pool }}
252
220
jobs :
@@ -262,9 +230,27 @@ extends:
262
230
displayName : Download pipeline artifacts
263
231
264
232
- pwsh : |
265
- Write-Host "Copying *emitter-package*.json to $(Build.SourcesDirectory)/eng"
266
- Copy-Item $(publishArtifactsPath)/*emitter-package*.json $(Build.SourcesDirectory)/eng/ -Force
267
- displayName: Copy emitter-package json files
233
+ npm install -g @azure-tools/typespec-client-generator-cli@latest
234
+ displayName: Install tsp-client
235
+
236
+ - pwsh : |
237
+ Write-Host "Overrides location: $(buildArtifactsPath)/packages/overrides.json"
238
+
239
+ if (Test-Path -Path '$(buildArtifactsPath)/packages/overrides.json') {
240
+ Write-Host "Using overrides.json to generate emitter-package.json"
241
+ tsp-client generate-config-files `
242
+ --package-json '$(buildArtifactsPath)/lock-files/package.json' `
243
+ --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}' `
244
+ --overrides '$(buildArtifactsPath)/packages/overrides.json'
245
+ } else {
246
+ Write-Host "No overrides.json found. Running tsp-client without overrides."
247
+
248
+ tsp-client generate-config-files `
249
+ --package-json '$(buildArtifactsPath)/lock-files/package.json' `
250
+ --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}'
251
+ }
252
+ displayName: Generate emitter-package.json and emitter-package-lock files
253
+ workingDirectory: $(Build.SourcesDirectory)
268
254
269
255
- ${{ parameters.InitializationSteps }}
270
256
@@ -341,7 +327,7 @@ extends:
341
327
- Generate
342
328
variables :
343
329
generateJobResult : $[dependencies.Generate.result]
344
- emitterVersion : $[stageDependencies.Build.Build.outputs['ci_build .emitterVersion']]
330
+ emitterVersion : $[stageDependencies.Build.Build.outputs['initialize .emitterVersion']]
345
331
steps :
346
332
- template : /eng/common/pipelines/templates/steps/sparse-checkout.yml
347
333
@@ -401,6 +387,16 @@ extends:
401
387
} else {
402
388
Write-Error "Build.Repository.Name not in the expected {Owner}/{Name} format"
403
389
}
390
+
391
+ $openAsDraft = -not ($reason -eq 'IndividualCI' -and $sourceBranch -eq 'refs/heads/main')
392
+ Write-Host "Setting OpenAsDraftBool = $openAsDraft"
393
+ Write-Host "##vso[task.setvariable variable=OpenAsDraft]$openAsDraft"
394
+ if ($openAsDraft) {
395
+ Write-Host "##vso[task.setvariable variable=PRLabels]Do Not Merge"
396
+ } else {
397
+ Write-Host "##vso[task.setvariable variable=PRLabels]"
398
+ }
399
+
404
400
displayName: Get PR title and body
405
401
406
402
- task : PowerShell@2
@@ -417,8 +413,8 @@ extends:
417
413
-AuthToken '$(azuresdk-github-pat)'
418
414
-PRTitle '$(PullRequestTitle)'
419
415
-PRBody '$(PullRequestBody)'
420
- -OpenAsDraft $true
421
- -PRLabels 'Do Not Merge '
416
+ -OpenAsDraft $$(OpenAsDraft)
417
+ -PRLabels '$(PRLabels) '
422
418
workingDirectory : $(Build.SourcesDirectory)
423
419
424
420
# Test stage
0 commit comments