update build-to-release.yml for rust

This commit is contained in:
amd64fox 2025-10-27 20:20:12 +03:00
parent e67831bc47
commit b434d93a7d
2 changed files with 58 additions and 28 deletions

View file

@ -1,4 +1,4 @@
name: Build Windows LoaderSpot name: Build Windows LoaderSpot UI
on: on:
workflow_dispatch: workflow_dispatch:
@ -8,34 +8,60 @@ jobs:
runs-on: windows-latest runs-on: windows-latest
strategy: strategy:
matrix: matrix:
architecture: [x86, x64] include:
- arch: x86
rust_target: i686-pc-windows-msvc
- arch: x64
rust_target: x86_64-pc-windows-msvc
- arch: arm64
rust_target: aarch64-pc-windows-msvc
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
- name: Set up Python - name: Install Rust toolchain and target
uses: actions/setup-python@v6 uses: actions-rs/toolchain@v1
with: with:
python-version: '3.13' toolchain: stable
architecture: ${{ matrix.architecture }} profile: minimal
override: true
- name: Install dependencies targets: ${{ matrix.rust_target }}
- name: Build release binary
env:
RUST_TARGET: ${{ matrix.rust_target }}
ARCH: ${{ matrix.arch }}
shell: pwsh
run: | run: |
python -m pip install --upgrade pip # fail on first error
pip install aiohttp Set-PSDebug -Strict
pip install tqdm # build release for target
pip install pyinstaller Write-Host "Building target: $env:RUST_TARGET"
cargo build --manifest-path LoaderSpot_UI/Cargo.toml --release --target $env:RUST_TARGET
- name: Build executable
run: | # prepare artifacts folder
pyinstaller --onefile --clean --name LoaderSpot_${{ matrix.architecture }} LoaderSpot.py $out = "artifacts"
if (Test-Path $out) { Remove-Item $out -Recurse -Force }
New-Item -ItemType Directory -Path $out | Out-Null
# locate produced executable in target/<target>/release
$exePath = Join-Path -Path "LoaderSpot_UI" -ChildPath (Join-Path -Path "target" -ChildPath (Join-Path -Path $env:RUST_TARGET -ChildPath "release"))
Write-Host "Searching for exe in: $exePath"
$exe = Get-ChildItem -Path $exePath -Filter "*.exe" -File -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $exe) {
Write-Error "Executable not found in $exePath"
exit 1
}
Copy-Item $exe.FullName -Destination "$out\loaderspot_ui_${env:ARCH}.exe" -Force
Compress-Archive -Path "$out\loaderspot_ui_${env:ARCH}.exe" -DestinationPath "$out\loaderspot_ui_${env:ARCH}.zip" -Force
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v5 uses: actions/upload-artifact@v5
with: with:
name: LoaderSpot_${{ matrix.architecture }} name: loaderspot_ui_${{ matrix.arch }}
path: dist/LoaderSpot_${{ matrix.architecture }}.exe path: artifacts/loaderspot_ui_${{ matrix.arch }}.zip
- name: Get latest release - name: Get latest release
id: latest_release id: latest_release
uses: actions/github-script@v8 uses: actions/github-script@v8
@ -45,20 +71,24 @@ jobs:
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo repo: context.repo.repo
}); });
if (!releases.data || releases.data.length === 0) {
core.setFailed('No releases found for repository');
}
return releases.data[0].id; return releases.data[0].id;
result-encoding: string result-encoding: string
- name: Upload to Release - name: Upload to Release
uses: actions/github-script@v8 uses: actions/github-script@v8
with: with:
script: | script: |
const fs = require('fs'); const fs = require('fs');
const releaseId = ${{ steps.latest_release.outputs.result }}; const releaseId = parseInt('${{ steps.latest_release.outputs.result }}', 10);
const path = `artifacts/loaderspot_ui_${{ matrix.arch }}.zip`;
const content = fs.readFileSync(path);
await github.rest.repos.uploadReleaseAsset({ await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
release_id: releaseId, release_id: releaseId,
name: `LoaderSpot_${{ matrix.architecture }}.exe`, name: `loaderspot_ui_${{ matrix.arch }}.zip`,
data: fs.readFileSync(`dist/LoaderSpot_${{ matrix.architecture }}.exe`) data: content
}); });

View file

@ -1,7 +1,7 @@
[package] [package]
name = "spotify_finder" name = "spotify_finder"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2025"
[dependencies] [dependencies]
eframe = "0.29" eframe = "0.29"