From def28dd5188b594fdbd576eea4cbbfef65dac69f Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Mon, 4 Jan 2021 12:07:02 -0800 Subject: [PATCH 1/4] Update latest folder with one index.html includes the redirect links --- eng/common/scripts/copy-docs-to-blobstorage.ps1 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/eng/common/scripts/copy-docs-to-blobstorage.ps1 b/eng/common/scripts/copy-docs-to-blobstorage.ps1 index 9e6ddf81077..25ea55d81fe 100644 --- a/eng/common/scripts/copy-docs-to-blobstorage.ps1 +++ b/eng/common/scripts/copy-docs-to-blobstorage.ps1 @@ -216,17 +216,21 @@ function Upload-Blobs LogDebug "Uploading $($PkgName)/$($DocVersion) to $($DocDest)..." & $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/$($DocVersion)$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate" - + LogDebug "Handling versioning files under $($DocDest)/$($PkgName)/versioning/" $versionsObj = (Update-Existing-Versions -PkgName $PkgName -PkgVersion $DocVersion -DocDest $DocDest) + $latestVersion = $versionsObj.LatestGAPackage + if (!$latestVersion) { + $latestVersion = $versionsObj.LatestPreviewPackage + } - # we can safely assume we have AT LEAST one version here. Reason being we just completed Update-Existing-Versions - $latestVersion = ($versionsObj.SortedVersionArray | Select-Object -First 1).RawVersion - - if ($UploadLatest -and ($latestVersion -eq $DocVersion)) + # Prepare the index.html which can redirect to the latest GA whenever avaiable, otherwise point to latest preview. + New-Item -Path $DocDir -Name "latest" -ItemType "directory" + New-Item -Path "$($DocDir)/latest" -Name "index.html" -ItemType "file" -Value "" + if ($UploadLatest -and $latestVersion) { LogDebug "Uploading $($PkgName) to latest folder in $($DocDest)..." - & $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate" + & $($AzCopy) cp "$($DocDir)/latest/**" "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate" } } From f923c5b7db1d3297c3727418bad931ff6ba473af Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Mon, 4 Jan 2021 17:45:51 -0800 Subject: [PATCH 2/4] Update the redirect links and remove everything in latest --- eng/common/scripts/copy-docs-to-blobstorage.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/copy-docs-to-blobstorage.ps1 b/eng/common/scripts/copy-docs-to-blobstorage.ps1 index 25ea55d81fe..c9f2dd8fd3f 100644 --- a/eng/common/scripts/copy-docs-to-blobstorage.ps1 +++ b/eng/common/scripts/copy-docs-to-blobstorage.ps1 @@ -223,13 +223,15 @@ function Upload-Blobs if (!$latestVersion) { $latestVersion = $versionsObj.LatestPreviewPackage } - + LogDebug "Fetching the latest version. $latestVersion" # Prepare the index.html which can redirect to the latest GA whenever avaiable, otherwise point to latest preview. New-Item -Path $DocDir -Name "latest" -ItemType "directory" - New-Item -Path "$($DocDir)/latest" -Name "index.html" -ItemType "file" -Value "" + New-Item -Path "$($DocDir)/latest" -Name "index.html" -ItemType "file" -Value "" if ($UploadLatest -and $latestVersion) { LogDebug "Uploading $($PkgName) to latest folder in $($DocDest)..." + # Clean up existing folders, will remove this step once we have one or two release cycles. + & $($AzCopy) rm "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true & $($AzCopy) cp "$($DocDir)/latest/**" "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate" } } From 1bbab5ee7237d9b11fd4c9783819cf3e48f9c4f3 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Tue, 5 Jan 2021 12:42:08 -0800 Subject: [PATCH 3/4] Address feedback --- eng/common/scripts/copy-docs-to-blobstorage.ps1 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/eng/common/scripts/copy-docs-to-blobstorage.ps1 b/eng/common/scripts/copy-docs-to-blobstorage.ps1 index c9f2dd8fd3f..256e5a1b163 100644 --- a/eng/common/scripts/copy-docs-to-blobstorage.ps1 +++ b/eng/common/scripts/copy-docs-to-blobstorage.ps1 @@ -224,19 +224,17 @@ function Upload-Blobs $latestVersion = $versionsObj.LatestPreviewPackage } LogDebug "Fetching the latest version. $latestVersion" - # Prepare the index.html which can redirect to the latest GA whenever avaiable, otherwise point to latest preview. - New-Item -Path $DocDir -Name "latest" -ItemType "directory" - New-Item -Path "$($DocDir)/latest" -Name "index.html" -ItemType "file" -Value "" + if ($UploadLatest -and $latestVersion) { + # Prepare the index.html which can redirect to the latest GA whenever avaiable, otherwise point to latest preview. + New-Item -Path $DocDir -Name "latest" -ItemType "directory" + New-Item -Path "$($DocDir)/latest" -Name "index.html" -ItemType "file" -Value "" LogDebug "Uploading $($PkgName) to latest folder in $($DocDest)..." - # Clean up existing folders, will remove this step once we have one or two release cycles. - & $($AzCopy) rm "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true & $($AzCopy) cp "$($DocDir)/latest/**" "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate" } } - if ($PublishGithubIODocsFn -and (Test-Path "Function:$PublishGithubIODocsFn")) { &$PublishGithubIODocsFn -DocLocation $DocLocation -PublicArtifactLocation $PublicArtifactLocation From 87b7ad0896d14793d79273308fe742ac3501b049 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Tue, 5 Jan 2021 15:51:39 -0800 Subject: [PATCH 4/4] Have the entire copy for latest GA. --- eng/common/scripts/copy-docs-to-blobstorage.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/eng/common/scripts/copy-docs-to-blobstorage.ps1 b/eng/common/scripts/copy-docs-to-blobstorage.ps1 index 256e5a1b163..c4dfb1894cf 100644 --- a/eng/common/scripts/copy-docs-to-blobstorage.ps1 +++ b/eng/common/scripts/copy-docs-to-blobstorage.ps1 @@ -223,15 +223,12 @@ function Upload-Blobs if (!$latestVersion) { $latestVersion = $versionsObj.LatestPreviewPackage } - LogDebug "Fetching the latest version. $latestVersion" + LogDebug "Fetching the latest version $latestVersion" - if ($UploadLatest -and $latestVersion) + if ($UploadLatest -and ($latestVersion -eq $DocVersion)) { - # Prepare the index.html which can redirect to the latest GA whenever avaiable, otherwise point to latest preview. - New-Item -Path $DocDir -Name "latest" -ItemType "directory" - New-Item -Path "$($DocDir)/latest" -Name "index.html" -ItemType "file" -Value "" LogDebug "Uploading $($PkgName) to latest folder in $($DocDest)..." - & $($AzCopy) cp "$($DocDir)/latest/**" "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate" + & $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate" } }