mirror of
https://github.com/jmcorgan/fips.git
synced 2026-07-30 19:46:15 +00:00
Drop the `tui`, `ble`, and `gateway` cargo features and replace them with platform cfg gates. Plain `cargo build` now produces every subsystem appropriate for the target platform with no feature flags required. Motivation: - `default = ["tui", "ble"]` broke `cargo build` on macOS and Windows because `ble` pulled in `bluer` (BlueZ, Linux-only). Every non-Linux packager needed `--no-default-features`. - The feature flags on `ble` and `gateway` were redundant with their platform-gated deps (`bluer`, `rustables`). The parallel gating was inconsistent and error-prone. - `tui` feature protected against a ratatui binary-size concern that no longer applies in 2026. Cargo.toml: - Remove `tui`, `ble`, `gateway` features; `default = []`. - Promote `ratatui` to a non-optional top-level dependency. - Move `rustables` from top-level optional into the Linux target block, non-optional. - Split `bluer` into its own target block with `cfg(all(target_os = "linux", not(target_env = "musl")))` — BlueZ isn't available on musl router targets and `libdbus-sys` doesn't cross-compile to musl without pkg-config sysroot setup. - Drop `required-features` from the `fipstop` and `fips-gateway` `[[bin]]` entries. build.rs: - Emit a `bluer_available` custom cfg when `target_os == "linux"` and `target_env != "musl"`, for use in place of the verbose full predicate in source cfg gates. Source: - Replace every `#[cfg(feature = "gateway")]` with `#[cfg(target_os = "linux")]`. Gateway code works on both glibc and musl Linux (rustables is fine on musl). - Replace every `#[cfg(feature = "ble")]` with `#[cfg(bluer_available)]`. BLE-specific code (BluerIo module, bluer type conversions, BLE transport instance creation, resolve_ble_addr) is excluded on musl and non-Linux. Generic `BleAddr`, `BleIo` trait, `MockBleIo`, and `BleTransport<I>` still compile on all targets. - `src/bin/fips-gateway.rs`: always compiled, but `main()` is gated to Linux. Non-Linux stub exits 1 with a diagnostic. Existing non-Linux packaging scripts don't ship it, so the stub binary sits unused. Packaging and CI: - Drop `--features` and `--no-default-features` flags from every packaging script and workflow. Defaults now match each platform's capabilities. - AUR `fips-git` automatically aligns with stable `PKGBUILD` (both build with defaults). Verified: `cargo build --release` with no flags produces all four binaries on glibc Linux; all unit and integration tests pass across Linux/macOS/Windows/OpenWrt (musl) in CI.
159 lines
4.5 KiB
YAML
159 lines
4.5 KiB
YAML
name: Windows Package
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- maint
|
|
- next
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
determine-versioning:
|
|
runs-on: windows-latest
|
|
outputs:
|
|
package_version: ${{ steps.version.outputs.package_version }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Derive package version
|
|
id: version
|
|
shell: pwsh
|
|
run: |
|
|
$cargoToml = Get-Content Cargo.toml -Raw
|
|
if ($cargoToml -match 'version\s*=\s*"([^"]+)"') {
|
|
$baseVersion = $Matches[1]
|
|
} else {
|
|
throw "Could not determine version from Cargo.toml"
|
|
}
|
|
|
|
if ($env:GITHUB_REF -like "refs/tags/*") {
|
|
$version = $env:GITHUB_REF_NAME -replace '^v', ''
|
|
} else {
|
|
$branch = $env:GITHUB_REF_NAME -replace '[^A-Za-z0-9]', '.' -replace '\.\.+', '.' -replace '^\.|\.$$', ''
|
|
$height = git rev-list --count HEAD
|
|
$hash = git rev-parse --short HEAD
|
|
if (-not $branch) { $branch = "ref" }
|
|
$version = "$baseVersion+$branch.$height.$hash"
|
|
}
|
|
|
|
echo "package_version=$version" >> $env:GITHUB_OUTPUT
|
|
|
|
build:
|
|
name: Build Windows package
|
|
runs-on: windows-latest
|
|
needs: determine-versioning
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set SOURCE_DATE_EPOCH from git
|
|
shell: pwsh
|
|
run: |
|
|
$epoch = git log -1 --format=%ct
|
|
echo "SOURCE_DATE_EPOCH=$epoch" >> $env:GITHUB_ENV
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Cache Cargo registry + build
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: windows-release-x86_64-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
windows-release-x86_64-
|
|
|
|
- name: Build release binaries
|
|
run: cargo build --release
|
|
|
|
- name: Build Windows package
|
|
shell: pwsh
|
|
run: |
|
|
powershell -File packaging/windows/build-zip.ps1 `
|
|
-Version "${{ needs.determine-versioning.outputs.package_version }}" `
|
|
-NoBuild
|
|
|
|
- name: SHA-256 hash
|
|
shell: pwsh
|
|
run: |
|
|
Write-Host "==> Windows release asset:"
|
|
Get-ChildItem deploy\fips-*-windows-*.zip | ForEach-Object {
|
|
Get-FileHash $_.FullName -Algorithm SHA256 | Format-Table -AutoSize
|
|
}
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: fips_${{ needs.determine-versioning.outputs.package_version }}_x86_64_windows
|
|
path: deploy/fips-*-windows-*.zip
|
|
retention-days: 30
|
|
|
|
- name: Build summary
|
|
shell: pwsh
|
|
run: |
|
|
$pkg = Get-ChildItem deploy\fips-*-windows-*.zip | Select-Object -First 1
|
|
Write-Host "Build Summary for Windows/x86_64:"
|
|
Write-Host " Package: $($pkg.Name)"
|
|
Write-Host " Size: $([math]::Round($pkg.Length / 1MB, 2)) MB"
|
|
|
|
release:
|
|
name: Publish Windows assets to GitHub Release
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Download Windows artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: dist
|
|
merge-multiple: true
|
|
|
|
- name: Generate Windows release checksums
|
|
run: |
|
|
cd dist
|
|
find . -maxdepth 1 -type f -name '*.zip' -printf '%P\n' \
|
|
| LC_ALL=C sort \
|
|
| xargs sha256sum \
|
|
> checksums-windows.txt
|
|
|
|
- name: Wait for tag release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
for attempt in $(seq 1 20); do
|
|
if gh release view "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
|
|
exit 0
|
|
fi
|
|
echo "Release ${GITHUB_REF_NAME} not available yet; waiting..."
|
|
sleep 15
|
|
done
|
|
|
|
echo "Timed out waiting for release ${GITHUB_REF_NAME}" >&2
|
|
exit 1
|
|
|
|
- name: Upload Windows assets
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
gh release upload "${GITHUB_REF_NAME}" \
|
|
dist/*.zip \
|
|
dist/checksums-windows.txt \
|
|
--clobber \
|
|
--repo "${GITHUB_REPOSITORY}"
|