Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-client-python"
---

Fix CI publish failures by stamping prerelease version in Build-Packages.ps1. The `-Prerelease` flag was accepted but unused, causing every CI build to produce the same version and fail with a 409 conflict on the DevOps feed.
19 changes: 17 additions & 2 deletions packages/http-client-python/eng/scripts/Build-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ New-Item -ItemType Directory -Force -Path "$outputPath/packages" | Out-Null
$emitterVersion = node -p -e "require('$packageRoot/package.json').version"
Write-Host "Package version: $emitterVersion"

# Stamp prerelease version if BuildNumber is provided
if ($BuildNumber) {
$versionTag = $Prerelease ? "-alpha" : "-beta"
$emitterVersion = "$emitterVersion$versionTag.$BuildNumber"
Write-Host "Stamped prerelease version: $emitterVersion"
}

Push-Location "$packageRoot"
try {
# Step 1: Build the emitter and generator
Expand All @@ -87,12 +94,20 @@ try {
Invoke-LoggedCommand "npm run lint" -GroupOutput
}

# Step 3: Create npm package
# Step 3: Stamp version in package.json if prerelease
if ($BuildNumber) {
Write-Host "`n=== Updating package.json version to $emitterVersion ===" -ForegroundColor Cyan
$packageJson = Get-Content -Raw "package.json" | ConvertFrom-Json -AsHashtable
$packageJson.version = $emitterVersion
$packageJson | ConvertTo-Json -Depth 100 | Out-File -Path "package.json" -Encoding utf8 -NoNewline -Force
}
Comment thread
iscai-msft marked this conversation as resolved.
Resolved

# Step 4: Create npm package
Write-Host "`n=== Creating npm package ===" -ForegroundColor Cyan
Invoke-LoggedCommand "npm pack"
Copy-Item "typespec-http-client-python-$emitterVersion.tgz" -Destination "$outputPath/packages"

# Step 4: Verify package can be installed
# Step 5: Verify package can be installed
Write-Host "`n=== Verifying package installation ===" -ForegroundColor Cyan
Invoke-LoggedCommand "npm install typespec-http-client-python-$emitterVersion.tgz" -GroupOutput

Expand Down
Loading