diff --git a/eng/common/scripts/common.ps1 b/eng/common/scripts/common.ps1 index 6a1f148783..4e272d6162 100644 --- a/eng/common/scripts/common.ps1 +++ b/eng/common/scripts/common.ps1 @@ -8,6 +8,7 @@ $EngScriptsDir = Join-Path $EngDir "scripts" . (Join-Path $EngCommonScriptsDir SemVer.ps1) . (Join-Path $EngCommonScriptsDir ChangeLog-Operations.ps1) . (Join-Path $EngCommonScriptsDir Package-Properties.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 9b7dea48b1..26b0e35c33 100644 --- a/eng/common/scripts/copy-docs-to-blobstorage.ps1 +++ b/eng/common/scripts/copy-docs-to-blobstorage.ps1 @@ -11,7 +11,8 @@ param ( $PublicArtifactLocation = "", $RepoReplaceRegex = "(https://github.com/.*/(?:blob|tree)/)master" ) -. (Join-Path $PSScriptRoot artifact-metadata-parsing.ps1) + +. (Join-Path $PSScriptRoot common.ps1) $Language = $Language.ToLower() @@ -233,150 +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)/packages" | Where-Object -FilterScript {$_.Name.EndsWith(".nupkg") -and -not $_.Name.EndsWith(".symbols.nupkg")} - $PublishedDocs = Get-ChildItem "$($DocLocation)" | Where-Object -FilterScript {$_.Name.StartsWith("Docs.")} - - foreach ($Item in $PublishedDocs) { - $PkgName = $Item.Name.Remove(0, 5) - $PkgFullName = $PublishedPkgs | Where-Object -FilterScript {$_.Name -match "$($PkgName).\d"} - - if (($PkgFullName | Measure-Object).count -eq 1) - { - $DocVersion = $PkgFullName[0].BaseName.Remove(0, $PkgName.Length + 1) - - Write-Host "Start Upload for $($PkgName)/$($DocVersion)" - Write-Host "DocDir $($Item)" - Write-Host "PkgName $($PkgName)" - Write-Host "DocVersion $($DocVersion)" - $releaseTag = RetrieveReleaseTag "Nuget" $PublicArtifactLocation - Upload-Blobs -DocDir "$($Item)" -PkgName $PkgName -DocVersion $DocVersion -ReleaseTag $releaseTag - } - else - { - Write-Host "Package with the same name Exists. Upload Skipped" - continue - } - } -} - -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 \ No newline at end of file