Skip to content

Commit 3c210b3

Browse files
committed
Create UpdateVersion.ps1 script to simplify upgrading versions
1 parent 306a66e commit 3c210b3

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

UpdateVersion.ps1

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
param(
2+
[string]$version
3+
)
4+
5+
$version_underscored = $version -replace '\.', '_'
6+
$setup_link = "https://github.com/Ellendar/Z2Randomizer/releases/download/$version/Z2Randomizer_${version_underscored}.msi"
7+
$pub_date = Get-Date -Format "dddd, dd MMMM yyyy"
8+
9+
# Update appcast.xml
10+
$file = "appcast.xml"
11+
$content = Get-Content $file
12+
13+
$firstMatch = $content | Select-String -Pattern '^\s*<item>' | Select-Object -First 1
14+
$index = $firstMatch.LineNumber - 1
15+
$before = $content[0..($index - 1)]
16+
$after = $content[$index..($content.Length - 1)]
17+
18+
if ($content -like "*<title>Version $version</title>*") {
19+
Write-Host "Version $version already exists in appcast.xml - ending."
20+
exit 0
21+
}
22+
23+
$app_cast_item = @"
24+
<item>
25+
<title>Version $version</title>
26+
<description>
27+
<![CDATA[
28+
See the <a href=""https://github.com/Ellendar/Z2Randomizer/blob/main/PatchNotes.md"">changelog</a> for details about new features.
29+
]]>
30+
</description>
31+
<pubDate>$pub_date</pubDate>
32+
<enclosure url=""$setup_link"" sparkle:version=""$version"" />
33+
</item>
34+
"@
35+
36+
Set-Content $file ($before + $app_cast_item + $after)
37+
38+
$file = "Directory.Build.targets"
39+
(Get-Content $file) |
40+
ForEach-Object {
41+
$_ -replace '<Version>.*?</Version>', "<Version>$version</Version>"
42+
} | Set-Content $file
43+
44+
$file = "README.md"
45+
(Get-Content $file) |
46+
ForEach-Object {
47+
$_ -replace '\[Download\]\([^)]*\)', "[Download]($setup_link)"
48+
} | Set-Content $file
49+
50+
$file = "Setup1/Setup1.vdproj"
51+
(Get-Content $file) |
52+
ForEach-Object {
53+
$_ -replace '"ProductVersion"\s*=\s*"8:.*?"', "`"ProductVersion`" = `"8:$version`""
54+
} | Set-Content $file
55+
56+
#git add .
57+
#git commit -m "Update version to $version"

0 commit comments

Comments
 (0)