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
name: release
on:
release:
types:
# The default GITHUB_TOKEN is contents:read in many repos. softprops/action-gh-release
# needs contents:write to attach assets to the release. Without this we get
# "Resource not accessible by integration" at upload time.
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
jobs:
build-windows:
name: Build and attach Windows artifacts to release
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: x86_64-pc-windows-msvc
- uses: Swatinem/rust-cache@v2
# cargo-wix is a thin wrapper around WiX Toolset 3 (preinstalled
# on windows-latest at C:\Program Files (x86)\WiX Toolset v3.*\bin
# and on PATH). It builds an MSI from wix/main.wxs.
- name: Install cargo-wix
run: cargo install --locked cargo-wix --version "^0.3"
- name: Build release binary
run: cargo build --release --locked
# Build the MSI installer. --no-build skips the redundant
# cargo build (we just did it) and reuses target/release/keyhop.exe.
# Output: target/wix/Keyhop-<version>-x86_64.msi
- name: Build MSI installer
run: cargo wix --no-build --nocapture
# Surface the produced asset paths into env vars so the upload
# step doesn't have to glob them. cargo-wix's output filename
# encodes the package version, so this also acts as a sanity
# check that Cargo.toml and the release tag agree.
- name: Locate artifacts
id: artifacts
shell: pwsh
run: |
$msi = Get-ChildItem -Path target/wix -Filter "Keyhop-*-x86_64.msi" | Select-Object -First 1
if (-not $msi) { throw "No MSI produced under target/wix" }
$exe = "target/release/keyhop.exe"
if (-not (Test-Path $exe)) { throw "No keyhop.exe at $exe" }
"msi=$($msi.FullName)" >> $env:GITHUB_OUTPUT
"exe=$exe" >> $env:GITHUB_OUTPUT
Write-Host "MSI: $($msi.FullName) ($([math]::Round($msi.Length/1MB,2)) MB)"
Write-Host "EXE: $exe"
- name: Attach binaries to GitHub Release
uses: softprops/action-gh-release@v3
with:
files: |
${{ steps.artifacts.outputs.exe }}
${{ steps.artifacts.outputs.msi }}
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}