89 lines
2.4 KiB
YAML
89 lines
2.4 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
release:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
platform:
|
|
- os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
name: Windows-x64
|
|
|
|
runs-on: ${{ matrix.platform.os }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.platform.target }}
|
|
|
|
|
|
- name: Rust cache
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: './src-tauri -> target'
|
|
|
|
- name: Install Tauri CLI
|
|
run: cargo install tauri-cli --version "^2.0.0" --locked
|
|
|
|
- name: Build Tauri app
|
|
working-directory: ./src-tauri
|
|
run: cargo tauri build --verbose
|
|
|
|
|
|
- name: Get version from tag
|
|
id: get_version
|
|
shell: bash
|
|
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Prepare release files (Windows)
|
|
if: matrix.platform.os == 'windows-latest'
|
|
shell: pwsh
|
|
run: |
|
|
New-Item -Path "release" -ItemType Directory -Force
|
|
# 获取版本号
|
|
$version = "${env:GITHUB_REF}" -replace "refs/tags/v", ""
|
|
|
|
# 复制并重命名 MSI 文件
|
|
Get-ChildItem -Path "src-tauri/target/release/bundle/msi/*.msi" -ErrorAction SilentlyContinue | ForEach-Object {
|
|
$newName = "UPX-Tools-${version}-x64.msi"
|
|
Copy-Item $_.FullName -Destination "release/$newName"
|
|
Write-Host "Created: $newName"
|
|
}
|
|
|
|
# 复制并重命名 NSIS 文件
|
|
Get-ChildItem -Path "src-tauri/target/release/bundle/nsis/*.exe" -ErrorAction SilentlyContinue | ForEach-Object {
|
|
$newName = "UPX-Tools-${version}-x64-setup.exe"
|
|
Copy-Item $_.FullName -Destination "release/$newName"
|
|
Write-Host "Created: $newName"
|
|
}
|
|
|
|
Get-ChildItem -Path "release/" -Recurse | ForEach-Object { Write-Host $_.Name }
|
|
|
|
|
|
- name: Upload release assets
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: release/*
|
|
draft: false
|
|
prerelease: false
|
|
generate_release_notes: true
|
|
fail_on_unmatched_files: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|