Skip to content

WebGAL Dedup v0.1.0

WebGAL Dedup v0.1.0 #2

Workflow file for this run

name: release build
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_name:
description: 'Tag/Version to build (defaults to Cargo.toml version)'
required: false
default: ''
build_all:
description: 'Build all architectures'
type: boolean
default: true
permissions:
contents: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux-x86_64
target: x86_64-unknown-linux-gnu
- os: macos-latest
platform: macos-x86_64
target: x86_64-apple-darwin
- os: windows-latest
platform: windows-x86_64
target: x86_64-pc-windows-msvc
- os: macos-latest
platform: macos-aarch64
target: aarch64-apple-darwin
- os: windows-latest
platform: windows-aarch64
target: aarch64-pc-windows-msvc
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
# 版本获取
- name: Get version (bash)
if: matrix.os != 'windows-latest'
shell: bash
run: |
if [ -n "${{ github.event.inputs.tag_name }}" ]; then
VERSION="${{ github.event.inputs.tag_name }}"
elif [ -n "${{ github.event.release.tag_name }}" ]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION=$(awk -F'"' '/^[[:space:]]*version[[:space:]]*=/{print $2; exit}' Cargo.toml)
fi
VERSION="${VERSION#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Building version: $VERSION"
- name: Get version (PowerShell)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$version = ""
if ('${{ github.event.inputs.tag_name }}' -ne '') {
$version = '${{ github.event.inputs.tag_name }}'
} elseif ('${{ github.event.release.tag_name }}' -ne '') {
$version = '${{ github.event.release.tag_name }}'
}
if ([string]::IsNullOrEmpty($version)) {
$s = Get-Content Cargo.toml -Raw
if ($s -match 'version\s*=\s*"([^"]+)"') { $version = $matches[1] }
}
$version = $version -replace '^v', ''
Add-Content -Path $env:GITHUB_ENV -Value ("VERSION=$version")
Write-Host "Building version: $version"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Build wgddp-cli
shell: bash
run: |
cargo build --release --target ${{ matrix.target }} -p wgddp-cli
- name: Strip binary (linux and macos)
if: matrix.os != 'windows-latest'
shell: bash
run: |
BIN_PATH="target/${{ matrix.target }}/release/wgddp-cli"
case "${{ matrix.target }}" in
aarch64-unknown-linux-gnu)
sudo apt-get install -y gcc-aarch64-linux-gnu
aarch64-linux-gnu-strip "$BIN_PATH" || true
;;
*)
strip "$BIN_PATH" || true
;;
esac
- name: Prepare package (bash)
if: matrix.os != 'windows-latest'
shell: bash
run: |
set -e
# 准备一个空目录用于打包
PKG_DIR="webgal-dedup-pkg"
rm -rf "$PKG_DIR"
mkdir -p "$PKG_DIR"
# 复制 README 和 LICENSE
cp README.md LICENSE "$PKG_DIR/" 2>/dev/null || true
# 复制并重命名二进制
BIN_SRC="target/${{ matrix.target }}/release/wgddp-cli"
BIN_DST="$PKG_DIR/webgal-dedup"
cp "$BIN_SRC" "$BIN_DST"
# 压缩
cd "$PKG_DIR"
zip -r "../webgal-dedup-${VERSION}-${{ matrix.platform }}.zip" .
cd ..
echo "Created: webgal-dedup-${VERSION}-${{ matrix.platform }}.zip"
- name: Prepare package (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$pkgDir = "webgal-dedup-pkg"
Remove-Item -Recurse -Force $pkgDir -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path $pkgDir -Force | Out-Null
# 复制 README 和 LICENSE
Copy-Item -Path README.md, LICENSE -Destination $pkgDir -Force -ErrorAction SilentlyContinue
# 复制并重命名 exe
$binSrc = "target\${{ matrix.target }}\release\wgddp-cli.exe"
$binDst = "$pkgDir\webgal-dedup.exe"
Copy-Item -Path $binSrc -Destination $binDst -Force
# 压缩
$zip = "webgal-dedup-$env:VERSION-${{ matrix.platform }}.zip"
Compress-Archive -Path "$pkgDir\*" -DestinationPath $zip -Force
Write-Host "Created: $zip"
- name: Upload asset to Release (if triggered by release)
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: webgal-dedup-${{ env.VERSION }}-${{ matrix.platform }}.zip
asset_name: webgal-dedup-${{ env.VERSION }}-${{ matrix.platform }}.zip
asset_content_type: application/zip
- name: Upload artifact (manual trigger)
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: webgal-dedup-${{ env.VERSION }}-${{ matrix.platform }}
path: webgal-dedup-${{ env.VERSION }}-${{ matrix.platform }}.zip
retention-days: 7