Skip to content

Commit

Permalink
Updates to Language Settings file (Azure#12589)
Browse files Browse the repository at this point in the history
* Add Update-javascript-CIConfig

* Add Update-javascript-CIConfig

* Switch from using BuildNumber to BuildID for test versions
  • Loading branch information
chidozieononiwu authored Nov 18, 2020
1 parent 279f6bf commit 1c2e8c4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion eng/pipelines/templates/stages/archetype-js-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ stages:
pwsh: true
workingDirectory: $(Build.SourcesDirectory)
filePath: eng/scripts/SetTestPipelineVersion.ps1
arguments: '-BuildNumber $(Build.BuildNumber)'
arguments: '-BuildID $(Build.BuildId)'
- template: /eng/common/pipelines/templates/steps/verify-changelog.yml
parameters:
PackageName: ${{artifact.name}}
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/templates/steps/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ steps:
pwsh: true
workingDirectory: $(Build.SourcesDirectory)
filePath: eng/scripts/SetTestPipelineVersion.ps1
arguments: '-BuildNumber $(Build.BuildNumber)'
arguments: '-BuildID $(Build.BuildId)'

- pwsh: |
$folder = "${{parameters.ServiceDirectory}}"
Expand Down
57 changes: 56 additions & 1 deletion eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ function Publish-javascript-GithubIODocs ($DocLocation, $PublicArtifactLocation)
$parsedPackage = Get-javascript-PackageInfoFromPackageFile $pkgs[0] $PublicArtifactLocation
$PkgName = $parsedPackage.PackageId.Replace("@", "").Replace("/", "-")
}
else{
else
{
Write-Host "Package info is not available from artifact. Assuming package is in default scope @azure."
}
Write-Host "Uploading Doc for $($PkgName) Version:- $($DocVersion)..."
Expand All @@ -144,3 +145,57 @@ function Get-javascript-GithubIoDocIndex()
# Generate yml/md toc files and build site.
GenerateDocfxTocContent -tocContent $tocContent -lang "JavaScript"
}

# Updates a js CI configuration json.
# For "latest", we simply set a target package name
# For "preview", we add @next to the target package name
function Update-javascript-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId = $null)
{
$pkgJsonLoc = (Join-Path -Path $ciRepo -ChildPath $locationInDocRepo)

if (-not (Test-Path $pkgJsonLoc))
{
Write-Error "Unable to locate package json at location $pkgJsonLoc, exiting."
exit(1)
}

$allJson = Get-Content $pkgJsonLoc | ConvertFrom-Json

$visibleInCI = @{}

for ($i = 0; $i -lt $allJson.npm_package_sources.Length; $i++)
{
$pkgDef = $allJson.npm_package_sources[$i]
$accessor = ($pkgDef.name).Replace("`@next", "")
$visibleInCI[$accessor] = $i
}

foreach ($releasingPkg in $pkgs)
{
$name = $releasingPkg.PackageId

if ($releasingPkg.IsPrerelease)
{
$name += "`@next"
}

if ($visibleInCI.ContainsKey($releasingPkg.PackageId))
{
$packagesIndex = $visibleInCI[$releasingPkg.PackageId]
$existingPackageDef = $allJson.npm_package_sources[$packagesIndex]
$existingPackageDef.name = $name
}
else
{
$newItem = New-Object PSObject -Property @{
name = $name
}

if ($newItem) { $allJson.npm_package_sources += $newItem }
}
}

$jsonContent = $allJson | ConvertTo-Json -Depth 10 | ForEach-Object { $_ -replace "(?m) (?<=^(?: )*)", " " }

Set-Content -Path $pkgJsonLoc -Value $jsonContent
}
4 changes: 2 additions & 2 deletions eng/scripts/SetTestPipelineVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

param (
[Parameter(mandatory = $true)]
$BuildNumber
$BuildID
)

. "${PSScriptRoot}\..\common\scripts\common.ps1"
Expand All @@ -24,7 +24,7 @@ LogDebug "Last Published Version $($semVarsSorted[0])"

$newVersion = [AzureEngSemanticVersion]::ParseVersionString($semVarsSorted[0])
$newVersion.PrereleaseLabel = "beta"
$newVersion.PrereleaseNumber = $BuildNumber
$newVersion.PrereleaseNumber = $BuildID

$packageFileContent = Get-Content -Path $templatePackageFile | ConvertFrom-Json
LogDebug "Version in Source $($packageFileContent.version)"
Expand Down

0 comments on commit 1c2e8c4

Please sign in to comment.