Skip to content

Commit fbd0e7d

Browse files
Publish Azure Generator to Dev Feed (Azure#49474)
* temp * simply scripts * rename publish parameter name
1 parent 0c1866b commit fbd0e7d

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

eng/packages/http-client-csharp/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ parameters:
3535
displayName: "Regenerate clients"
3636
type: boolean
3737
default: false
38+
- name: PublishNugetPackages
39+
displayName: "Publish NuGet package artifacts"
40+
type: boolean
41+
default: false
3842

3943
variables:
4044
- template: /eng/pipelines/templates/variables/image.yml
@@ -53,6 +57,7 @@ extends:
5357
${{ if eq(variables['Build.Reason'], 'Manual') }}:
5458
ShouldPublish: ${{ parameters.ShouldPublish }}
5559
ShouldRegenerate: ${{ parameters.ShouldRegenerate }}
60+
HasNugetPackages: ${{ parameters.PublishNugetPackages }}
5661
${{ if startswith(variables['Build.SourceBranch'], 'refs/pull/') }}: # PR ref's can't be published to public, even in a manual run
5762
PublishPublic: false
5863
PublishDependsOnTest: false
@@ -64,6 +69,7 @@ extends:
6469
ShouldRegenerate: true
6570
PublishDependsOnTest: false
6671
PublishPublic: ${{ and(eq(variables['Build.Reason'], 'IndividualCI'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) }}
72+
HasNugetPackages: true
6773
RegenerationJobCount: 5
6874
MinimumPerJob: 10
6975
OnlyGenerateTypespec: true

eng/scripts/typespec/Build-Emitter.ps1

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
param(
44
[string] $OutputDirectory,
55
[switch] $TargetNpmJsFeed,
6-
[string] $emitterPackagePath
6+
[string] $emitterPackagePath,
7+
[string] $GeneratorVersion
78
)
89

10+
if ([string]::IsNullOrEmpty($GeneratorVersion)) {
11+
Write-Host "GeneratorVersion is required"
12+
exit 1
13+
}
14+
915
$ErrorActionPreference = 'Stop'
1016
Set-StrictMode -Version 3.0
1117
. "$PSScriptRoot/../../common/scripts/common.ps1"
@@ -58,6 +64,43 @@ function Build-Emitter {
5864
}
5965
}
6066

67+
function Write-PackageInfo {
68+
param(
69+
[string] $packageName,
70+
[string] $directoryPath,
71+
[string] $version
72+
)
73+
74+
$packageInfoPath = "$outputPath/PackageInfo"
75+
76+
if (!(Test-Path $packageInfoPath)) {
77+
New-Item -ItemType Directory -Force -Path $packageInfoPath | Out-Null
78+
}
79+
80+
@{
81+
Name = $packageName
82+
Version = $version
83+
DirectoryPath = $directoryPath
84+
SdkType = "client"
85+
IsNewSdk = $true
86+
ReleaseStatus = "Unreleased"
87+
} | ConvertTo-Json | Set-Content -Path "$packageInfoPath/$packageName.json"
88+
}
89+
90+
function Pack-And-Write-Info {
91+
param(
92+
[string] $package,
93+
[string] $version,
94+
[string] $outputPath
95+
)
96+
97+
$versionOption = "/p:Version=$version"
98+
$hasReleaseVersionOption = $version.Contains("alpha") ? "/p:HasReleaseVersion=false" : ""
99+
Invoke-LoggedCommand "dotnet pack ./$package/src/$package.csproj $versionOption $hasReleaseVersionOption -c Release -o $outputPath"
100+
Write-PackageInfo -packageName $package -directoryPath "eng/packages/http-client-csharp/generator/$package/src" -version $version
101+
}
102+
103+
61104
$overrides = @{}
62105

63106
$outputPath = $OutputDirectory ? $OutputDirectory : (Join-Path $RepoRoot "artifacts" "emitters")
@@ -70,6 +113,23 @@ if ($emitterPackagePath.StartsWith("/")) {
70113
$packageRoot = Join-Path $RepoRoot $emitterPackagePath
71114
Build-Emitter -packageRoot $packageRoot -outputPath $outputPath -overrides $overrides
72115

116+
# Pack the generator
117+
Push-Location "$packageRoot/generator"
118+
try {
119+
Write-Host "Working in $PWD"
120+
Pack-And-Write-Info -package "Azure.Generator" -version $GeneratorVersion -outputPath $outputPath
121+
}
122+
finally
123+
{
124+
Pop-Location
125+
}
126+
127+
$packageMatrix = [ordered]@{
128+
"azure.generator" = $generatorVersion
129+
}
130+
131+
$packageMatrix | ConvertTo-Json | Set-Content "$outputPath/package-versions.json"
132+
73133
Write-Host "Writing overrides to $outputPath/overrides.json"
74134

75135
$overrides | ConvertTo-Json | Out-File -FilePath "$outputPath/overrides.json" -Encoding utf8 -Force

0 commit comments

Comments
 (0)