Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build

on:
workflow_dispatch:
workflow_call:

push:
branches:
- "*"

pull_request:
branches:
- "*"

jobs:
build:
name: Build (${{ matrix.type }})
runs-on: windows-latest
strategy:
matrix:
include:
- type: debug
args: ""
artifacts: |
target/debug/*.exe
target/debug/*.pdb

- type: release
args: --release
artifacts: |
target/release/*.exe

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Build Cache
uses: actions/cache@v4
id: build-cache
with:
path: |
target/*/*.exe
target/*/*.pdb
key: windows-latest-${{ matrix.type }}-${{ hashFiles('./Cargo.*', './*.rs', 'img/*', 'img/**/*', 'resources/*', 'resources/**/*', 'src/*', 'src/**/*') }}

- name: Cargo Cache
uses: actions/cache@v4
if: ${{ steps.build-cache.outputs.cache-hit != 'true' }}
with:
path: |
~/.cargo/
target/
key: windows-latest-${{ matrix.type }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: windows-latest-${{ matrix.type }}-cargo-

- name: Cargo Build
if: ${{ steps.build-cache.outputs.cache-hit != 'true' }}
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.args }}

- name: Artifact Upload
uses: actions/upload-artifact@v4
with:
name: wsl-usb-manager-${{ matrix.type }}
path: ${{ matrix.artifacts }}
if-no-files-found: error
52 changes: 52 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release

on:
release:
types: published

jobs:
build:
uses: ./.github/workflows/build.yaml

release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write

steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
pattern: '*-release'
path: artifacts

- name: Release Artifact Upload
uses: softprops/action-gh-release@v2
with:
files: artifacts/**/*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this action works, but is there any way to strip the -release part from the executable name? I'd like the release artifact to just be called wsl-usb-manager.exe.


winget:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't want this job yet in the repo, I'd suggest to drop it for now so that we can merge the rest of the CI and then once winget is in place, we can re-add it later on.

runs-on: ubuntu-latest
needs: release

steps:
- name: Check if WINGET_TOKEN is present
id: check_secret
run: |
if [ -z "${{ secrets.WINGET_TOKEN }}" ]; then
echo "WINGET_TOKEN is not set"
echo "winget_token_present=false" >> $GITHUB_ENV
else
echo "WINGET_TOKEN is present"
echo "winget_token_present=true" >> $GITHUB_ENV
fi
- name: Submit to winget
id: winget_deploy
uses: vedantmgoyal9/winget-releaser@main
if: env.winget_token_present == 'true'
with:
identifier: nickbeth.wsl-usb-manager
installers-regex: '\.exe$'
fork-user: ${{ secrets.WINGET_FORK_USER }}
token: ${{ secrets.WINGET_TOKEN }}
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ authors = ["Niccolò Betto <[email protected]>"]
edition = "2021"
license = "MIT"

[profile.release]
strip = true # Automatically strip symbols from the binary.
Copy link
Owner

@nickbeth nickbeth Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no real reason to strip debugging symbols from the binary, even for release builds. The executable is already very small, and in the past I had to debug a release build of the app, symbols were really useful in that situation.

lto = true # Enable link time optimization.
codegen-units = 1 # Limit codegen units to 1 for better optimization.

[dependencies]
windows-sys = { version = "0.52.0", features = [
"Win32_Devices_DeviceAndDriverInstallation",
Expand Down