From 360aad7e360fad5b21f84ece3ecc8074ce869e7f Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 17 Sep 2020 04:12:22 +0000 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools repository for Tools PR 968 --- .../templates/steps/publish-blobs.yml | 1 - eng/common/scripts/common.ps1 | 1 + .../scripts/copy-docs-to-blobstorage.ps1 | 155 +----------------- 3 files changed, 5 insertions(+), 152 deletions(-) diff --git a/eng/common/pipelines/templates/steps/publish-blobs.yml b/eng/common/pipelines/templates/steps/publish-blobs.yml index 773fb31b274e2..5888edff87d12 100644 --- a/eng/common/pipelines/templates/steps/publish-blobs.yml +++ b/eng/common/pipelines/templates/steps/publish-blobs.yml @@ -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 diff --git a/eng/common/scripts/common.ps1 b/eng/common/scripts/common.ps1 index 4caaacc4e2cfe..12344dcd9ab1b 100644 --- a/eng/common/scripts/common.ps1 +++ b/eng/common/scripts/common.ps1 @@ -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" diff --git a/eng/common/scripts/copy-docs-to-blobstorage.ps1 b/eng/common/scripts/copy-docs-to-blobstorage.ps1 index b1306692408dd..536fccea54844 100644 --- a/eng/common/scripts/copy-docs-to-blobstorage.ps1 +++ b/eng/common/scripts/copy-docs-to-blobstorage.ps1 @@ -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() @@ -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 \ No newline at end of file