Skip to content

Commit eb28279

Browse files
committed
Convert Markdown to HTML for updating LatestVersion.json
1 parent c51cb3d commit eb28279

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.azure-pipelines/templates/update-github-version.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,19 @@ stages:
4747
echo "✗ Failed to fetch ChangeLog.md or file is empty"
4848
exit 1
4949
fi
50-
5150
echo "✓ ChangeLog.md fetched successfully"
52-
CHANGELOG_CONTENT=$(cat changelog.md | base64 -w 0)
51+
52+
echo "Converting Markdown to HTML..."
53+
python3 -m pip install --quiet markdown
54+
python3 -c "import markdown; content = open('changelog.md', encoding='utf-8').read(); html = markdown.markdown(content, extensions=['fenced_code', 'tables', 'nl2br']); open('changelog.html', 'w', encoding='utf-8').write(html)"
55+
56+
if [ ! -s changelog.html ]; then
57+
echo "✗ Failed to convert ChangeLog.md to HTML"
58+
exit 1
59+
fi
60+
echo "✓ ChangeLog.md converted to HTML"
61+
62+
CHANGELOG_CONTENT=$(base64 -w 0 changelog.html)
5363
echo "##vso[task.setvariable variable=CHANGELOG_B64]$CHANGELOG_CONTENT"
5464
displayName: 'Fetch ChangeLog.md'
5565
condition: succeeded()
@@ -173,7 +183,7 @@ stages:
173183
-replace '\\', '\\' `
174184
-replace '"', '\"' `
175185
-replace "`n", '\n' `
176-
-replace "`r", '\r' `
186+
-replace "`r", '' `
177187
-replace "`t", '\t'
178188
$line = $indent + '"Changes": "' + $escaped + '"'
179189
}
@@ -189,7 +199,7 @@ stages:
189199
$newContent = ($updatedLines -join "`n")
190200
$contentBytes = [System.Text.Encoding]::UTF8.GetBytes($newContent)
191201
$contentBase64 = [System.Convert]::ToBase64String($contentBytes)
192-
$commitMessage = "Update $buildType to v$versionMajor.$versionMinor.$versionPatch via Azure Pipeline"
202+
$commitMessage = "Update $buildType to v$versionMajor.$versionMinor.$versionPatch via Azure Pipelines"
193203
194204
$updateBody = @{
195205
message = $commitMessage

0 commit comments

Comments
 (0)