Skip to content

Commit 4cdb8bb

Browse files
committed
Add Windows release workflow
1 parent 5477dff commit 4cdb8bb

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
15+
jobs:
16+
windows:
17+
name: Windows x64
18+
runs-on: windows-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Install Rust
25+
shell: pwsh
26+
run: |
27+
rustup toolchain install stable --profile minimal
28+
rustup default stable
29+
rustc -Vv
30+
cargo -Vv
31+
32+
- name: Cache cargo
33+
uses: actions/cache@v4
34+
with:
35+
path: |
36+
~/.cargo/registry
37+
~/.cargo/git
38+
src-tauri/target
39+
key: windows-cargo-${{ hashFiles('src-tauri/Cargo.lock') }}
40+
restore-keys: |
41+
windows-cargo-
42+
43+
- name: Build release executable
44+
working-directory: src-tauri
45+
run: cargo build --release
46+
47+
- name: Package executable
48+
shell: pwsh
49+
run: |
50+
$tag = if ($env:GITHUB_REF_TYPE -eq "tag") { $env:GITHUB_REF_NAME } else { "manual-$env:GITHUB_RUN_NUMBER" }
51+
New-Item -ItemType Directory -Force dist | Out-Null
52+
Copy-Item src-tauri/target/release/caps.exe "dist/CAPS-$tag-windows-x64.exe"
53+
Get-FileHash "dist/CAPS-$tag-windows-x64.exe" -Algorithm SHA256 |
54+
ForEach-Object { "$($_.Hash) CAPS-$tag-windows-x64.exe" } |
55+
Set-Content "dist/CAPS-$tag-windows-x64.exe.sha256"
56+
57+
- name: Upload workflow artifact
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: CAPS-windows-x64
61+
path: dist/*
62+
63+
- name: Publish GitHub release assets
64+
if: github.ref_type == 'tag'
65+
shell: pwsh
66+
env:
67+
GH_TOKEN: ${{ github.token }}
68+
run: |
69+
$tag = $env:GITHUB_REF_NAME
70+
gh release view $tag *> $null
71+
if ($LASTEXITCODE -ne 0) {
72+
gh release create $tag --title $tag --notes "Windows x64 build for CAPS $tag."
73+
}
74+
gh release upload $tag "dist/CAPS-$tag-windows-x64.exe" "dist/CAPS-$tag-windows-x64.exe.sha256" --clobber

0 commit comments

Comments
 (0)