feat(desktop): multi-OS and multi-arch build support

This commit is contained in:
xxnuo
2026-01-10 00:29:20 +08:00
parent 554a68b18a
commit 9dd9ecf777
2 changed files with 39 additions and 29 deletions

View File

@@ -43,7 +43,10 @@ jobs:
path: dist/mtranserver-*
build-desktop:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -57,22 +60,32 @@ jobs:
run: bun install
- name: Sync version from tag
shell: bash
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION="v$(cat package.json | grep '"version"' | head -1 | sed 's/.*"version": "\(.*\)".*/\1/')"
VERSION="v$(grep '"version"' package.json | head -1 | sed 's/.*"version": "\(.*\)".*/\1/')"
fi
echo "Syncing version to ${VERSION}"
bun run bump ${VERSION}
- name: Build Desktop
run: bun run build:electron -- --linux --win --mac
- name: Build Desktop (Linux)
if: matrix.os == 'ubuntu-latest'
run: bun run build:electron -- --linux
- name: Build Desktop (Windows)
if: matrix.os == 'windows-latest'
run: bun run build:electron -- --win
- name: Build Desktop (macOS)
if: matrix.os == 'macos-latest'
run: bun run build:electron -- --mac
- name: Upload Desktop Artifacts
uses: actions/upload-artifact@v4
with:
name: desktop-artifacts
name: desktop-${{ matrix.os }}
path: release/mtranserver-desktop-*
release:
@@ -93,27 +106,10 @@ jobs:
- name: Download Desktop Artifacts
uses: actions/download-artifact@v4
with:
name: desktop-artifacts
pattern: desktop-*
path: release-assets
merge-multiple: true
- name: Sync version from tag
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
fi
echo "Syncing version to ${VERSION}"
# We need bun to run bump, or just manually update if bun is not setup.
# But we haven't setup bun in release job yet.
# Let's rely on string manipulation for the body generation or setup bun.
# The previous release job logic read from package.json.
# If we don't bump, package.json has old version.
# So we should probably setup bun and bump, or just use the VERSION variable directly in the script below.
# But the script below reads package.json again.
# Let's just override the VERSION variable in the script below.
- name: Determine Release Tag
id: tag
run: |
@@ -144,7 +140,9 @@ jobs:
echo "Using version: $VERSION"
if [[ "${{ github.ref_name }}" == *"dev"* ]]; then
WARNING="**This is a development release. DO NOT USE IT!**"$ '\n\n'
WARNING="**This is a development release. DO NOT USE IT!**"$'
'
else
WARNING=""
fi
@@ -233,4 +231,4 @@ jobs:
body_path: release_body.md
files: release-assets/*
draft: false
fail_on_unmatched_files: false
fail_on_unmatched_files: false

View File

@@ -93,7 +93,10 @@
"output": "release"
},
"mac": {
"target": "dmg",
"target": {
"target": "dmg",
"arch": ["x64", "arm64"]
},
"icon": "images/icon.icns"
},
"win": {
@@ -102,9 +105,18 @@
},
"linux": {
"target": [
"AppImage",
"deb",
"rpm"
{
"target": "AppImage",
"arch": ["x64", "arm64"]
},
{
"target": "deb",
"arch": ["x64", "arm64"]
},
{
"target": "rpm",
"arch": ["x64", "arm64"]
}
],
"icon": "images/icon.png"
},