Skip to content

Commit 45e7d17

Browse files
authored
Sync eng/common directory with azure-sdk-tools repository (#11566)
1 parent b94b42f commit 45e7d17

File tree

5 files changed

+445
-24
lines changed

5 files changed

+445
-24
lines changed

eng/common/pipelines/templates/steps/docs-metadata-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ steps:
5555
PRTitle: "Docs.MS Readme Update."
5656
BaseBranchName: smoke-test
5757
WorkingDirectory: ${{parameters.WorkingDirectory}}/repo
58-
ScriptDirectory: ${{parameters.WorkingDirectory}}/${{parameters.ScriptDirectory}}
58+
ScriptDirectory: ${{parameters.WorkingDirectory}}/${{parameters.ScriptDirectory}}

eng/common/scripts/artifact-metadata-parsing.ps1

+53-15
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,21 @@ function ParseMavenPackage($pkg, $workingDirectory) {
8686
$pkgId = $contentXML.project.artifactId
8787
$pkgVersion = $contentXML.project.version
8888
$groupId = if ($contentXML.project.groupId -eq $null) { $contentXML.project.parent.groupId } else { $contentXML.project.groupId }
89+
$releaseNotes = ""
90+
$readmeContent = ""
8991

9092
# 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)
9193
if ($pkgVersion.Contains("SNAPSHOT")) {
9294
return $null
9395
}
9496

95-
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-changelog.md")[0]
97+
$changeLogLoc = @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-changelog.md")[0]
98+
if ($changeLogLoc) {
99+
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
100+
}
96101

97102
$readmeContentLoc = @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-readme.md")[0]
98-
if (Test-Path -Path $readmeContentLoc) {
103+
if ($readmeContentLoc) {
99104
$readmeContent = Get-Content -Raw $readmeContentLoc
100105
}
101106

@@ -155,15 +160,23 @@ function ResolvePkgJson($workFolder) {
155160
function ParseNPMPackage($pkg, $workingDirectory) {
156161
$workFolder = "$workingDirectory$($pkg.Basename)"
157162
$origFolder = Get-Location
163+
$releaseNotes = ""
164+
$readmeContent = ""
165+
158166
New-Item -ItemType Directory -Force -Path $workFolder
159167
cd $workFolder
160168

161169
tar -xzf $pkg
162170

163171
$packageJSON = ResolvePkgJson -workFolder $workFolder | Get-Content | ConvertFrom-Json
164-
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
172+
173+
$changeLogLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
174+
if ($changeLogLoc) {
175+
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
176+
}
177+
165178
$readmeContentLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "README.md")[0]
166-
if (Test-Path -Path $readmeContentLoc) {
179+
if ($readmeContentLoc) {
167180
$readmeContent = Get-Content -Raw $readmeContentLoc
168181
}
169182

@@ -208,15 +221,22 @@ function ParseNugetPackage($pkg, $workingDirectory) {
208221
$workFolder = "$workingDirectory$($pkg.Basename)"
209222
$origFolder = Get-Location
210223
$zipFileLocation = "$workFolder/$($pkg.Basename).zip"
224+
$releaseNotes = ""
225+
$readmeContent = ""
226+
211227
New-Item -ItemType Directory -Force -Path $workFolder
212228

213229
Copy-Item -Path $pkg -Destination $zipFileLocation
214230
Expand-Archive -Path $zipFileLocation -DestinationPath $workFolder
215231
[xml] $packageXML = Get-ChildItem -Path "$workFolder/*.nuspec" | Get-Content
216-
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
232+
233+
$changeLogLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
234+
if ($changeLogLoc) {
235+
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
236+
}
217237

218238
$readmeContentLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "README.md")[0]
219-
if (Test-Path -Path $readmeContentLoc) {
239+
if ($readmeContentLoc) {
220240
$readmeContent = Get-Content -Raw $readmeContentLoc
221241
}
222242

@@ -269,12 +289,19 @@ function ParsePyPIPackage($pkg, $workingDirectory) {
269289

270290
$workFolder = "$workingDirectory$($pkg.Basename)"
271291
$origFolder = Get-Location
272-
New-Item -ItemType Directory -Force -Path $workFolder
292+
$releaseNotes = ""
293+
$readmeContent = ""
273294

295+
New-Item -ItemType Directory -Force -Path $workFolder
274296
Expand-Archive -Path $pkg -DestinationPath $workFolder
275-
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
297+
298+
$changeLogLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
299+
if ($changeLogLoc) {
300+
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
301+
}
302+
276303
$readmeContentLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "README.md")[0]
277-
if (Test-Path -Path $readmeContentLoc) {
304+
if ($readmeContentLoc) {
278305
$readmeContent = Get-Content -Raw $readmeContentLoc
279306
}
280307
Remove-Item $workFolder -Force -Recurse -ErrorAction SilentlyContinue
@@ -291,23 +318,28 @@ function ParsePyPIPackage($pkg, $workingDirectory) {
291318
function ParseCArtifact($pkg, $workingDirectory) {
292319
$packageInfo = Get-Content -Raw -Path $pkg | ConvertFrom-JSON
293320
$packageArtifactLocation = (Get-ItemProperty $pkg).Directory.FullName
321+
$releaseNotes = ""
322+
$readmeContent = ""
294323

295-
$releaseNotes = ExtractReleaseNotes -changeLogLocation @(Get-ChildItem -Path $packageArtifactLocation -Recurse -Include "CHANGELOG.md")[0]
296-
324+
$changeLogLoc = @(Get-ChildItem -Path $packageArtifactLocation -Recurse -Include "CHANGELOG.md")[0]
325+
if ($changeLogLoc)
326+
{
327+
$releaseNotes = &"${PSScriptRoot}/../Extract-ReleaseNotes.ps1" -ChangeLogLocation $changeLogLoc
328+
}
329+
297330
$readmeContentLoc = @(Get-ChildItem -Path $packageArtifactLocation -Recurse -Include "README.md")[0]
298-
if (Test-Path -Path $readmeContentLoc) {
331+
if ($readmeContentLoc) {
299332
$readmeContent = Get-Content -Raw $readmeContentLoc
300333
}
301334

302335
return New-Object PSObject -Property @{
303-
PackageId = $packageInfo.name
336+
PackageId = ''
304337
PackageVersion = $packageInfo.version
305338
# Artifact info is always considered deployable for C becasue it is not
306339
# deployed anywhere. Dealing with duplicate tags happens downstream in
307340
# CheckArtifactShaAgainstTagsList
308341
Deployable = $true
309342
ReleaseNotes = $releaseNotes
310-
ReadmeContent = $readmeContent
311343
}
312344
}
313345

@@ -410,10 +442,16 @@ function VerifyPackages($pkgRepository, $artifactLocation, $workingDirectory, $a
410442
exit(1)
411443
}
412444

445+
$tag = if ($parsedPackage.packageId) {
446+
"$($parsedPackage.packageId)_$($parsedPackage.PackageVersion)"
447+
} else {
448+
$parsedPackage.PackageVersion
449+
}
450+
413451
$pkgList += New-Object PSObject -Property @{
414452
PackageId = $parsedPackage.PackageId
415453
PackageVersion = $parsedPackage.PackageVersion
416-
Tag = ($parsedPackage.PackageId + "_" + $parsedPackage.PackageVersion)
454+
Tag = $tag
417455
ReleaseNotes = $parsedPackage.ReleaseNotes
418456
ReadmeContent = $parsedPackage.ReadmeContent
419457
}

eng/common/scripts/copy-docs-to-blobstorage.ps1

+16-8
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,17 @@ if ($Language -eq "java")
304304
jar -xf "$($Item.FullName)"
305305
Set-Location $CurrentLocation
306306

307+
# If javadocs are produced for a library with source, there will always be an
308+
# index.html. If this file doesn't exist in the UnjarredDocumentationPath then
309+
# this is a sourceless library which means there are no javadocs and nothing
310+
# should be uploaded to blob storage.
311+
$IndexHtml = Join-Path -Path $UnjarredDocumentationPath -ChildPath "index.html"
312+
if (!(Test-Path -path $IndexHtml))
313+
{
314+
Write-Host "$($PkgName) does not have an index.html file, skippping."
315+
continue
316+
}
317+
307318
# Get the POM file for the artifact we're processing
308319
$PomFile = $Item.FullName.Substring(0,$Item.FullName.LastIndexOf(("-javadoc.jar"))) + ".pom"
309320
Write-Host "PomFile $($PomFile)"
@@ -334,14 +345,11 @@ if ($Language -eq "java")
334345
if ($Language -eq "c")
335346
{
336347
# The documentation publishing process for C differs from the other
337-
# langauges in this file because this script is invoked once per library
348+
# langauges in this file because this script is invoked for the whole SDK
338349
# publishing. It is not, for example, invoked once per service publishing.
339-
# This is also the case for other langauge publishing steps above... Those
340-
# loops are left over from previous versions of this script which were used
341-
# to publish multiple docs packages in a single invocation.
350+
# There is a similar situation for other langauge publishing steps above...
351+
# Those loops are left over from previous versions of this script which were
352+
# used to publish multiple docs packages in a single invocation.
342353
$pkgInfo = Get-Content $DocLocation/package-info.json | ConvertFrom-Json
343-
$pkgName = $pkgInfo.name
344-
$pkgVersion = $pkgInfo.version
345-
346-
Upload-Blobs -DocDir $DocLocation -PkgName $pkgName -DocVersion $pkgVersion
354+
Upload-Blobs -DocDir $DocLocation -PkgName 'docs' -DocVersion $pkgInfo.version
347355
}

0 commit comments

Comments
 (0)