-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add GitHub Actions workflows for build and release #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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/**/* | ||
|
|
||
| winget: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,11 @@ authors = ["Niccolò Betto <[email protected]>"] | |
| edition = "2021" | ||
| license = "MIT" | ||
|
|
||
| [profile.release] | ||
| strip = true # Automatically strip symbols from the binary. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||
|
|
||
There was a problem hiding this comment.
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
-releasepart from the executable name? I'd like the release artifact to just be calledwsl-usb-manager.exe.