@@ -67,9 +67,14 @@ parameters:
67
67
type : object
68
68
default : []
69
69
70
- - name : EmitterPackageJsonPath
70
+ # The path to the emitter package json file.
71
+ - name : EmitterPackageJsonOutputPath
72
+ type : string
73
+ default : " eng/emitter-package.json"
74
+
75
+ # The relative path to the emitter package.
76
+ - name : EmitterPackagePath
71
77
type : string
72
- default : " "
73
78
74
79
extends :
75
80
template : /eng/pipelines/templates/stages/1es-redirect.yml
@@ -93,24 +98,34 @@ extends:
93
98
94
99
- ${{ parameters.InitializationSteps }}
95
100
101
+ # Initialize-WorkingDirectory.ps1 is responsible for setting the emitterVersion output variable.
96
102
- task : PowerShell@2
97
103
displayName : ' Run initialize script'
104
+ name : initialize
98
105
inputs :
99
106
pwsh : true
100
107
filePath : $(Build.SourcesDirectory)/eng/scripts/typespec/Initialize-WorkingDirectory.ps1
101
- arguments : -UseTypeSpecNext:$${{ parameters.UseTypeSpecNext }}
108
+ ${{ if parameters.BuildPrereleaseVersion }} :
109
+ arguments : >
110
+ -PrereleaseSuffix "-alpha.$(Build.BuildNumber)"
111
+ -OutputDirectory "$(Build.ArtifactStagingDirectory)"
112
+ -UseTypeSpecNext:$${{ parameters.UseTypeSpecNext }}
113
+ -EmitterPackagePath:${{ parameters.EmitterPackagePath }}
114
+ ${{ else }} :
115
+ arguments : >
116
+ -OutputDirectory "$(Build.ArtifactStagingDirectory)"
117
+ -UseTypeSpecNext:$${{ parameters.UseTypeSpecNext }}
118
+ -EmitterPackagePath:${{ parameters.EmitterPackagePath }}
102
119
103
120
- task : PowerShell@2
104
121
displayName : ' Run build script'
105
- name : ci_build
106
122
inputs :
107
123
pwsh : true
108
124
filePath : $(Build.SourcesDirectory)/eng/scripts/typespec/Build-Emitter.ps1
109
125
arguments : >
110
- -BuildNumber "$(Build.BuildNumber)"
111
- -OutputDirectory "$(Build.ArtifactStagingDirectory)"
126
+ -OutputDirectory "$(Build.ArtifactStagingDirectory)/packages"
112
127
-TargetNpmJsFeed:$${{ parameters.PublishPublic }}
113
- -Prerelease:$$ {{ parameters.BuildPrereleaseVersion }}
128
+ -EmitterPackagePath:$ {{ parameters.EmitterPackagePath }}
114
129
115
130
- pwsh : |
116
131
$sourceBranch = '$(Build.SourceBranch)'
@@ -136,10 +151,7 @@ extends:
136
151
artifactPath : $(Build.ArtifactStagingDirectory)
137
152
138
153
# Publish stage
139
- # Responsible for publishing the packages in `build_artifacts/packages` and producing `emitter-package-lock.json`
140
- # Produces the artifact `publish_artifacts` which contains the following:
141
- # emitter-package.json: Created using the package json from the build step.
142
- # emitter-package-lock.json: Created by calling `npm install` using `emitter-package.json`
154
+ # Responsible for publishing the packages in `build_artifacts/packages`
143
155
- ${{ if parameters.ShouldPublish }} :
144
156
- stage : Publish
145
157
dependsOn :
@@ -193,31 +205,6 @@ extends:
193
205
ServiceEndpointUrl : https://api.esrp.microsoft.com
194
206
MainPublisher : ESRPRELPACMANTEST
195
207
196
- - pwsh : |
197
- npm install -g @azure-tools/typespec-client-generator-cli@latest
198
- displayName: Install tsp-client
199
-
200
- - pwsh : |
201
- if (Test-Path -Path '$(buildArtifactsPath)/overrides.json') {
202
- Write-Host "Using overrides.json to generate emitter-package.json"
203
- tsp-client generate-config-files `
204
- --package-json '$(buildArtifactsPath)/lock-files/package.json' `
205
- --output-dir '$(Build.ArtifactStagingDirectory)' `
206
- --emitter-package-json-path '${{ parameters.EmitterPackageJsonPath }}' `
207
- --overrides '$(buildArtifactsPath)/overrides.json'
208
- } else {
209
- tsp-client generate-config-files `
210
- --package-json '$(buildArtifactsPath)/lock-files/package.json' `
211
- --output-dir '$(Build.ArtifactStagingDirectory)' `
212
- --emitter-package-json-path '${{ parameters.EmitterPackageJsonPath }}'
213
- }
214
- displayName: Generate emitter-package.json and emitter-package-lock files
215
-
216
- - template : /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
217
- parameters :
218
- artifactName : publish_artifacts
219
- artifactPath : $(Build.ArtifactStagingDirectory)
220
-
221
208
# Regenerate stage
222
209
# Responsible for regenerating the SDK code using the emitter package and the generation matrix.
223
210
- ${{ if and(parameters.ShouldPublish, parameters.ShouldRegenerate) }} :
@@ -227,7 +214,7 @@ extends:
227
214
- Publish
228
215
variables :
229
216
pullRequestTargetBranch : ' main'
230
- publishArtifactsPath : $(Pipeline.Workspace)/publish_artifacts
217
+ buildArtifactsPath : $(Pipeline.Workspace)/build_artifacts
231
218
branchName : $[stageDependencies.Build.Build.outputs['set_branch_name.branchName']]
232
219
pool : ${{ parameters.Pool }}
233
220
jobs :
@@ -243,12 +230,27 @@ extends:
243
230
displayName : Download pipeline artifacts
244
231
245
232
- pwsh : |
246
- Write-Host "Copying emitter-package.json to $(Build.SourcesDirectory)/eng"
247
- Copy-Item $(publishArtifactsPath)/emitter-package.json $(Build.SourcesDirectory)/eng/ -Force
233
+ npm install -g @azure-tools/typespec-client-generator-cli@latest
234
+ displayName: Install tsp-client
248
235
249
- Write-Host "Copying emitter-package-lock.json to $(Build.SourcesDirectory)/eng"
250
- Copy-Item $(publishArtifactsPath)/emitter-package-lock.json $(Build.SourcesDirectory)/eng/ -Force
251
- displayName: Copy emitter-package json files
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)
252
254
253
255
- ${{ parameters.InitializationSteps }}
254
256
@@ -294,7 +296,7 @@ extends:
294
296
Paths :
295
297
- " /*"
296
298
- " !SessionRecords"
297
-
299
+
298
300
- download : current
299
301
displayName : Download pipeline artifacts
300
302
@@ -325,7 +327,7 @@ extends:
325
327
- Generate
326
328
variables :
327
329
generateJobResult : $[dependencies.Generate.result]
328
- emitterVersion : $[stageDependencies.Build.Build.outputs['ci_build .emitterVersion']]
330
+ emitterVersion : $[stageDependencies.Build.Build.outputs['initialize .emitterVersion']]
329
331
steps :
330
332
- template : /eng/common/pipelines/templates/steps/sparse-checkout.yml
331
333
@@ -385,6 +387,16 @@ extends:
385
387
} else {
386
388
Write-Error "Build.Repository.Name not in the expected {Owner}/{Name} format"
387
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
+
388
400
displayName: Get PR title and body
389
401
390
402
- task : PowerShell@2
@@ -401,8 +413,8 @@ extends:
401
413
-AuthToken '$(azuresdk-github-pat)'
402
414
-PRTitle '$(PullRequestTitle)'
403
415
-PRBody '$(PullRequestBody)'
404
- -OpenAsDraft $true
405
- -PRLabels 'Do Not Merge '
416
+ -OpenAsDraft $$(OpenAsDraft)
417
+ -PRLabels '$(PRLabels) '
406
418
workingDirectory : $(Build.SourcesDirectory)
407
419
408
420
# Test stage
@@ -435,7 +447,9 @@ extends:
435
447
inputs :
436
448
pwsh : true
437
449
filePath : $(Build.SourcesDirectory)/eng/scripts/typespec/Initialize-WorkingDirectory.ps1
438
- arguments : -BuildArtifactsPath '$(buildArtifactsPath)'
450
+ arguments : >
451
+ -BuildArtifactsPath '$(buildArtifactsPath)/lock-files'
452
+ -EmitterPackagePath: ${{ parameters.EmitterPackagePath }}
439
453
440
454
- task : PowerShell@2
441
455
displayName : ' Run test script'
@@ -445,6 +459,7 @@ extends:
445
459
arguments : >
446
460
$(TestArguments)
447
461
-OutputDirectory "$(Build.ArtifactStagingDirectory)"
462
+ -EmitterPackagePath: ${{ parameters.EmitterPackagePath }}
448
463
449
464
- template : /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
450
465
parameters :
0 commit comments