Skip to content

Commit 1db6170

Browse files
committed
Add release workflow for tagged builds
1 parent e4b8f41 commit 1db6170

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: Build and Draft Release
14+
runs-on: windows-latest
15+
defaults:
16+
run:
17+
shell: pwsh
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.x'
28+
29+
- name: Set up MSBuild
30+
uses: microsoft/setup-msbuild@v2
31+
32+
- name: Install vcpkg
33+
run: |
34+
$vcpkgRoot = Join-Path $env:RUNNER_TEMP 'vcpkg'
35+
git clone --depth 1 https://github.com/microsoft/vcpkg $vcpkgRoot
36+
& "$vcpkgRoot\bootstrap-vcpkg.bat"
37+
Add-Content -Path $env:GITHUB_ENV -Value "VCPKG_ROOT=$vcpkgRoot"
38+
39+
- name: Build Release binaries
40+
run: |
41+
msbuild "src\WORR-kex.sln" /m /t:Build /p:Configuration=Release /p:Platform=x64
42+
43+
- name: Package artifacts
44+
run: |
45+
$dist = Join-Path $PWD 'dist'
46+
if (Test-Path $dist) { Remove-Item $dist -Recurse -Force }
47+
New-Item -ItemType Directory -Path $dist | Out-Null
48+
49+
$package = Join-Path $dist 'package'
50+
New-Item -ItemType Directory -Path $package | Out-Null
51+
52+
Copy-Item 'game_x64.dll' -Destination $package -ErrorAction Stop
53+
if (Test-Path 'game_x64.pdb') { Copy-Item 'game_x64.pdb' -Destination $package }
54+
if (Test-Path 'game_x64.map') { Copy-Item 'game_x64.map' -Destination $package }
55+
56+
$zipPath = Join-Path $dist ("WORR-kex-${{ github.ref_name }}.zip")
57+
Compress-Archive -Path (Join-Path $package '*') -DestinationPath $zipPath
58+
59+
$checksumPath = Join-Path $dist 'SHA256SUMS'
60+
$files = @()
61+
$files += Get-Item $zipPath
62+
$files += Get-ChildItem $package -File
63+
$files | ForEach-Object {
64+
$hash = Get-FileHash $_.FullName -Algorithm SHA256
65+
"$($hash.Hash) $($_.Name)"
66+
} | Set-Content $checksumPath
67+
68+
- name: Upload workflow artifacts
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: WORR-kex-${{ github.ref_name }}
72+
path: |
73+
dist/WORR-kex-${{ github.ref_name }}.zip
74+
dist/SHA256SUMS
75+
76+
- name: Prepare release notes
77+
run: |
78+
$checksum = (Get-Content 'dist/SHA256SUMS' -Raw).Trim()
79+
$content = @'
80+
## Summary
81+
- _Add key highlights for this release._
82+
83+
## Features
84+
- _Summarize newly added capabilities._
85+
86+
## Fixes
87+
- _Note important fixes and improvements._
88+
89+
## Checksums
90+
```text
91+
{{CHECKSUMS}}
92+
```
93+
'@
94+
$content = $content -replace '{{CHECKSUMS}}', $checksum
95+
$content = $content.TrimStart()
96+
Set-Content -Path 'dist/RELEASE_TEMPLATE.md' -Value $content
97+
98+
- name: Draft GitHub release
99+
uses: softprops/action-gh-release@v2
100+
with:
101+
draft: true
102+
tag_name: ${{ github.ref_name }}
103+
name: WORR-kex ${{ github.ref_name }}
104+
body_path: dist/RELEASE_TEMPLATE.md
105+
files: |
106+
dist/WORR-kex-${{ github.ref_name }}.zip
107+
dist/SHA256SUMS
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)