Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
chore(publishing): fix commit hash links in changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderCow committed May 9, 2017
1 parent 7e112fa commit f069cc0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ function Main {
Write-Host "Release version will be $releaseVersion"

$outChangelogFile = "$outDir\changelog.md"
Generate-Changelog $pluginApiVersion $tshockVersion $terrariaVersion $outChangelogFile
$gitHubUrl = "https://github.com/$gitHubUser/$gitHubRepoName"
Generate-Changelog $pluginApiVersion $tshockVersion $terrariaVersion $outChangelogFile $gitHubUrl

$outZipFile = "$outDir\" + ($outZipFileNameFormat -f $releaseVersion,$terrariaVersion,$pluginApiVersion)
Package-Files $outZipFile
Expand All @@ -113,10 +114,10 @@ function Main {

Write-Host "Publishing to GitHub..."
Create-GitHubRelease $releaseVersion $outChangelogFile $outZipFile
Start-Process "https://github.com/$gitHubUser/$gitHubRepoName/releases"
Start-Process "$gitHubUrl/releases"

Write-Host "Updating TShock resource..."
Update-TShockResource $releaseVersion $terrariaVersion $pluginApiVersion $outChangelogFile
Update-TShockResource $releaseVersion $terrariaVersion $pluginApiVersion $outChangelogFile $gitHubUrl
Start-Process "$tshockResourceUri/updates"
}

Expand Down Expand Up @@ -149,13 +150,13 @@ function Update-AssemblyVersion {
GitVersion.exe /updateassemblyinfo $assemblyInfoPath | ConvertFrom-Json
}

function Generate-Changelog($pluginApiVersion, $tshockVersion, $terrariaVersion, $outChangelogFile) {
function Generate-Changelog($pluginApiVersion, $tshockVersion, $terrariaVersion, $outChangelogFile, $gitHubUrl) {
if (Test-Path $outChangelogFile) {
Remove-Item -Force $outChangelogFile
}

# clog builds a markdown changelog from all commits since the last tag
clog.exe --from-latest-tag --setversion $releaseVersion --outfile $outChangelogFile
clog.exe --from-latest-tag --setversion $releaseVersion --outfile $outChangelogFile --repository $gitHubUrl

# add some custom lines to the changelog
if ($isPrerelease) {
Expand Down Expand Up @@ -208,7 +209,7 @@ function Create-GitHubRelease($releaseVersion, $outChangelogFile, $outZipFile) {
GitReleaseManager.exe publish -u $gitHubUser -p $gitHubPassword -o $gitHubRepoOwner -r $gitHubRepoName -t $releaseVersion
}

function Update-TShockResource($releaseVersion, $terrariaVersion, $pluginApiVersion, $changelogFile) {
function Update-TShockResource($releaseVersion, $terrariaVersion, $pluginApiVersion, $changelogFile, $gitHubUrl) {
$tshockPassword = Read-Host "Enter password for TShock XenForo user $tshockUser"

# Invoke-WebRequest: https://msdn.microsoft.com/powershell/reference/5.1/microsoft.powershell.utility/Invoke-WebRequest
Expand Down Expand Up @@ -257,13 +258,12 @@ function Update-TShockResource($releaseVersion, $terrariaVersion, $pluginApiVers
$formHtmlElement = $response.ParsedHtml.IHTMLDocument3_getElementsByTagName("form") | Where { $_.action.EndsWith("/save-version") }

$fields = Construct-FormFields $response $formHtmlElement
$fields["download-url"] = "https://github.com/$gitHubUser/$gitHubRepoName/releases/tag/$releaseVersion"
$fields["download-url"] = "$gitHubUrl/releases/tag/$releaseVersion"
$fields["version-string"] = $releaseVersion
$fields["title"] = "$releaseVersion Update"

$changelogMarkdown = Get-Content $changelogFile
# remove commit hashes
$changelogMarkdown = $changelogMarkdown -replace "\(\[[A-Za-z0-9]+\]\([A-Za-z0-9]+\)\)",""
$fields["message_html"] = Convert-MarkdownToHtml $changelogMarkdown

# post update
Expand Down

0 comments on commit f069cc0

Please sign in to comment.