-
Notifications
You must be signed in to change notification settings - Fork 1
125 lines (103 loc) · 5.03 KB
/
Copy pathrelease.yml
File metadata and controls
125 lines (103 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
# Pinned to the windows-2022 image (not windows-latest): that image guarantees a working
# VS2022 MSBuild install. windows-latest has moved on to a newer default VS whose MSBuild
# can't resolve Microsoft.NET.Sdk for this project (see the Setup MSBuild step below).
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
with:
# Pinned to VS2022's MSBuild: windows-latest runners now also carry a newer VS whose
# MSBuild can't resolve Microsoft.NET.Sdk for this project (its own bundled Sdks folder
# is missing Microsoft.NET.Sdk), and setup-msbuild's default "pick latest" selects that
# broken one instead of the working VS2022 toolchain every prior release used.
vs-version: "[17.0,18.0)"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build test project
# Built via MSBuild (not "dotnet build"/"dotnet test"): the dotnet SDK's own MSBuild
# fails on Trainer.resx's binary resources (MSB3822/MSB3823, missing
# System.Resources.Extensions), which the full Visual Studio MSBuild toolchain
# handles natively for this legacy .NET Framework 4.0 project.
run: msbuild A2G-Trainer-XP.Tests/A2G-Trainer-XP.Tests.csproj /t:Restore,Build /p:Configuration=Release
- name: Run tests
run: dotnet test A2G-Trainer-XP.Tests/A2G-Trainer-XP.Tests.csproj --configuration Release --no-build --no-restore
- name: Inject version from tag
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$versionPart = $tag -replace '^v', ''
$numericPart = ($versionPart -split '-')[0]
$segments = @($numericPart -split '\.')
while ($segments.Count -lt 4) { $segments += '0' }
$assemblyVersion = ($segments[0..3] -join '.')
$content = @"
using System.Reflection;
[assembly: AssemblyVersion("$assemblyVersion")]
[assembly: AssemblyFileVersion("$assemblyVersion")]
[assembly: AssemblyInformationalVersion("$versionPart")]
"@
Set-Content -Path Properties/VersionInfo.cs -Value $content -Encoding utf8
- name: Build Trainer (standard)
run: msbuild A2G-Trainer-XP.csproj /restore /t:Rebuild /p:Configuration=Release /p:Platform=x86
- name: Build Trainer (2007 CD)
run: msbuild A2G-Trainer-XP.csproj /restore /t:Rebuild /p:Configuration=Release2007CD /p:Platform=x86
- name: Package binaries
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item "bin\x86\Release\A2G-Trainer-XP.exe" "dist\A2G-Trainer-XP-$tag.exe"
Copy-Item "bin\x86\Release2007CD\A2G-Trainer-XP.exe" "dist\A2G-Trainer-XP-$tag-2007CD.exe"
Copy-Item "A2G-Trainer-XP.ct" "dist\A2G-Trainer-XP-$tag.ct"
- name: Build GOG cheat table
shell: pwsh
run: ./scripts/Convert-CtToGog.ps1 -InputPath "A2G-Trainer-XP.ct" -OutputPath "dist/A2G-Trainer-XP-${{ github.ref_name }}-GOG.ct"
- name: Generate changelog
shell: pwsh
run: ./scripts/Generate-Changelog.ps1 -Tag "${{ github.ref_name }}"
- name: Render changelog HTML
shell: pwsh
run: ./scripts/New-ChangelogHtml.ps1
- name: Build Latest.zip bundle
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$bundleDir = "dist/bundle"
New-Item -ItemType Directory -Force -Path $bundleDir | Out-Null
Copy-Item "dist\A2G-Trainer-XP-$tag.exe" "$bundleDir\A2G-Trainer-XP.exe"
Copy-Item "dist\A2G-Trainer-XP-$tag-2007CD.exe" "$bundleDir\A2G-Trainer-XP-2007CD.exe"
Copy-Item "dist\A2G-Trainer-XP-$tag.ct" "$bundleDir\A2G-Trainer-XP.ct"
Copy-Item "dist\A2G-Trainer-XP-$tag-GOG.ct" "$bundleDir\A2G-Trainer-XP-GOG.ct"
Copy-Item "dist\Changelog.html" "$bundleDir\Changelog.html"
$zipPath = "dist/A2G-Trainer-XP-Latest.zip"
Compress-Archive -Path "$bundleDir\*" -DestinationPath $zipPath -Force
$hash = (Get-FileHash -Algorithm SHA256 -Path $zipPath).Hash.ToLower()
"$hash A2G-Trainer-XP-Latest.zip" | Set-Content "$zipPath.sha256" -Encoding utf8
- name: Build version manifest
shell: pwsh
run: ./scripts/New-VersionManifest.ps1 -Tag "${{ github.ref_name }}" -Repository "${{ github.repository }}" -ZipShaPath "dist/A2G-Trainer-XP-Latest.zip.sha256"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.exe
dist/*.ct
dist/A2G-Trainer-XP-Latest.zip
dist/A2G-Trainer-XP-Latest.zip.sha256
dist/version*.json
body_path: dist/current-version-notes.md