-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (112 loc) · 3.62 KB
/
build-and-release.yml
File metadata and controls
128 lines (112 loc) · 3.62 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
126
127
128
name: Build and Release
on:
push:
branches:
- release
jobs:
build:
name: Build (${{ matrix.platform }})
runs-on: windows-latest
strategy:
matrix:
platform: [x64, x86, ARM64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Read version from vbproj
id: version
shell: pwsh
run: |
[xml]$proj = Get-Content "NTPilot.vbproj"
$ver = $proj.Project.PropertyGroup[0].Version
if (-not $ver) { $ver = "1.0.0" }
echo "VERSION=$ver" >> $env:GITHUB_ENV
echo "TAG=v$ver" >> $env:GITHUB_ENV
echo "version=$ver" >> $env:GITHUB_OUTPUT
- name: Restore
run: dotnet restore NTPilot.vbproj -p:Platform=${{ matrix.platform }}
- name: Build (${{ matrix.platform }})
run: >
dotnet build NTPilot.vbproj
-c Release
-p:Platform=${{ matrix.platform }}
--no-restore
- name: Rename output
shell: pwsh
run: |
$dst = "NTPilot_${{ matrix.platform }}.exe"
$candidates = @(
"bin\Release\net481\NTPilot.exe",
"bin\Release\net481\${{ matrix.platform }}\NTPilot.exe",
"bin\${{ matrix.platform }}\Release\net481\NTPilot.exe"
)
foreach ($path in $candidates) {
if (Test-Path $path) {
Copy-Item $path $dst
break
}
}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: NTPilot_${{ matrix.platform }}
path: NTPilot_${{ matrix.platform }}.exe
- name: Upload version metadata
if: matrix.platform == 'x64'
uses: actions/upload-artifact@v4
with:
name: version-meta
path: CHANGELOG.md
release:
name: Create GitHub Release
needs: build
runs-on: windows-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Download version metadata
uses: actions/download-artifact@v4
with:
name: version-meta
- name: Read version
id: version
shell: pwsh
run: |
$file = Get-ChildItem "NTPilot_x64.exe"
$ver = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($file.FullName).FileVersion
if (-not $ver) { $ver = "1.0.0" }
# Remove trailing .0 only for 4-segment versions (e.g. 1.0.0.0 -> 1.0.0)
if ($ver -match '^\d+\.\d+\.\d+\.0$') { $ver = $ver -replace '\.0$', '' }
echo "TAG=v$ver" >> $env:GITHUB_ENV
- name: Extract release notes from CHANGELOG.md
id: notes
shell: pwsh
run: |
$content = Get-Content "CHANGELOG.md" -Raw
# Match the first ## [x.y.z] section
if ($content -match '(?ms)^## \[\d+\.\d+\.\d+\][^\n]*\n(.*?)(?=^## \[|\z)') {
$notes = $Matches[1].Trim()
} else {
$notes = "See CHANGELOG.md for details."
}
$notes | Out-File "release_notes.txt" -Encoding utf8
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG }}
name: Release ${{ env.TAG }}
body_path: release_notes.txt
draft: false
prerelease: false
files: |
NTPilot_x64.exe
NTPilot_x86.exe
NTPilot_ARM64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}