Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync eng/common directory with azure-sdk-tools for PR 968 #14926

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eng/common/pipelines/templates/steps/publish-blobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ steps:
-BlobName "${{ parameters.BlobName }}"
-PublicArtifactLocation "${{ parameters.ArtifactLocation }}"
-RepoReplaceRegex "(https://github.com/${{ parameters.RepoId }}/(?:blob|tree)/)master"
-WorkingDirectory "$(System.DefaultWorkingDirectory)"
pwsh: true
workingDirectory: $(Pipeline.Workspace)
displayName: Copy Docs to Blob
Expand Down
1 change: 1 addition & 0 deletions eng/common/scripts/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $EngScriptsDir = Join-Path $EngDir "scripts"
. (Join-Path $EngCommonScriptsDir ChangeLog-Operations.ps1)
. (Join-Path $EngCommonScriptsDir Package-Properties.ps1)
. (Join-Path $EngCommonScriptsDir logging.ps1)
. (Join-Path $EngCommonScriptsDir artifact-metadata-parsing.ps1)

# Setting expected from common languages settings
$Language = "Unknown"
Expand Down
155 changes: 4 additions & 151 deletions eng/common/scripts/copy-docs-to-blobstorage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ param (
$ExitOnError=1,
$UploadLatest=1,
$PublicArtifactLocation = "",
$RepoReplaceRegex = "(https://github.com/.*/(?:blob|tree)/)master",
$WorkingDirectory
$RepoReplaceRegex = "(https://github.com/.*/(?:blob|tree)/)master"
)
. (Join-Path $PSScriptRoot artifact-metadata-parsing.ps1)

. (Join-Path $PSScriptRoot common.ps1)

$Language = $Language.ToLower()

Expand Down Expand Up @@ -234,151 +234,4 @@ function Upload-Blobs
}
}

if ($Language -eq "javascript")
{
$PublishedDocs = Get-ChildItem "$($DocLocation)/documentation" | Where-Object -FilterScript {$_.Name.EndsWith(".zip")}

foreach ($Item in $PublishedDocs) {
$PkgName = "azure-$($Item.BaseName)"
Write-Host $PkgName
Expand-Archive -Force -Path "$($DocLocation)/documentation/$($Item.Name)" -DestinationPath "$($DocLocation)/documentation/$($Item.BaseName)"
$dirList = Get-ChildItem "$($DocLocation)/documentation/$($Item.BaseName)/$($Item.BaseName)" -Attributes Directory

if($dirList.Length -eq 1){
$DocVersion = $dirList[0].Name
Write-Host "Uploading Doc for $($PkgName) Version:- $($DocVersion)..."
$releaseTag = RetrieveReleaseTag "NPM" $PublicArtifactLocation
Upload-Blobs -DocDir "$($DocLocation)/documentation/$($Item.BaseName)/$($Item.BaseName)/$($DocVersion)" -PkgName $PkgName -DocVersion $DocVersion -ReleaseTag $releaseTag
}
else{
Write-Host "found more than 1 folder under the documentation for package - $($Item.Name)"
}
}
}

if ($Language -eq "dotnet")
{
$PublishedPkgs = Get-ChildItem "$($DocLocation)" | Where-Object -FilterScript {$_.Name.EndsWith(".nupkg") -and -not $_.Name.EndsWith(".symbols.nupkg")}
$PublishedDocs = Get-ChildItem "$($DocLocation)" | Where-Object -FilterScript {$_.Name.EndsWith("docs.zip")}

if (($PublishedPkgs.Count -gt 1) -or ($PublishedDoc.Count -gt 1))
{
Write-Host "$($DocLocation) should contain only one (1) published package and docs"
Write-Host "No of Packages $($PublishedPkgs.Count)"
Write-Host "No of Docs $($PublishedDoc.Count)"
exit 1
}

$DocsStagingDir = "$WorkingDirectory/docstaging"
$TempDir = "$WorkingDirectory/temp"

New-Item -ItemType directory -Path $DocsStagingDir
New-Item -ItemType directory -Path $TempDir

Expand-Archive -LiteralPath $PublishedDocs[0].FullName -DestinationPath $DocsStagingDir
$pkgProperties = ParseNugetPackage -pkg $PublishedPkgs[0].FullName -workingDirectory $TempDir

Write-Host "Start Upload for $($pkgProperties.Tag)"
Write-Host "DocDir $($DocsStagingDir)"
Write-Host "PkgName $($pkgProperties.PackageId)"
Write-Host "DocVersion $($pkgProperties.PackageVersion)"
Upload-Blobs -DocDir "$($DocsStagingDir)" -PkgName $pkgProperties.PackageId -DocVersion $pkgProperties.PackageVersion -ReleaseTag $pkgProperties.Tag
}

if ($Language -eq "python")
{
$PublishedDocs = Get-ChildItem "$DocLocation" | Where-Object -FilterScript {$_.Name.EndsWith(".zip")}

foreach ($Item in $PublishedDocs) {
$PkgName = $Item.BaseName
$ZippedDocumentationPath = Join-Path -Path $DocLocation -ChildPath $Item.Name
$UnzippedDocumentationPath = Join-Path -Path $DocLocation -ChildPath $PkgName
$VersionFileLocation = Join-Path -Path $UnzippedDocumentationPath -ChildPath "version.txt"

Expand-Archive -Force -Path $ZippedDocumentationPath -DestinationPath $UnzippedDocumentationPath

$Version = $(Get-Content $VersionFileLocation).Trim()

Write-Host "Discovered Package Name: $PkgName"
Write-Host "Discovered Package Version: $Version"
Write-Host "Directory for Upload: $UnzippedDocumentationPath"
$releaseTag = RetrieveReleaseTag "PyPI" $PublicArtifactLocation
Upload-Blobs -DocDir $UnzippedDocumentationPath -PkgName $PkgName -DocVersion $Version -ReleaseTag $releaseTag
}
}

if ($Language -eq "java")
{
$PublishedDocs = Get-ChildItem "$DocLocation" | Where-Object -FilterScript {$_.Name.EndsWith("-javadoc.jar")}
foreach ($Item in $PublishedDocs) {
$UnjarredDocumentationPath = ""
try {
$PkgName = $Item.BaseName
# The jar's unpacking command doesn't allow specifying a target directory
# and will unjar all of the files in whatever the current directory is.
# Create a subdirectory to unjar into, set the location, unjar and then
# set the location back to its original location.
$UnjarredDocumentationPath = Join-Path -Path $DocLocation -ChildPath $PkgName
New-Item -ItemType directory -Path "$UnjarredDocumentationPath"
$CurrentLocation = Get-Location
Set-Location $UnjarredDocumentationPath
jar -xf "$($Item.FullName)"
Set-Location $CurrentLocation

# If javadocs are produced for a library with source, there will always be an
# index.html. If this file doesn't exist in the UnjarredDocumentationPath then
# this is a sourceless library which means there are no javadocs and nothing
# should be uploaded to blob storage.
$IndexHtml = Join-Path -Path $UnjarredDocumentationPath -ChildPath "index.html"
if (!(Test-Path -path $IndexHtml))
{
Write-Host "$($PkgName) does not have an index.html file, skippping."
continue
}

# Get the POM file for the artifact we're processing
$PomFile = $Item.FullName.Substring(0,$Item.FullName.LastIndexOf(("-javadoc.jar"))) + ".pom"
Write-Host "PomFile $($PomFile)"

# Pull the version from the POM
[xml]$PomXml = Get-Content $PomFile
$Version = $PomXml.project.version
$ArtifactId = $PomXml.project.artifactId

Write-Host "Start Upload for $($PkgName)/$($Version)"
Write-Host "DocDir $($UnjarredDocumentationPath)"
Write-Host "PkgName $($ArtifactId)"
Write-Host "DocVersion $($Version)"
$releaseTag = RetrieveReleaseTag "Maven" $PublicArtifactLocation
Upload-Blobs -DocDir $UnjarredDocumentationPath -PkgName $ArtifactId -DocVersion $Version -ReleaseTag $releaseTag

} Finally {
if (![string]::IsNullOrEmpty($UnjarredDocumentationPath)) {
if (Test-Path -Path $UnjarredDocumentationPath) {
Write-Host "Cleaning up $UnjarredDocumentationPath"
Remove-Item -Recurse -Force $UnjarredDocumentationPath
}
}
}
}
}

if ($Language -eq "c")
{
# The documentation publishing process for C differs from the other
# langauges in this file because this script is invoked for the whole SDK
# publishing. It is not, for example, invoked once per service publishing.
# 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
$releaseTag = RetrieveReleaseTag "C" $PublicArtifactLocation
Upload-Blobs -DocDir $DocLocation -PkgName 'docs' -DocVersion $pkgInfo.version -ReleaseTag $releaseTag
}

if ($Language -eq "cpp")
{
$packageInfo = (Get-Content (Join-Path $DocLocation 'package-info.json') | ConvertFrom-Json)
$releaseTag = RetrieveReleaseTag "CPP" $PublicArtifactLocation
Upload-Blobs -DocDir $DocLocation -PkgName $packageInfo.name -DocVersion $packageInfo.version -ReleaseTag $releaseTag
}
&$PublishGithubIODocsFn -DocLocation $DocLocation -PublicArtifactLocation $PublicArtifactLocation