Skip to content

Build Windows Binary #6

Build Windows Binary

Build Windows Binary #6

Workflow file for this run

name: Build Windows Binary
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to build (e.g., v5.3.20)'
required: true
type: string
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
jobs:
build-windows:
name: Build Windows x64
runs-on: windows-latest
steps:
- name: Checkout code at tag
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: Patch Cargo.toml for Windows compatibility
run: |
$content = Get-Content Cargo.toml -Raw
# The home crate v0.5.12 requires unstable edition2024
# Patch Cargo.toml to constrain home version for older tags
if ($content -notmatch 'home\s*=') {
$content = $content -replace '(\[dependencies\])', "`$1`nhome = `">=0.5.4, <0.5.12`" # Pin to avoid v0.5.12 which requires unstable edition2024"
Write-Host "Added home crate constraint to Cargo.toml"
} else {
Write-Host "home crate already specified in Cargo.toml"
}
# Enable bundled feature for rusqlite on Windows to avoid needing sqlite3.lib
if ($content -match '(?m)^rusqlite\s*=\s*"[^"]+"$' -and $content -notmatch 'rusqlite.*bundled') {
$content = $content -replace '(?m)^rusqlite\s*=\s*"([^"]+)"$', 'rusqlite = { version = "$1", features = ["bundled"] }'
Write-Host "Enabled bundled feature for rusqlite"
} else {
Write-Host "rusqlite already has features configured or bundled is enabled"
}
Set-Content Cargo.toml $content
Write-Host "Final Cargo.toml dependencies section:"
Get-Content Cargo.toml | Select-String -Pattern "rusqlite|home" -Context 0,0
shell: pwsh
- name: Build release binary
run: cargo build --release --target x86_64-pc-windows-msvc --verbose
- name: Rename binary
run: |
copy target\x86_64-pc-windows-msvc\release\database-replicator.exe database-replicator-windows-x64.exe
shell: cmd
- name: Upload to release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload ${{ inputs.tag }} database-replicator-windows-x64.exe --clobber