This repository was archived by the owner on Sep 6, 2025. It is now read-only.
chore: add CargoPackageVersion variable to MSI build process for mias… #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- name: Cache cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build release | |
run: cargo build --release --locked --features ui | |
- name: Bundle app (macOS) | |
if: runner.os == 'macOS' | |
run: | | |
cargo install cargo-bundle --locked || true | |
# cargo-bundle uses --profile; avoid combining --release with --profile internally | |
# use --package (-k) to select package (cargo-bundle uses -k/--package) | |
# prefer --release shorthand instead of --profile to avoid duplicate/profile conflicts | |
cargo bundle -k miassistant-gui --features ui --release | |
- name: Package (Linux/macOS) | |
if: runner.os != 'Windows' | |
shell: bash | |
run: | | |
set -eux | |
mkdir -p dist | |
cp target/release/miassistant-cli dist/ || true | |
cp target/release/miassistant-gui dist/ || true | |
if [ "$RUNNER_OS" = "macOS" ]; then | |
APP="target/release/bundle/osx/miassistant-gui.app" | |
if [ -d "$APP" ]; then | |
# Create DMG | |
hdiutil create -volname "MiAssistantTool" -srcfolder "$APP" -ov -format UDZO miassistant-macOS.dmg | |
fi | |
fi | |
cp README.md dist/ | |
tar -czf miassistant-${{ runner.os }}.tar.gz -C dist . | |
- name: Package (Windows) | |
if: runner.os == 'Windows' | |
shell: pwsh | |
run: | | |
New-Item -ItemType Directory -Force -Path dist | Out-Null | |
Copy-Item target\release\miassistant-cli.exe dist\ | |
Copy-Item target\release\miassistant-gui.exe dist\ | |
Copy-Item README.md dist\ | |
Compress-Archive -Path dist\* -DestinationPath miassistant-Windows.zip | |
- name: Build MSI (Windows) | |
if: runner.os == 'Windows' | |
shell: pwsh | |
run: | | |
rustup toolchain install stable | |
cargo install cargo-wix --locked | |
choco install wixtoolset --no-progress -y | |
# Build MSI for GUI package | |
# Extract package version from Cargo metadata and pass it to wix/candle as a preprocessor var | |
$meta = cargo metadata --format-version 1 --no-deps --manifest-path crates/gui/Cargo.toml | ConvertFrom-Json | |
$ver = ($meta.packages | Where-Object { $_.name -eq 'miassistant-gui' }).version | |
Write-Host "Building MSI for miassistant-gui version $ver" | |
# Use cargo-wix's --install-version to set MSI version instead of forwarding defines | |
# Define CargoPackageVersion variable used in main.wxs | |
cargo wix -p miassistant-gui --nocapture --install-version $ver -C -dCargoPackageVersion=$ver | |
Copy-Item target\wix\miassistant-gui-*.msi .\miassistant-Windows.msi | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package-${{ runner.os }} | |
path: | | |
miassistant-*.zip | |
miassistant-*.tar.gz | |
miassistant-*.dmg | |
miassistant-*.msi | |
publish: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: package-* | |
path: ./artifacts | |
merge-multiple: true | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: artifacts/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |