Skip to content

Commit 5663cb4

Browse files
author
BF6 Portal Developer
committed
CI: automate GitHub releases on tags
1 parent c5f1bda commit 5663cb4

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
- "*.*.*"
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build-windows:
14+
name: Build Windows installer
15+
runs-on: windows-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 18
25+
cache: npm
26+
27+
- name: Install root deps
28+
run: npm ci
29+
30+
- name: Install web_ui deps
31+
run: npm ci --prefix web_ui
32+
33+
- name: Build web_ui
34+
run: npm run build --prefix web_ui
35+
36+
- name: Build Electron (Windows)
37+
run: npm run dist -- --win
38+
39+
- name: Normalize artifact names
40+
shell: pwsh
41+
run: |
42+
$ErrorActionPreference = 'Stop'
43+
44+
# Find the NSIS installer (file name may contain spaces)
45+
$setup = Get-ChildItem -Path dist -Filter "*Setup*.exe" -File | Select-Object -First 1
46+
if (-not $setup) {
47+
throw "Could not find installer in dist/ (expected *Setup*.exe)."
48+
}
49+
50+
$setupOut = Join-Path (Resolve-Path dist) 'BF6Portal-Tool-Setup.exe'
51+
Copy-Item -Force $setup.FullName $setupOut
52+
53+
# Zip win-unpacked (optional)
54+
$unpacked = Join-Path (Resolve-Path dist) 'win-unpacked'
55+
if (Test-Path $unpacked) {
56+
$zipOut = Join-Path (Resolve-Path dist) 'BF6Portal-Tool-win-unpacked.zip'
57+
if (Test-Path $zipOut) { Remove-Item -Force $zipOut }
58+
Compress-Archive -Path (Join-Path $unpacked '*') -DestinationPath $zipOut
59+
}
60+
61+
"SETUP_PATH=$setupOut" | Out-File -FilePath $env:GITHUB_ENV -Append
62+
63+
- name: Prepare release notes
64+
shell: pwsh
65+
run: |
66+
$ErrorActionPreference = 'Stop'
67+
$tag = "${{ github.ref_name }}"
68+
$version = $tag
69+
if ($version.StartsWith('v')) { $version = $version.Substring(1) }
70+
71+
$notesPath = "docs/RELEASE_NOTES_$version.md"
72+
if (Test-Path $notesPath) {
73+
Copy-Item -Force $notesPath release_body.md
74+
} else {
75+
@(
76+
"# Release $tag",
77+
"",
78+
"Automated GitHub release for tag **$tag**.",
79+
"",
80+
"If you maintain versioned notes, add `docs/RELEASE_NOTES_$version.md` to populate this automatically."
81+
) | Set-Content -Encoding UTF8 release_body.md
82+
}
83+
84+
- name: Create GitHub Release
85+
uses: softprops/action-gh-release@v2
86+
with:
87+
body_path: release_body.md
88+
files: |
89+
dist/BF6Portal-Tool-Setup.exe
90+
dist/BF6Portal-Tool-win-unpacked.zip
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)