|
2 | 2 | [string]$version |
3 | 3 | ) |
4 | 4 |
|
5 | | -$version_underscored = $version -replace '\.', '_' |
6 | | -$setup_link = "https://github.com/Ellendar/Z2Randomizer/releases/download/$version/Z2Randomizer_${version_underscored}.msi" |
| 5 | +$setup_link = "https://github.com/Ellendar/Z2Randomizer/releases/download/$version/Z2Randomizer-$version-Windows-Installer.msi" |
7 | 6 | $pub_date = Get-Date -Format "dddd, dd MMMM yyyy" |
8 | 7 |
|
9 | | -# Update appcast.xml |
10 | 8 | $file = "appcast.xml" |
11 | 9 | $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 | 10 | 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 = @" |
| 11 | + Write-Host "Version $version already exists in appcast.xml" |
| 12 | +} else { |
| 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 | + $app_cast_item = @" |
24 | 18 | <item> |
25 | 19 | <title>Version $version</title> |
26 | 20 | <description> |
27 | 21 | <![CDATA[ |
28 | | - See the <a href=""https://github.com/Ellendar/Z2Randomizer/blob/main/PatchNotes.md"">changelog</a> for details about new features. |
| 22 | + See the <a href="https://github.com/Ellendar/Z2Randomizer/blob/main/PatchNotes.md">changelog</a> for details about new features. |
29 | 23 | ]]> |
30 | 24 | </description> |
31 | 25 | <pubDate>$pub_date</pubDate> |
32 | | - <enclosure url=""$setup_link"" sparkle:version=""$version"" /> |
| 26 | + <enclosure url="$setup_link" sparkle:version="$version" /> |
33 | 27 | </item> |
34 | 28 | "@ |
35 | | - |
36 | | -Set-Content $file ($before + $app_cast_item + $after) |
| 29 | + Set-Content $file ($before + $app_cast_item + $after) |
| 30 | +} |
| 31 | +git add $file |
37 | 32 |
|
38 | 33 | $file = "Directory.Build.targets" |
39 | 34 | (Get-Content $file) | |
40 | 35 | ForEach-Object { |
41 | 36 | $_ -replace '<Version>.*?</Version>', "<Version>$version</Version>" |
42 | 37 | } | Set-Content $file |
| 38 | +git add $file |
43 | 39 |
|
44 | 40 | $file = "README.md" |
45 | 41 | (Get-Content $file) | |
46 | 42 | ForEach-Object { |
47 | 43 | $_ -replace '\[Download\]\([^)]*\)', "[Download]($setup_link)" |
48 | 44 | } | Set-Content $file |
| 45 | +git add $file |
49 | 46 |
|
50 | 47 | $file = "Setup1/Setup1.vdproj" |
51 | 48 | (Get-Content $file) | |
52 | 49 | ForEach-Object { |
53 | 50 | $_ -replace '"ProductVersion"\s*=\s*"8:.*?"', "`"ProductVersion`" = `"8:$version`"" |
54 | 51 | } | Set-Content $file |
| 52 | +git add $file |
55 | 53 |
|
56 | | -#git add . |
57 | | -#git commit -m "Update version to $version" |
| 54 | +# Only commit if some change was actually staged (to prevent setting error level) |
| 55 | +if (git diff --cached --name-only) { |
| 56 | + git commit -m "$version Release" |
| 57 | +} |
0 commit comments