Sync eng/common directory with azure-sdk-tools repository (#147)

This commit is contained in:
Azure SDK Bot 2020-05-27 19:41:53 -07:00 committed by GitHub
parent 64e653ac20
commit 2c058bd053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 34 deletions

View File

@ -86,16 +86,21 @@ function ParseMavenPackage($pkg, $workingDirectory) {
$pkgId = $contentXML.project.artifactId
$pkgVersion = $contentXML.project.version
$groupId = if ($contentXML.project.groupId -eq $null) { $contentXML.project.parent.groupId } else { $contentXML.project.groupId }
$releaseNotes = ""
$readmeContent = ""
# if it's a snapshot. return $null (as we don't want to create tags for this, but we also don't want to fail)
if ($pkgVersion.Contains("SNAPSHOT")) {
return $null
}
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-changelog.md")[0]
$changeLogLoc = @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-changelog.md")[0]
if ($changeLogLoc) {
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
}
$readmeContentLoc = @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-readme.md")[0]
if (Test-Path -Path $readmeContentLoc) {
if ($readmeContentLoc) {
$readmeContent = Get-Content -Raw $readmeContentLoc
}
@ -155,15 +160,23 @@ function ResolvePkgJson($workFolder) {
function ParseNPMPackage($pkg, $workingDirectory) {
$workFolder = "$workingDirectory$($pkg.Basename)"
$origFolder = Get-Location
$releaseNotes = ""
$readmeContent = ""
New-Item -ItemType Directory -Force -Path $workFolder
cd $workFolder
tar -xzf $pkg
$packageJSON = ResolvePkgJson -workFolder $workFolder | Get-Content | ConvertFrom-Json
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
$changeLogLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
if ($changeLogLoc) {
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
}
$readmeContentLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "README.md")[0]
if (Test-Path -Path $readmeContentLoc) {
if ($readmeContentLoc) {
$readmeContent = Get-Content -Raw $readmeContentLoc
}
@ -208,15 +221,22 @@ function ParseNugetPackage($pkg, $workingDirectory) {
$workFolder = "$workingDirectory$($pkg.Basename)"
$origFolder = Get-Location
$zipFileLocation = "$workFolder/$($pkg.Basename).zip"
$releaseNotes = ""
$readmeContent = ""
New-Item -ItemType Directory -Force -Path $workFolder
Copy-Item -Path $pkg -Destination $zipFileLocation
Expand-Archive -Path $zipFileLocation -DestinationPath $workFolder
[xml] $packageXML = Get-ChildItem -Path "$workFolder/*.nuspec" | Get-Content
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
$changeLogLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
if ($changeLogLoc) {
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
}
$readmeContentLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "README.md")[0]
if (Test-Path -Path $readmeContentLoc) {
if ($readmeContentLoc) {
$readmeContent = Get-Content -Raw $readmeContentLoc
}
@ -269,12 +289,19 @@ function ParsePyPIPackage($pkg, $workingDirectory) {
$workFolder = "$workingDirectory$($pkg.Basename)"
$origFolder = Get-Location
New-Item -ItemType Directory -Force -Path $workFolder
$releaseNotes = ""
$readmeContent = ""
New-Item -ItemType Directory -Force -Path $workFolder
Expand-Archive -Path $pkg -DestinationPath $workFolder
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
$changeLogLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
if ($changeLogLoc) {
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
}
$readmeContentLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "README.md")[0]
if (Test-Path -Path $readmeContentLoc) {
if ($readmeContentLoc) {
$readmeContent = Get-Content -Raw $readmeContentLoc
}
Remove-Item $workFolder -Force -Recurse -ErrorAction SilentlyContinue
@ -291,23 +318,28 @@ function ParsePyPIPackage($pkg, $workingDirectory) {
function ParseCArtifact($pkg, $workingDirectory) {
$packageInfo = Get-Content -Raw -Path $pkg | ConvertFrom-JSON
$packageArtifactLocation = (Get-ItemProperty $pkg).Directory.FullName
$releaseNotes = ""
$readmeContent = ""
$releaseNotes = ExtractReleaseNotes -changeLogLocation @(Get-ChildItem -Path $packageArtifactLocation -Recurse -Include "CHANGELOG.md")[0]
$changeLogLoc = @(Get-ChildItem -Path $packageArtifactLocation -Recurse -Include "CHANGELOG.md")[0]
if ($changeLogLoc)
{
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
}
$readmeContentLoc = @(Get-ChildItem -Path $packageArtifactLocation -Recurse -Include "README.md")[0]
if (Test-Path -Path $readmeContentLoc) {
if ($readmeContentLoc) {
$readmeContent = Get-Content -Raw $readmeContentLoc
}
return New-Object PSObject -Property @{
PackageId = $packageInfo.name
PackageId = ''
PackageVersion = $packageInfo.version
# Artifact info is always considered deployable for C becasue it is not
# deployed anywhere. Dealing with duplicate tags happens downstream in
# CheckArtifactShaAgainstTagsList
Deployable = $true
ReleaseNotes = $releaseNotes
ReadmeContent = $readmeContent
}
}
@ -410,10 +442,16 @@ function VerifyPackages($pkgRepository, $artifactLocation, $workingDirectory, $a
exit(1)
}
$tag = if ($parsedPackage.packageId) {
"$($parsedPackage.packageId)_$($parsedPackage.PackageVersion)"
} else {
$parsedPackage.PackageVersion
}
$pkgList += New-Object PSObject -Property @{
PackageId = $parsedPackage.PackageId
PackageVersion = $parsedPackage.PackageVersion
Tag = ($parsedPackage.PackageId + "_" + $parsedPackage.PackageVersion)
Tag = $tag
ReleaseNotes = $parsedPackage.ReleaseNotes
ReadmeContent = $parsedPackage.ReadmeContent
}

View File

@ -345,14 +345,11 @@ if ($Language -eq "java")
if ($Language -eq "c")
{
# The documentation publishing process for C differs from the other
# langauges in this file because this script is invoked once per library
# langauges in this file because this script is invoked for the whole SDK
# publishing. It is not, for example, invoked once per service publishing.
# This is also the case for other langauge publishing steps above... Those
# loops are left over from previous versions of this script which were used
# to publish multiple docs packages in a single invocation.
# There is a similar situation for other langauge publishing steps above...
# Those loops are left over from previous versions of this script which were
# used to publish multiple docs packages in a single invocation.
$pkgInfo = Get-Content $DocLocation/package-info.json | ConvertFrom-Json
$pkgName = $pkgInfo.name
$pkgVersion = $pkgInfo.version
Upload-Blobs -DocDir $DocLocation -PkgName $pkgName -DocVersion $pkgVersion
Upload-Blobs -DocDir $DocLocation -PkgName 'docs' -DocVersion $pkgInfo.version
}

View File

@ -24,19 +24,19 @@ Write-Host "> $PSCommandPath $args"
function GetMetaData($lang){
switch ($lang) {
"java" {
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/java-packages.csv"
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/allpackages/java-packages.csv"
break
}
".net" {
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/dotnet-packages.csv"
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/allpackages/dotnet-packages.csv"
break
}
"python" {
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/python-packages.csv"
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/allpackages/python-packages.csv"
break
}
"javascript" {
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/js-packages.csv"
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/allpackages/js-packages.csv"
break
}
default {
@ -46,6 +46,8 @@ function GetMetaData($lang){
}
$metadataResponse = Invoke-WebRequest-WithHandling -url $metadataUri -method "GET" | ConvertFrom-Csv
return $metadataResponse
}
function GetAdjustedReadmeContent($pkgInfo, $lang){
@ -57,10 +59,11 @@ function GetAdjustedReadmeContent($pkgInfo, $lang){
try {
$metadata = GetMetaData -lang $lang
$service = $metadata | ? { $_.Package -eq $pkgId }
if ($service) {
$service = "$service,"
$service = "$($service.Service)"
}
}
catch {
@ -68,12 +71,18 @@ function GetAdjustedReadmeContent($pkgInfo, $lang){
Write-Host "Unable to retrieve service metadata for packageId $($pkgInfo.PackageId)"
}
$headerContentMatch = (Select-String -InputObject $pkgInfo.ReadmeContent -Pattern 'Azure .+? (client|plugin|shared) library for (JavaScript|Java|Python|\.NET|C)').Matches[0]
$fileContent = $pkgInfo.ReadmeContent
if ($headerContentMatch){
$header = "---`r`ntitle: $headerContentMatch`r`nkeywords: Azure, $lang, SDK, API, $service $($pkgInfo.PackageId)`r`nauthor: maggiepint`r`nms.author: magpint`r`nms.date: $date`r`nms.topic: article`r`nms.prod: azure`r`nms.technology: azure`r`nms.devlang: $lang`r`nms.service: $service`r`n---`r`n"
$fileContent = $pkgInfo.ReadmeContent -replace $headerContentMatch, "$headerContentMatch - Version $($pkgInfo.PackageVersion) `r`n"
return "$header $fileContent"
# only replace the version if the formatted header can be found
$headerContentMatches = (Select-String -InputObject $pkgInfo.ReadmeContent -Pattern 'Azure .+? (client|plugin|shared) library for (JavaScript|Java|Python|\.NET|C)')
if ($headerContentMatches) {
$headerContentMatch = $headerContentMatches.Matches[0]
$header = "---`ntitle: $headerContentMatch`nkeywords: Azure, $lang, SDK, API, $($pkgInfo.PackageId), $service`nauthor: maggiepint`nms.author: magpint`nms.date: $date`nms.topic: article`nms.prod: azure`nms.technology: azure`nms.devlang: $lang`nms.service: $service`n---`n"
$fileContent = $pkgInfo.ReadmeContent -replace $headerContentMatch, "$headerContentMatch - Version $($pkgInfo.PackageVersion) `n"
}
if ($fileContent) {
return "$header`n$fileContent"
}
else {
return ""
@ -102,7 +111,10 @@ if ($pkgs) {
$readmeName = "$($packageInfo.PackageId.Replace('azure-','').Replace('Azure.', '').Replace('@azure/', '').ToLower())-readme$rdSuffix.md"
$readmeLocation = Join-Path $DocRepoLocation $DocRepoContentLocation $readmeName
$adjustedContent = GetAdjustedReadmeContent -pkgInfo $packageInfo -lang $Language
if ($packageInfo.ReadmeContent) {
$adjustedContent = GetAdjustedReadmeContent -pkgInfo $packageInfo -lang $Language
}
if ($adjustedContent) {
try {