Skip to content

feat: Update CI workflows for Ubuntu ARM; add support for ARM architecture #104

feat: Update CI workflows for Ubuntu ARM; add support for ARM architecture

feat: Update CI workflows for Ubuntu ARM; add support for ARM architecture #104

Workflow file for this run

name: PR Build
on:
pull_request:
branches: [ main, develop ]
types: [opened, synchronize, reopened]
# 授予工作流写入权限,用于创建 Release 和上传产物
permissions:
contents: write
issues: write
pull-requests: write
# 定义环境变量
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: short
# 确保每个提交只运行一次工作流
concurrency:
group: "${{ github.workflow }} - ${{ github.head_ref || github.ref }}"
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
# 任务 1: 检查 Git Tag 和 package.json 的版本是否一致
pre_release:
name: Check Release Tag and package.json Version Consistency
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install jq for JSON parsing
run: sudo apt-get update && sudo apt-get install -y jq
- name: Get version from package.json
id: get_version
run: |
PKG_VERSION=$(jq -r .version package.json)
echo "package.json version: $PKG_VERSION"
echo "version=${PKG_VERSION}" >> $GITHUB_OUTPUT
# 任务 2: 为 Windows, macOS, Linux, 和 Android 构建和发布
# Job 1: 构建 Windows, macOS, Linux x86_64 和 Android
build-artifacts:
name: Build Debug Artifacts
needs: [ pre_release ]
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
platform: windows
target: x86_64-pc-windows-msvc
arch: x86_64
- os: windows-latest
platform: windows
target: aarch64-pc-windows-msvc
arch: aarch64
- os: macos-latest
platform: macos
target: aarch64-apple-darwin
arch: aarch64
- os: macos-latest
platform: macos
target: x86_64-apple-darwin
arch: x86_64
- os: ubuntu-22.04
platform: linux
target: x86_64-unknown-linux-gnu
arch: x86_64
- os: ubuntu-22.04-arm
platform: linux
target: aarch64-unknown-linux-gnu
arch: aarch64
- os: ubuntu-22.04
platform: android
target: x86_64-linux-android
arch: x86_64
- os: ubuntu-22.04
platform: android
target: aarch64-linux-android
arch: aarch64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable
- name: Set up Java
if: matrix.platform == 'android'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
if: matrix.platform == 'android'
uses: android-actions/setup-android@v3
with:
accept-android-sdk-licenses: 'true'
cmdline-tools-version: 12266719
log-accepted-android-sdk-licenses: true
packages: tools platform-tools emulator
- name: Install NDK
if: matrix.platform == 'android'
run: sdkmanager "ndk;26.1.10909125"
- name: Add Rust Target
run: rustup target add ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
key: ${{ matrix.target }}
- name: Install dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y libsoup-3.0-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev libgtk-3-dev libssl-dev xdg-utils librsvg2-dev libappindicator3-dev patchelf
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: "22"
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: latest
- name: Pnpm install
run:
pnpm i
pnpm tauri icon
- name: Initialize Tauri Android Project
if: matrix.platform == 'android'
env:
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/26.1.10909125
run:
pnpm tauri android init
- name: Download and Setup eCapture
shell: bash
if: matrix.platform == 'linux' || matrix.platform == 'android'
run: |
echo ">>> Setting up eCapture for ${{ matrix.platform }}-${{ matrix.arch }}..."
if [[ "${{ matrix.arch }}" == "x86_64" ]]; then
ECAPTURE_ARCH="amd64"
else
ECAPTURE_ARCH="arm64"
fi
ECAPTURE_LATEST=$(curl -s https://api.github.com/repos/gojue/ecapture/releases/latest | grep tag_name | cut -d '"' -f 4)
if [[ -z "$ECAPTURE_LATEST" ]]; then echo "Failed to fetch eCapture version."; exit 1; fi
ECAPTURE_TAR="ecapture-${ECAPTURE_LATEST}-${{ matrix.platform }}-${ECAPTURE_ARCH}.tar.gz"
wget "https://github.com/gojue/ecapture/releases/download/${ECAPTURE_LATEST}/${ECAPTURE_TAR}"
tar -zxvf "${ECAPTURE_TAR}"
SOURCE_FILE=$(find . -name ecapture -type f | head -n 1)
mkdir -p src-tauri/binaries
DEST_FILE="src-tauri/binaries/${{ matrix.platform }}_ecapture_${ECAPTURE_ARCH}"
cp "${SOURCE_FILE}" "${DEST_FILE}"
ls -l src-tauri/binaries/
- name: Build Desktop Artifacts (Windows/macOS/Linux)
if: matrix.platform != 'android'
uses: tauri-apps/[email protected]
env:
DECOUPLED_MODE: ${{ matrix.platform == 'linux' || matrix.platform == 'android' }}
RUST_TARGET: ${{ matrix.target }}
NODE_OPTIONS: "--max_old_space_size=4096"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.ANDROID_SIGN_DEBUG_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.ANDROID_SIGN_DEBUG_KEY_PASSWORD }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
with:
tauriScript: pnpm tauri
args: --target ${{ matrix.target }} --debug
- name: Build Android Artifact (Android)
if: matrix.platform == 'android'
env:
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/26.1.10909125
run: |
pnpm tauri android build --target ${{ matrix.arch }}
- name: Sign Android APK
if: matrix.platform == 'android'
id: sign_apk
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: src-tauri/gen/android/app/build/outputs/apk/universal/debug
signingKeyBase64: ${{ secrets.ANDROID_SIGN_DEBUG_KEY }}
alias: ${{ secrets.ANDROID_SIGN_DEBUG_KEY_ALIAS }}
keyStorePassword: ${{ secrets.ANDROID_SIGN_DEBUG_KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.ANDROID_SIGN_DEBUG_KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: "34.0.0"
- name: Upload artifacts (Linux)
uses: actions/upload-artifact@v4
if: matrix.platform == 'linux'
with:
name: eCaptureQ-pr${{ github.event.number }}-${{ github.run_id }}-${{ matrix.arch }}.AppImage
retention-days: 7
path: src-tauri/target/${{ matrix.target }}/debug/bundle/appimage/eCaptureQ*.AppImage
- name: Upload artifacts (macOS)
uses: actions/upload-artifact@v4
if: matrix.platform == 'macos'
with:
name: eCaptureQ-pr${{ github.event.number }}-${{ github.run_id }}-${{ matrix.arch }}.dmg
retention-days: 7
path: |
src-tauri/target/${{ matrix.target }}/debug/bundle/dmg/eCaptureQ*.dmg
- name: Upload artifacts (Windows)
uses: actions/upload-artifact@v4
if: matrix.platform == 'windows'
with:
name: eCaptureQ-pr${{ github.event.number }}-${{ github.run_id }}-${{ matrix.arch }}.msi
retention-days: 7
path: |
src-tauri/target/${{ matrix.target }}/debug/bundle/msi/eCaptureQ*.msi
- name: Upload artifacts (Android)
if: matrix.platform == 'android'
uses: actions/upload-artifact@v4
with:
name: eCaptureQ-pr${{ github.event.number }}-${{ github.run_id }}-${{ matrix.arch }}.apk
retention-days: 7
path: |
${{ steps.sign_apk.outputs.signedReleaseFile }}
comment-pr:
runs-on: ubuntu-22.04
name: Comment PR with Download Links
needs: build-artifacts
steps:
- name: Comment PR with Download Links
uses: actions/github-script@v7
with:
script: |
const runId = context.runId;
const prNumber = context.payload.pull_request.number;
github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🔧 **Debug Build Complete (PR ${prNumber}, RunID ${runId})**
📦 Download Links:
- [PR ${prNumber} Debug Binary](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId})
⏰ Files will be retained for 7 days, please download and test promptly.`
});