[feat] add github actions scripts

This commit is contained in:
dijunkun
2025-08-10 00:03:13 +08:00
parent 1a1bbe3e4d
commit f2664daaec
14 changed files with 1134 additions and 22 deletions

258
.github/workflows/other.bak vendored Normal file
View File

@@ -0,0 +1,258 @@
name: Build and Release CrossDesk
on:
push:
branches: [release]
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
# Linux Job with CUDA container
build-linux:
name: Build on (ubuntu + CUDA)
runs-on: ubuntu-22.04
container:
image: nvidia/cuda:12.6.3-devel-ubuntu22.04
options: --user root
defaults:
run:
working-directory: ${{ github.workspace }}
steps:
- name: Install system dependencies
run: |
apt-get update
apt-get install -y \
git \
curl \
unzip \
software-properties-common \
build-essential \
libxcb-randr0-dev \
libxcb-xtest0-dev \
libxcb-xinerama0-dev \
libxcb-shape0-dev \
libxcb-xkb-dev \
libxcb-xfixes0-dev \
libxv-dev \
libxtst-dev \
libasound2-dev \
libsndio-dev \
libxcb-shm0-dev \
libxrandr-dev \
libpulse-dev
add-apt-repository ppa:xmake-io/xmake
apt-get update
apt-get install -y xmake
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache xmake dependencies
uses: actions/cache@v4
with:
path: ~/.xmake/packages
key: linux-xmake-deps-intel-${{ hashFiles('**/xmake.lua') }}
restore-keys: |
linux-xmake-deps-intel-
- name: Build CrossDesk
run: xmake b -vy --root crossdesk
# - name: Package
# run: |
# chmod +x ./scripts/linux/pkg_x86_64.sh
# ./scripts/linux/pkg_x86_64.sh
# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: crossdesk-linux-x86_64
# path: ${{ github.workspace }}/build/linux/x86_64/release/crossdesk
# Non-Linux platforms (macOS, Windows)
build-other:
name: Build on (${{ matrix.runner }} ${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- arch: x86_64
platform: macos
runner: macos-13
cache-key: intel
out-dir: ./build/macosx/x86_64/release/crossdesk
artifact-name: crossdesk-macos-x86_64
package_script: ./scripts/macosx/pkg_x86_64.sh
- arch: arm64
platform: macos
runner: macos-14
cache-key: arm
out-dir: ./build/macosx/arm64/release/crossdesk
artifact-name: crossdesk-macos-arm64
package_script: ./scripts/macosx/pkg_arm64.sh
- arch: x86_64
platform: windows
runner: windows-2022
cache-key: intel
out-dir: ./build/win/x86_64/release/crossdesk
artifact-name: crossdesk-win-x86_64
package_script: ./scripts/windows/nsis_script.nsi
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize submodules
run: git submodule update --init --recursive
- name: Install xmake (macOS)
if: runner.os == 'macOS'
run: brew install xmake
- name: Install xmake (Windows)
if: runner.os == 'Windows'
run: |
Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content
echo "C:\Users\runneradmin\xmake" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Cache xmake dependencies (macOS)
if: runner.os == 'macOS'
uses: actions/cache@v4
with:
path: ~/.xmake/packages
key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }}
restore-keys: |
${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-
- name: Get LOCALAPPDATA path (Windows)
if: runner.os == 'Windows'
id: localappdata
run: |
echo "localappdata=$env:LOCALAPPDATA" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Cache xmake dependencies (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: ${{ steps.localappdata.outputs.localappdata }}\.xmake\packages
key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }}
restore-keys: |
${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-
- name: Build CrossDesk
run: xmake b -vy crossdesk
- name: Package
run: |
chmod +x ${{ matrix.package_script }}
${{ matrix.package_script }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.out-dir }}
# - name: Decode and save certificate
# shell: bash
# run: |
# mkdir -p certs
# echo "${{ secrets.CROSSDESK_CERT_BASE64 }}" | base64 --decode > certs/cert.crt
# - name: Package CrossDesk app
# if: runner.os != 'Windows'
# run: |
# chmod +x ${{ matrix.package_script }}
# ${{ matrix.package_script }}
# - name: Package CrossDesk app (Windows)
# if: runner.os == 'Windows'
# run: "& makensis.exe ${{ matrix.package_script }}"
# working-directory: ${{ github.workspace }}
# - name: Upload build artifacts
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.artifact-name }}-pkg
# path: crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg
# - name: Move files to release dir
# run: |
# mkdir -p release
# cp crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg release/
# release:
# name: Publish Release
# if: startsWith(github.ref, 'refs/tags/v')
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Download all artifacts
# uses: actions/download-artifact@v4
# with:
# path: artifacts
# - name: Extract version number
# id: version
# run: |
# VERSION="${GITHUB_REF##*/}"
# VERSION_NUM="${VERSION#v}"
# echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_OUTPUT
# - name: Rename artifacts
# run: |
# mkdir -p release
# cp artifacts/crossdesk-macos-x86_64-pkg/* release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg
# cp artifacts/crossdesk-macos-arm64-pkg/* release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg
# - name: Upload to Versioned GitHub Release
# uses: softprops/action-gh-release@v2
# with:
# tag_name: v${{ steps.version.outputs.VERSION_NUM }}
# name: Release v${{ steps.version.outputs.VERSION_NUM }}
# draft: false
# prerelease: false
# files: release/*
# generate_release_notes: false
# body: |
# Binary release only. Source code is not included.
# - name: Upload to 'latest' Release
# run: |
# mkdir -p release/latest
# cp release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-x86_64-latest.pkg
# cp release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-aarch64-latest.pkg
# - name: Create or update 'latest' tag
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"
# git tag -f latest
# git push origin latest --force
# - name: Upload to GitHub Release (latest)
# uses: softprops/action-gh-release@v2
# with:
# tag_name: latest
# name: Latest Release
# draft: false
# prerelease: false
# files: |
# release/latest/crossdesk-macos-*.pkg
# generate_release_notes: false
#

132
.github/workflows/release.yaml vendored Normal file
View File

@@ -0,0 +1,132 @@
name: Build and Release CrossDesk
on:
push:
branches: [release]
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
# Linux
build-linux:
name: Build on Ubuntu
runs-on: ubuntu-22.04
container:
image: crossdesk/ubuntu22.04:latest
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build CrossDesk
env:
CUDA_PATH: /usr/local/cuda
XMAKE_GLOBALDIR: /data
run: |
ls -la $XMAKE_GLOBALDIR
xmake b -vy --root crossdesk
# macOS
build-macos:
name: Build on macOS
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- arch: x86_64
runner: macos-13
cache-key: intel
out-dir: ./build/macosx/x86_64/release/crossdesk
artifact-name: crossdesk-macos-x86_64
package_script: ./scripts/macosx/pkg_x86_64.sh
- arch: arm64
runner: macos-14
cache-key: arm
out-dir: ./build/macosx/arm64/release/crossdesk
artifact-name: crossdesk-macos-arm64
package_script: ./scripts/macosx/pkg_arm64.sh
steps:
- name: Cache xmake dependencies
uses: actions/cache@v4
with:
path: ~/.xmake/packages
key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }}
restore-keys: |
${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-
- name: Install xmake
run: brew install xmake
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize submodules
run: git submodule update --init --recursive
- name: Build CrossDesk
run: xmake b -vy crossdesk
# Windows
build-windows:
name: Build on Windows
runs-on: windows-2022
env:
XMAKE_GLOBALDIR: D:\xmake_global
steps:
- name: Cache xmake dependencies
uses: actions/cache@v4
with:
path: D:\xmake_global\.xmake\packages
key: ${{ runner.os }}-xmake-deps-intel-${{ hashFiles('**/xmake.lua') }}
restore-keys: |
${{ runner.os }}-xmake-deps-intel-
- name: Install xmake
run: |
Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content
echo "C:\Users\runneradmin\xmake" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
xmake create cuda
Set-Location cuda
xmake g --theme=plain
$cudaPath = ""
$packagesPath = "D:\xmake_global\.xmake\packages"
if (Test-Path $packagesPath) {
Write-Host "Packages directory exists: $packagesPath"
try {
$info = xmake require --info "cuda 12.6.3" 2>$null
if ($null -ne $info -and $info -ne "") {
$cudaPath = (($info | Select-String installdir).ToString() -replace '.*installdir:\s*','').Trim()
Write-Host "Resolved CUDA_PATH = $cudaPath"
}
} catch {}
} else {
Write-Host "Packages directory not found: $packagesPath"
Write-Host "Installing CUDA package..."
xmake require -vy "cuda 12.6.3"
$info = xmake require --info "cuda 12.6.3"
$cudaPath = (($info | Select-String installdir).ToString() -replace '.*installdir:\s*','').Trim()
Write-Host "Resolved CUDA_PATH = $cudaPath"
}
echo "CUDA_PATH=$cudaPath" >> $env:GITHUB_ENV
Write-Host "Resolved CUDA_PATH = $cudaPath"
Pop-Location
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize submodules
run: git submodule update --init --recursive
- name: Build CrossDesk
run: xmake b -vy crossdesk

213
.github/workflows/release.yaml.bak vendored Normal file
View File

@@ -0,0 +1,213 @@
name: Build and Release CrossDesk
on:
push:
branches: [release]
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: Build on (${{ matrix.runner }} ${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- arch: x86_64
platform: macos
runner: macos-13
cache-key: intel
out-dir: ./build/macosx/x86_64/release/crossdesk
artifact-name: crossdesk-macos-x86_64
package_script: ./scripts/macosx/pkg_x86_64.sh
- arch: arm64
platform: macos
runner: macos-14
cache-key: arm
out-dir: ./build/macosx/arm64/release/crossdesk
artifact-name: crossdesk-macos-arm64
package_script: ./scripts/macosx/pkg_arm64.sh
- arch: x86_64
platform: windows
runner: windows-2022
cache-key: intel
out-dir: ./build/win/x86_64/release/crossdesk
artifact-name: crossdesk-win-x86_64
package_script: ./scripts/windows/nsis_script.nsi
- arch: x86_64
platform: linux
runner: ubuntu-22.04
cache-key: intel
out-dir: ./build/linux/x86_64/release/crossdesk
artifact-name: crossdesk-linux-x86_64
package_script: ./scripts/linux/pkg_x86_64.sh
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize submodules
run: git submodule update --init --recursive
- name: Install xmake
if: runner.os == 'macOS'
run: brew install xmake
- name: Install xmake (Ubuntu)
if: runner.os == 'Linux'
run: |
curl -fsSL https://xmake.io/shget.text | bash
source ~/.xmake/profile
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get -y install \
libxcb-randr0-dev \
libxcb-xtest0-dev \
libxcb-xinerama0-dev \
libxcb-shape0-dev \
libxcb-xkb-dev \
libxcb-xfixes0-dev \
libxv-dev \
libxtst-dev \
libasound2-dev \
libsndio-dev \
libxcb-shm0-dev \
libxrandr-dev \
libpulse-dev
- name: Install xmake (Windows)
if: runner.os == 'Windows'
run: |
Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content
echo "C:\Users\runneradmin\xmake" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Build CrossDesk
run: xmake b -vy crossdesk
- name: Cache xmake dependencies (Linux/macOS)
if: runner.os != 'Windows'
uses: actions/cache@v4
with:
path: ~/.xmake/packages
key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }}
restore-keys: |
${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-
- name: Get LOCALAPPDATA path (Windows)
if: runner.os == 'Windows'
id: localappdata
run: |
echo "localappdata=$env:LOCALAPPDATA" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Cache xmake dependencies (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: ${{ steps.localappdata.outputs.localappdata }}\.xmake\packages
key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }}
restore-keys: |
${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-
# - name: Decode and save certificate
# shell: bash
# run: |
# mkdir -p certs
# echo "${{ secrets.CROSSDESK_CERT_BASE64 }}" | base64 --decode > certs/cert.crt
# - name: Package CrossDesk app
# if: runner.os != 'Windows'
# run: |
# chmod +x ${{ matrix.package_script }}
# ${{ matrix.package_script }}
# - name: Package CrossDesk app (Windows)
# if: runner.os == 'Windows'
# run: "& makensis.exe ${{ matrix.package_script }}"
# working-directory: ${{ github.workspace }}
# - name: Upload build artifacts
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.artifact-name }}-pkg
# path: crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg
# - name: Move files to release dir
# run: |
# mkdir -p release
# cp crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg release/
# release:
# name: Publish Release
# if: startsWith(github.ref, 'refs/tags/v')
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Download all artifacts
# uses: actions/download-artifact@v4
# with:
# path: artifacts
# - name: Extract version number
# id: version
# run: |
# VERSION="${GITHUB_REF##*/}"
# VERSION_NUM="${VERSION#v}"
# echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_OUTPUT
# - name: Rename artifacts
# run: |
# mkdir -p release
# cp artifacts/crossdesk-macos-x86_64-pkg/* release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg
# cp artifacts/crossdesk-macos-arm64-pkg/* release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg
# - name: Upload to Versioned GitHub Release
# uses: softprops/action-gh-release@v2
# with:
# tag_name: v${{ steps.version.outputs.VERSION_NUM }}
# name: Release v${{ steps.version.outputs.VERSION_NUM }}
# draft: false
# prerelease: false
# files: release/*
# generate_release_notes: false
# body: |
# Binary release only. Source code is not included.
# - name: Upload to 'latest' Release
# run: |
# mkdir -p release/latest
# cp release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-x86_64-latest.pkg
# cp release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-aarch64-latest.pkg
# - name: Create or update 'latest' tag
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"
# git tag -f latest
# git push origin latest --force
# - name: Upload to GitHub Release (latest)
# uses: softprops/action-gh-release@v2
# with:
# tag_name: latest
# name: Latest Release
# draft: false
# prerelease: false
# files: |
# release/latest/crossdesk-macos-*.pkg
# generate_release_notes: false

View File

@@ -1,19 +0,0 @@
[signal server]
ip = 150.158.81.30
port = 9099
[stun server]
ip = 150.158.81.30
port = 3478
[turn server]
ip = 150.158.81.30
port = 3478
username = dijunkun
password = dijunkunpw
[hardware acceleration]
turn_on = false
[av1 encoding]
turn_on = true

View File

Before

Width:  |  Height:  |  Size: 687 B

After

Width:  |  Height:  |  Size: 687 B

BIN
icons/crossdesk.icns Normal file

Binary file not shown.

BIN
icons/crossdesk.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 B

BIN
icons/crossdesk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

126
scripts/linux/pkg_x86_64.sh Normal file
View File

@@ -0,0 +1,126 @@
#!/bin/bash
set -e
# 配置变量
APP_NAME="CrossDesk"
APP_VERSION="0.0.1"
ARCHITECTURE="amd64"
MAINTAINER="Junkun Di <junkun.di@hotmail.com>"
DESCRIPTION="A simple cross-platform remote desktop client."
# 目录结构
DEB_DIR="$APP_NAME-$APP_VERSION"
DEBIAN_DIR="$DEB_DIR/DEBIAN"
BIN_DIR="$DEB_DIR/usr/local/bin"
CERT_SRC_DIR="$DEB_DIR/opt/$APP_NAME/certs" # 用于中转安装时分发
ICON_DIR="$DEB_DIR/usr/share/icons/hicolor/256x256/apps"
DESKTOP_DIR="$DEB_DIR/usr/share/applications"
# 清理已有的打包文件夹
rm -rf "$DEB_DIR"
# 创建目录结构
mkdir -p "$DEBIAN_DIR" "$BIN_DIR" "$CERT_SRC_DIR" "$ICON_DIR" "$DESKTOP_DIR"
# 复制二进制文件
cp build/linux/x86_64/release/crossdesk "$BIN_DIR"
# 复制证书文件(将来通过 postinst 拷贝到每个用户 XDG_CONFIG_HOME
cp certs/crossdesk.cn_root.crt "$CERT_SRC_DIR/crossdesk.cn_root.crt"
# 复制图标文件
cp icons/crossdesk.png "$ICON_DIR/crossdesk.png"
# 设置可执行权限
chmod +x "$BIN_DIR/crossdesk"
# 创建 control 文件
cat > "$DEBIAN_DIR/control" << EOF
Package: $APP_NAME
Version: $APP_VERSION
Architecture: $ARCHITECTURE
Maintainer: $MAINTAINER
Description: $DESCRIPTION
Depends: libc6 (>= 2.29), libstdc++6 (>= 9), libx11-6, libxcb1,
libxcb-randr0, libxcb-xtest0, libxcb-xinerama0, libxcb-shape0,
libxcb-xkb1, libxcb-xfixes0, libxv1, libxtst6, libasound2,
libsndio7.0, libxcb-shm0, libpulse0, nvidia-cuda-toolkit
Priority: optional
Section: utils
EOF
# 创建 desktop 文件
cat > "$DESKTOP_DIR/$APP_NAME.desktop" << EOF
[Desktop Entry]
Version=$APP_VERSION
Name=$APP_NAME
Comment=$DESCRIPTION
Exec=/usr/local/bin/crossdesk
Icon=crossdesk
Terminal=false
Type=Application
Categories=Utility;
EOF
# 创建卸载脚本 postrm
cat > "$DEBIAN_DIR/postrm" << EOF
#!/bin/bash
# post-removal script for $APP_NAME
set -e
if [ "\$1" = "remove" ] || [ "\$1" = "purge" ]; then
rm -f /usr/local/bin/crossdesk
rm -f /usr/share/icons/hicolor/256x256/apps/crossdesk.png
rm -f /usr/share/applications/$APP_NAME.desktop
rm -rf /opt/$APP_NAME
fi
exit 0
EOF
chmod +x "$DEBIAN_DIR/postrm"
# 创建安装后脚本 postinst拷贝证书到每个用户 XDG_CONFIG_HOME
cat > "$DEBIAN_DIR/postinst" << 'EOF'
#!/bin/bash
set -e
CERT_SRC="/opt/CrossDesk/certs"
CERT_FILE="crossdesk.cn_root.crt"
# 处理每个普通用户的配置目录
for user_home in /home/*; do
[ -d "$user_home" ] || continue
username=$(basename "$user_home")
config_dir="$user_home/.config/CrossDesk/certs"
target="$config_dir/$CERT_FILE"
if [ ! -f "$target" ]; then
mkdir -p "$config_dir"
cp "$CERT_SRC/$CERT_FILE" "$target"
chown -R "$username:$username" "$user_home/.config/CrossDesk"
echo "✔ Installed cert for $username at $target"
fi
done
# 处理 root 用户(可选)
if [ -d "/root" ]; then
config_dir="/root/.config/CrossDesk/certs"
mkdir -p "$config_dir"
cp "$CERT_SRC/$CERT_FILE" "$config_dir/$CERT_FILE"
chown -R root:root /root/.config/CrossDesk
fi
exit 0
EOF
chmod +x "$DEBIAN_DIR/postinst"
# 构建 .deb 包
dpkg-deb --build "$DEB_DIR"
# 清理构建目录
rm -rf "$DEB_DIR"
echo "✅ Deb package for $APP_NAME created successfully."

152
scripts/macosx/pkg_arm64.sh Normal file
View File

@@ -0,0 +1,152 @@
#!/bin/bash
set -e # 遇错退出
# === 配置变量 ===
APP_NAME="crossdesk"
APP_NAME_UPPER="CrossDesk" # 这个变量用来指定大写的应用名
EXECUTABLE_PATH="./build/macosx/arm64/release/crossdesk" # 可执行文件路径
APP_VERSION="0.0.1"
PLATFORM="macos"
ARCH="arm64"
IDENTIFIER="cn.crossdesk.app"
ICON_PATH="./icons/crossdesk.icns" # .icns 图标路径
MACOS_MIN_VERSION="10.12"
CERTS_SOURCE="./certs" # 你的证书文件目录,里面放所有需要安装的文件
CERT_NAME="crossdesk.cn_root.crt"
APP_BUNDLE="${APP_NAME_UPPER}.app" # 使用大写的应用名称
CONTENTS_DIR="${APP_BUNDLE}/Contents"
MACOS_DIR="${CONTENTS_DIR}/MacOS"
RESOURCES_DIR="${CONTENTS_DIR}/Resources"
PKG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-v${APP_VERSION}.pkg" # 保持安装包名称小写
DMG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-v${APP_VERSION}.dmg"
VOL_NAME="Install ${APP_NAME_UPPER}"
# === 清理旧文件 ===
echo "🧹 清理旧文件..."
rm -rf "${APP_BUNDLE}" "${PKG_NAME}" "${DMG_NAME}" build_pkg_temp CrossDesk_dmg_temp
mkdir -p build_pkg_temp
# === 创建 .app 结构 ===
echo "📦 创建 ${APP_BUNDLE}..."
mkdir -p "${MACOS_DIR}" "${RESOURCES_DIR}"
echo "🚚 拷贝可执行文件..."
cp "${EXECUTABLE_PATH}" "${MACOS_DIR}/${APP_NAME_UPPER}" # 拷贝时使用大写的应用名称
chmod +x "${MACOS_DIR}/${APP_NAME_UPPER}"
# === 图标 ===
if [ -f "${ICON_PATH}" ]; then
cp "${ICON_PATH}" "${RESOURCES_DIR}/crossedesk.icns"
ICON_KEY="<key>CFBundleIconFile</key><string>crossedesk.icns</string>"
echo "🎨 图标添加完成"
else
ICON_KEY=""
echo "⚠️ 未找到图标文件,跳过图标设置"
fi
# === 生成 Info.plist ===
echo "📝 生成 Info.plist..."
cat > "${CONTENTS_DIR}/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<key>CFBundleDisplayName</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<key>CFBundleIdentifier</key>
<string>${IDENTIFIER}</string>
<key>CFBundleVersion</key>
<string>${APP_VERSION}</string>
<key>CFBundleShortVersionString</key>
<string>${APP_VERSION}</string>
<key>CFBundleExecutable</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<key>CFBundlePackageType</key>
<string>APPL</string>
${ICON_KEY}
<key>LSMinimumSystemVersion</key>
<string>${MACOS_MIN_VERSION}</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>应用需要访问摄像头</string>
<key>NSMicrophoneUsageDescription</key>
<string>应用需要访问麦克风</string>
<key>NSAppleEventsUsageDescription</key>
<string>应用需要发送 Apple 事件</string>
<key>NSScreenCaptureUsageDescription</key>
<string>应用需要录屏权限以捕获屏幕内容</string>
</dict>
</plist>
EOF
echo "✅ .app 创建完成"
# === 构建应用组件包 ===
echo "📦 构建应用组件包..."
pkgbuild \
--identifier "${IDENTIFIER}" \
--version "${APP_VERSION}" \
--install-location "/Applications" \
--component "${APP_BUNDLE}" \
build_pkg_temp/${APP_NAME}-component.pkg
# === 构建 certs 组件包 ===
# 先创建脚本目录和脚本文件
mkdir -p scripts
cat > scripts/postinstall <<'EOF'
#!/bin/bash
USER_HOME=$( /usr/bin/stat -f "%Su" /dev/console )
HOME_DIR=$( /usr/bin/dscl . -read /Users/$USER_HOME NFSHomeDirectory | awk '{print $2}' )
DEST="$HOME_DIR/Library/Application Support/CrossDesk/certs"
mkdir -p "$DEST"
cp -R "/Library/Application Support/CrossDesk/certs/"* "$DEST/"
exit 0
EOF
chmod +x scripts/postinstall
# 构建 certs 组件包,增加 --scripts 参数指定 postinstall
pkgbuild \
--root "${CERTS_SOURCE}" \
--identifier "${IDENTIFIER}.certs" \
--version "${APP_VERSION}" \
--install-location "/Library/Application Support/CrossDesk/certs" \
--scripts scripts \
build_pkg_temp/${APP_NAME}-certs.pkg
# === 组合产品包 ===
echo "🏗️ 组合最终安装包..."
productbuild \
--package build_pkg_temp/${APP_NAME}-component.pkg \
--package build_pkg_temp/${APP_NAME}-certs.pkg \
"${PKG_NAME}"
echo "✅ 生成安装包完成:${PKG_NAME}"
# === 可选:打包成 DMG ===
echo "📦 可选打包成 DMG..."
mkdir -p CrossDesk_dmg_temp
cp "${PKG_NAME}" CrossDesk_dmg_temp/
ln -s /Applications CrossDesk_dmg_temp/Applications
hdiutil create -volname "${VOL_NAME}" \
-srcfolder CrossDesk_dmg_temp \
-ov -format UDZO "${DMG_NAME}"
rm -rf CrossDesk_dmg_temp build_pkg_temp scripts ${APP_BUNDLE} ${DMG_NAME}
echo "🎉 所有打包完成:"
echo " ✔️ 应用:${APP_BUNDLE}"
echo " ✔️ 安装包:${PKG_NAME}"
echo " ✔️ 镜像包(可选):${DMG_NAME}"

View File

@@ -0,0 +1,152 @@
#!/bin/bash
set -e # 遇错退出
# === 配置变量 ===
APP_NAME="crossdesk"
APP_NAME_UPPER="CrossDesk" # 这个变量用来指定大写的应用名
EXECUTABLE_PATH="build/macosx/x86_64/release/crossdesk" # 可执行文件路径
APP_VERSION="0.0.1"
PLATFORM="macos"
ARCH="x86_64"
IDENTIFIER="cn.crossdesk.app"
ICON_PATH="icons/crossdesk.icns" # .icns 图标路径
MACOS_MIN_VERSION="10.12"
CERTS_SOURCE="certs" # 你的证书文件目录,里面放所有需要安装的文件
CERT_NAME="crossdesk.cn_root.crt"
APP_BUNDLE="${APP_NAME_UPPER}.app" # 使用大写的应用名称
CONTENTS_DIR="${APP_BUNDLE}/Contents"
MACOS_DIR="${CONTENTS_DIR}/MacOS"
RESOURCES_DIR="${CONTENTS_DIR}/Resources"
PKG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-v${APP_VERSION}.pkg" # 保持安装包名称小写
DMG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-v${APP_VERSION}.dmg"
VOL_NAME="Install ${APP_NAME_UPPER}"
# === 清理旧文件 ===
echo "🧹 清理旧文件..."
rm -rf "${APP_BUNDLE}" "${PKG_NAME}" "${DMG_NAME}" build_pkg_temp CrossDesk_dmg_temp
mkdir -p build_pkg_temp
# === 创建 .app 结构 ===
echo "📦 创建 ${APP_BUNDLE}..."
mkdir -p "${MACOS_DIR}" "${RESOURCES_DIR}"
echo "🚚 拷贝可执行文件..."
cp "${EXECUTABLE_PATH}" "${MACOS_DIR}/${APP_NAME_UPPER}" # 拷贝时使用大写的应用名称
chmod +x "${MACOS_DIR}/${APP_NAME_UPPER}"
# === 图标 ===
if [ -f "${ICON_PATH}" ]; then
cp "${ICON_PATH}" "${RESOURCES_DIR}/crossedesk.icns"
ICON_KEY="<key>CFBundleIconFile</key><string>crossedesk.icns</string>"
echo "🎨 图标添加完成"
else
ICON_KEY=""
echo "⚠️ 未找到图标文件,跳过图标设置"
fi
# === 生成 Info.plist ===
echo "📝 生成 Info.plist..."
cat > "${CONTENTS_DIR}/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<key>CFBundleDisplayName</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<key>CFBundleIdentifier</key>
<string>${IDENTIFIER}</string>
<key>CFBundleVersion</key>
<string>${APP_VERSION}</string>
<key>CFBundleShortVersionString</key>
<string>${APP_VERSION}</string>
<key>CFBundleExecutable</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<key>CFBundlePackageType</key>
<string>APPL</string>
${ICON_KEY}
<key>LSMinimumSystemVersion</key>
<string>${MACOS_MIN_VERSION}</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>应用需要访问摄像头</string>
<key>NSMicrophoneUsageDescription</key>
<string>应用需要访问麦克风</string>
<key>NSAppleEventsUsageDescription</key>
<string>应用需要发送 Apple 事件</string>
<key>NSScreenCaptureUsageDescription</key>
<string>应用需要录屏权限以捕获屏幕内容</string>
</dict>
</plist>
EOF
echo "✅ .app 创建完成"
# === 构建应用组件包 ===
echo "📦 构建应用组件包..."
pkgbuild \
--identifier "${IDENTIFIER}" \
--version "${APP_VERSION}" \
--install-location "/Applications" \
--component "${APP_BUNDLE}" \
build_pkg_temp/${APP_NAME}-component.pkg
# === 构建 certs 组件包 ===
# 先创建脚本目录和脚本文件
mkdir -p scripts
cat > scripts/postinstall <<'EOF'
#!/bin/bash
USER_HOME=$( /usr/bin/stat -f "%Su" /dev/console )
HOME_DIR=$( /usr/bin/dscl . -read /Users/$USER_HOME NFSHomeDirectory | awk '{print $2}' )
DEST="$HOME_DIR/Library/Application Support/CrossDesk/certs"
mkdir -p "$DEST"
cp -R "/Library/Application Support/CrossDesk/certs/"* "$DEST/"
exit 0
EOF
chmod +x scripts/postinstall
# 构建 certs 组件包,增加 --scripts 参数指定 postinstall
pkgbuild \
--root "${CERTS_SOURCE}" \
--identifier "${IDENTIFIER}.certs" \
--version "${APP_VERSION}" \
--install-location "/Library/Application Support/CrossDesk/certs" \
--scripts scripts \
build_pkg_temp/${APP_NAME}-certs.pkg
# === 组合产品包 ===
echo "🏗️ 组合最终安装包..."
productbuild \
--package build_pkg_temp/${APP_NAME}-component.pkg \
--package build_pkg_temp/${APP_NAME}-certs.pkg \
"${PKG_NAME}"
echo "✅ 生成安装包完成:${PKG_NAME}"
# === 可选:打包成 DMG ===
echo "📦 可选打包成 DMG..."
mkdir -p CrossDesk_dmg_temp
cp "${PKG_NAME}" CrossDesk_dmg_temp/
ln -s /Applications CrossDesk_dmg_temp/Applications
hdiutil create -volname "${VOL_NAME}" \
-srcfolder CrossDesk_dmg_temp \
-ov -format UDZO "${DMG_NAME}"
rm -rf CrossDesk_dmg_temp build_pkg_temp scripts ${APP_BUNDLE} ${DMG_NAME}
echo "🎉 所有打包完成:"
echo " ✔️ 应用:${APP_BUNDLE}"
echo " ✔️ 安装包:${PKG_NAME}"
echo " ✔️ 镜像包(可选):${DMG_NAME}"

View File

@@ -0,0 +1,99 @@
; <20>ýű<C3BD>ʹ<EFBFBD><CAB9> HM VNISEdit <20>ű<EFBFBD><C5B1><EFBFBD><E0BCAD><EFBFBD>򵼲<EFBFBD><F2B5BCB2><EFBFBD>
; <20><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><E5B3A3>
!define PRODUCT_NAME "CrossDesk"
!define PRODUCT_VERSION "0.0.1"
!define PRODUCT_PUBLISHER "CrossDesk"
!define PRODUCT_WEB_SITE "https://www.crossdesk.cn/"
!define APP_NAME "CrossDesk"
!define UNINSTALL_REG_KEY "CrossDesk"
;<3B>ﰲװ<EFB0B2><D7B0>ͼ<EFBFBD><CDBC>
Icon "icons\crossdesk.ico"
!define MUI_ICON "icons\crossdesk.ico"
;<3B><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SetCompressor /FINAL lzma
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԱȨ<D4B1>ޣ<EFBFBD>д<EFBFBD><D0B4>HKLM<4C><4D>Ҫ<EFBFBD><D2AA>
RequestExecutionLevel admin
; ------ MUI <20>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><E6B6A8> ------
!include "MUI.nsh"
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "CrossDesk-${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\CrossDesk"
ShowInstDetails show
Section "MainSection"
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
File /oname=crossdesk.exe "build\windows\x64\release\crossdesk\crossdesk.exe"
; ? <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>װĿ¼
File "icons\crossdesk.ico"
;<3B><>д<EFBFBD><D0B4>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>Ϣ
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayName" "${PRODUCT_NAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayIcon" "$INSTDIR\crossdesk.ico"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "NoRepair" 1
SectionEnd
Section "Cert"
SetOutPath "$APPDATA\CrossDesk\certs"
File /r "certs\crossdesk.cn_root.crt"
SectionEnd
Section -AdditionalIcons
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>ʽ
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\crossdesk.exe" "" "$INSTDIR\crossdesk.ico"
;<3B>ʼ<EFBFAA>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>ݷ<EFBFBD>ʽ
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}.lnk" "$INSTDIR\crossdesk.exe" "" "$INSTDIR\crossdesk.ico"
;<3B><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD>ݷ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>
WriteIniStr "$DESKTOP\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
SectionEnd
Section "Uninstall"
; ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>س<EFBFBD><D8B3><EFBFBD>
Delete "$INSTDIR\crossdesk.exe"
Delete "$INSTDIR\uninstall.exe"
; <20>ݹ<EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>װĿ¼
RMDir /r "$INSTDIR"
; ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD>ʼ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>ݷ<EFBFBD>ʽ
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
Delete "$DESKTOP\${PRODUCT_NAME}.url"
Delete "$SMPROGRAMS\${PRODUCT_NAME}.lnk"
; ɾ<><C9BE>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}"
; <20>ݹ<EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>û<EFBFBD> AppData <20>е<EFBFBD> CrossDesk <20>ļ<EFBFBD><C4BC><EFBFBD>
RMDir /r "$APPDATA\CrossDesk"
RMDir /r "$LOCALAPPDATA\CrossDesk"
SectionEnd
Section -Post
SectionEnd

View File

@@ -30,11 +30,10 @@ if is_os("windows") then
"Imm32", "iphlpapi") "Imm32", "iphlpapi")
add_cxflags("/WX") add_cxflags("/WX")
elseif is_os("linux") then elseif is_os("linux") then
add_requires("libpulse")
add_links("pulse-simple", "pulse") add_links("pulse-simple", "pulse")
add_requires("libyuv") add_requires("libyuv")
add_syslinks("pthread", "dl") add_syslinks("pthread", "dl")
add_links("SDL2", "cuda", "nvidia-encode", "nvcuvid", "asound", "X11", "Xtst", "Xrandr") add_links("SDL2", "asound", "X11", "Xtst", "Xrandr")
add_cxflags("-Wno-unused-variable") add_cxflags("-Wno-unused-variable")
elseif is_os("macosx") then elseif is_os("macosx") then
add_links("SDL2", "SDL2main") add_links("SDL2", "SDL2main")
@@ -146,7 +145,7 @@ target("crossdesk")
set_kind("binary") set_kind("binary")
add_deps("rd_log", "common", "single_window") add_deps("rd_log", "common", "single_window")
if is_os("windows") then if is_os("windows") then
add_files("icon/app.rc") add_files("icons/app.rc")
elseif is_os("macosx") then elseif is_os("macosx") then
-- add_rules("xcode.application") -- add_rules("xcode.application")
-- add_files("Info.plist") -- add_files("Info.plist")