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 and do some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderCow committed May 8, 2017
1 parent 2c1f59e commit f059e48
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ function Main {
Write-Host "Release version will be $releaseVersion"

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

$outZipFile = "$outDir\" + ($outZipFileNameFormat -f $releaseVersion,$terrariaVersion)
Package-Files $outZipFile

Create-Commit $releaseVersion $terrariaVersion
Create-GitHubRelease $releaseVersion $outChangelogFile $outZipFile

Start-Process "https://github.com/$gitHubUser/$gitHubRepoName/releases"
Create-GitHubRelease $releaseVersion $outChangelogFile $outZipFile
Start-Process "$gitHubUrl/releases"
}

function Get-TShockVersion {
Expand All @@ -111,17 +112,13 @@ function Update-AssemblyVersion {
GitVersion.exe /updateassemblyinfo $assemblyInfoPath | ConvertFrom-Json
}

function Generate-Changelog {
$tshockVersion = $args[0]
$terrariaVersion = $args[1]
$outChangelogFile = $args[2]

function Generate-Changelog($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 All @@ -141,20 +138,15 @@ function Generate-Changelog {
}
}

function Package-Files {
$outZipFile = $args[0]

function Package-Files($outZipFile) {
if (Test-Path $outZipFile) {
Remove-Item -Force $outZipFile
}

7z.exe a -y -r -bd -tzip -mx9 $outZipFile $binariesToPublish > $null
}

function Create-Commit {
$releaseVersion = $args[0]
$terrariaVersion = $args[1]

function Create-Commit($releaseVersion, $terrariaVersion) {
$tagName = $tagNameFormat -f $releaseVersion,$terrariaVersion
$commitMessage = $commitMessageFormat -f $releaseVersion,$terrariaVersion

Expand All @@ -163,11 +155,7 @@ function Create-Commit {
git tag --annotate $releaseVersion --message $tagName
}

function Create-GitHubRelease {
$releaseVersion = $args[0]
$outChangelogFile = $args[1]
$outZipFile = $args[2]

function Create-GitHubRelease($releaseVersion, $outChangelogFile, $outZipFile) {
$gitHubPassword = Read-Host "Enter password for GitHub user $gitHubUser"

# This ensures that errors can be seen if they happen
Expand Down

0 comments on commit f059e48

Please sign in to comment.