Skip to content

Commit dfa3b13

Browse files
committed
Sync eng/common directory with azure-sdk-tools repository for Tools PR Azure/azure-sdk-tools#926
1 parent 80c7724 commit dfa3b13

File tree

6 files changed

+75
-4
lines changed

6 files changed

+75
-4
lines changed

eng/common/pipelines/templates/steps/publish-blobs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ parameters:
44
TargetLanguage: ''
55
BlobName: ''
66
ScriptPath: ''
7+
RepoId: ''
8+
ReleaseTag: ''
79

810
steps:
911
- pwsh: |
@@ -21,6 +23,8 @@ steps:
2123
-SASKey "${{ parameters.BlobSASKey }}"
2224
-Language "${{ parameters.TargetLanguage }}"
2325
-BlobName "${{ parameters.BlobName }}"
26+
-RepoReplaceRegex "(https://github.com/${{ parameters.RepoId }}/(?:blob|tree)/)master(/.*)"
27+
-Tag: "${{ parameters.ReleaseTag }}"
2428
pwsh: true
2529
workingDirectory: $(Pipeline.Workspace)
2630
displayName: Copy Docs to Blob

eng/common/scripts/Submit-PullRequest.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ param(
4242

4343
[Parameter(Mandatory = $true)]
4444
[string]$PRTitle,
45-
4645
$PRBody = $PRTitle,
4746

4847
[Parameter(Mandatory = $false)]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $SDIST_PACKAGE_REGEX = "^(?<package>.*)\-(?<versionstring>$([AzureEngSemanticVer
77
function CreateReleases($pkgList, $releaseApiUrl, $releaseSha) {
88
foreach ($pkgInfo in $pkgList) {
99
Write-Host "Creating release $($pkgInfo.Tag)"
10-
10+
echo "##vso[task.setvariable variable=ReleaseTag;isOutput=true]$($pkgInfo.Tag)"
1111
$releaseNotes = ""
1212
if ($pkgInfo.ReleaseNotes -ne $null) {
1313
$releaseNotes = $pkgInfo.ReleaseNotes
@@ -502,7 +502,7 @@ function CheckArtifactShaAgainstTagsList($priorExistingTagList, $releaseSha, $ap
502502
else {
503503
Write-Host "The artifact SHA $releaseSha does not match that of the currently existing tag."
504504
Write-Host "Tag with issues is $tag with commit SHA $tagSha"
505-
505+
echo "##vso[task.setvariable variable=ReleaseTag;isOutput=true]$tag"
506506
$unmatchedTags += $tag
507507
}
508508
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ param (
77
$Language,
88
$BlobName,
99
$ExitOnError=1,
10-
$UploadLatest=1
10+
$UploadLatest=1,
11+
$RepoReplaceRegex,
12+
$Tag
1113
)
1214

1315
$Language = $Language.ToLower()
@@ -197,6 +199,10 @@ function Upload-Blobs
197199
Write-Host "DocDir $($DocDir)"
198200
Write-Host "Final Dest $($DocDest)/$($PkgName)/$($DocVersion)"
199201

202+
# Use the step to replace master link to release tag link
203+
Write-Host "Replacing all readme master links with release tag $Tag"
204+
ReplaceLink -scanFolder $DocDir -fileSuffix ".html" -replacement $Tag -customRegex $RepoReplaceRegex
205+
200206
Write-Host "Uploading $($PkgName)/$($DocVersion) to $($DocDest)..."
201207
& $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/$($DocVersion)$($SASKey)" --recursive=true
202208

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
param (
2+
# url list to verify links. Can either be a http address or a local file request. Local file paths support md and html files.
3+
[string] $sourceDir,
4+
# file that contains a set of links to ignore when verifying
5+
[string] $ignoreLinksFile = "$PSScriptRoot/ignore-links.txt",
6+
# switch that will enable devops specific logging for warnings
7+
[switch] $devOpsLogging = $false,
8+
[string] $branchReplaceRegex = "(https://github.com/.*/(?:blob|tree)/)master(/.*)",
9+
# the substitute branch name or SHA commit
10+
[string] $releaseTag = ""
11+
)
12+
13+
$regexOptions = [System.Text.RegularExpressions.RegexOptions]"Singleline, IgnoreCase";
14+
15+
function ReplaceLink ($scanFolder, $fileSuffix, $replacement, $customRegex) {
16+
$regex = new-object System.Text.RegularExpressions.Regex ($branchReplaceRegex, $regexOptions)
17+
if ($customRegex) {
18+
$regex = new-object System.Text.RegularExpressions.Regex ($customRegex, $regexOptions)
19+
}
20+
if (!$fileSuffix) {
21+
Write-Error "Please provide at least one file extension to scan against."
22+
}
23+
$replacementPattern = "`${2}$replacement`$3"
24+
if (!$replacement) {
25+
Write-Error "Please provide the replacement string to replace with."
26+
}
27+
if ($scanFolder) {
28+
$fileSuffixArray = $fileSuffix -split ","
29+
$url = @()
30+
31+
foreach ($fileExtension in $fileSuffixArray) {
32+
$fileRegex = "*" + $fileSuffix.Trim()
33+
$urls += Get-ChildItem -Path "$scanFolder/*" -Recurse -Include $fileRegex
34+
}
35+
36+
if ($urls.Count -eq 0) {
37+
Write-Host "Usage $($MyInvocation.MyCommand.Name) <urls>";
38+
return;
39+
}
40+
$needTochange = @{}
41+
foreach ($url in $urls) {
42+
while ((Get-Content -Path $url) -match $regex) {
43+
Write-Verbose "We have master link matches in page $url"
44+
$needTochange[$url] = $true
45+
(Get-Content -Path $url) -replace $regex, $replacementPattern | Set-Content -Path $url
46+
}
47+
}
48+
foreach ($page in $needTochange.Keys) {
49+
Write-Host "There are replacements in page $page"
50+
}
51+
}
52+
}
53+
54+
#ReplaceLink -scanFolder $sourceDir -replacement $releaseTag -fileSuffix ".html"

eng/common/scripts/update-docs-metadata.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ param (
1717
. (Join-Path $PSScriptRoot artifact-metadata-parsing.ps1)
1818
. (Join-Path $PSScriptRoot SemVer.ps1)
1919

20+
$releaseReplaceRegex = "(https://github.com/$RepoId/(?:blob|tree)/)master(/.*)"
21+
2022
function GetMetaData($lang){
2123
switch ($lang) {
2224
"java" {
@@ -75,6 +77,12 @@ function GetAdjustedReadmeContent($pkgInfo, $lang){
7577
if ($headerContentMatches) {
7678
$foundTitle = $headerContentMatches.Matches[0]
7779
$fileContent = $pkgInfo.ReadmeContent -replace $foundTitle, "$foundTitle - Version $($pkgInfo.PackageVersion) `n"
80+
# Replace github master link with release tag.
81+
$regex = new-object System.Text.RegularExpressions.Regex ($releaseReplaceRegex,
82+
[System.Text.RegularExpressions.RegexOptions]"Singleline, IgnoreCase")
83+
84+
$ReplacementPattern = "`${1}$($pkgInfo.Tag)`$2"
85+
$fileContent = $fileContent -replace $regex, $ReplacementPattern
7886
}
7987

8088
$header = "---`ntitle: $foundTitle`nkeywords: Azure, $lang, SDK, API, $($pkgInfo.PackageId), $service`nauthor: maggiepint`nms.author: magpint`nms.date: $date`nms.topic: article`nms.prod: azure`nms.technology: azure`nms.devlang: $lang`nms.service: $service`n---`n"

0 commit comments

Comments
 (0)