Skip to content

Build and Release

Build and Release #69

Workflow file for this run

name: Build and Release
on:
workflow_dispatch:
inputs:
release_message:
description: "版本更新说明"
type: string
required: true
default: |
发现新版本✨ 如果更新失败,请到官网下载最新版本:https://feiyu-player.xbox.work
jobs:
build:
name: Build dist
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 初始化 PNPM
uses: pnpm/action-setup@v3
with:
version: 8
- name: 初始化 Node 环境和缓存
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
cache-dependency-path: "**/pnpm-lock.yaml"
- name: 构建飞鱼前端代码
id: app
run: |
cd packages/feiyu && pnpm build:desktop
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
cd ${{ github.workspace }}
- name: 上传构建产物
uses: actions/upload-artifact@v4
with:
name: dist
path: packages/feiyu/dist
if-no-files-found: error
outputs:
version: ${{ steps.app.outputs.version }}
build-for-macos:
name: macOS
needs: build
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
build: macos
os: macos-latest
arch: aarch64
- target: x86_64-apple-darwin
build: macos
os: macos-latest
arch: x86_64
- target: universal-apple-darwin
build: macos
os: macos-latest
arch: universal
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: 下载构建产物
uses: actions/download-artifact@v4
with:
name: dist
path: packages/feiyu/dist
- name: 初始化 Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.arch == 'universal' && 'aarch64-apple-darwin,x86_64-apple-darwin' || matrix.target }}
- name: 初始化 Rust 缓存
uses: swatinem/rust-cache@v2
with:
workspaces: "packages/feiyu-desktop/src-tauri/${{ matrix.target }} -> target"
- name: 构建飞鱼 APP
run: |
cd packages/feiyu-desktop
# 获取背景图片路径
bg_path=$(pwd)/background.jpg
# 设置环境变量
export BACKGROUND_FILE=$bg_path
export BACKGROUND_FILE_NAME=$(basename $BACKGROUND_FILE)
export BACKGROUND_CLAUSE="set background picture of opts to file \".background:${BACKGROUND_FILE_NAME}\""
cargo install tauri-cli --version "^2.0.0-beta"
cargo tauri build --target ${{ matrix.target }}
cd ${{ github.workspace }}
env:
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
- name: 重命名安装包
run: |
cd packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/dmg
app_name=feiyu_${{ needs.build.outputs.version }}_${{ matrix.build }}_${{ matrix.arch }}.dmg
for f in *.dmg; do mv "$f" $app_name; done
cd ${{ github.workspace }}
- name: 上传构建产物
uses: actions/upload-artifact@v4
with:
name: app_${{ matrix.build }}_${{ matrix.arch }}
path: |
packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/dmg/*.dmg
if-no-files-found: error
build-for-windows:
name: Windows
needs: build
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc
build: windows
os: windows-latest
arch: x86_64
- target: aarch64-pc-windows-msvc
build: windows
os: windows-latest
arch: aarch64
- target: i686-pc-windows-msvc
build: windows
os: windows-latest
arch: i686
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: 下载构建产物
uses: actions/download-artifact@v4
with:
name: dist
path: packages/feiyu/dist
- name: 初始化 Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: 初始化 Rust 缓存
uses: swatinem/rust-cache@v2
with:
workspaces: "packages/feiyu-desktop/src-tauri/${{ matrix.target }} -> target"
- name: 构建飞鱼 APP
run: |
cd packages/feiyu-desktop
cargo install tauri-cli --version "^2.0.0-beta"
cargo tauri build --target ${{ matrix.target }} ${{ env.TAURI_ARGS }}
cd ${{ github.workspace }}
env:
TAURI_ARGS: ${{ matrix.arch == 'aarch64' && '--bundles nsis' || '' }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
- name: 重命名安装包 (.msi)
if: matrix.arch != 'aarch64'
run: |
cd packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/msi
$app_name = "feiyu_${{ needs.build.outputs.version }}_${{ matrix.build }}_${{ matrix.arch }}.msi"
Get-ChildItem -Path ./ -Filter *.msi | Rename-Item -NewName $app_name
cd ${{ github.workspace }}
shell: pwsh
- name: 重命名安装包 (.exe)
run: |
cd packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/nsis
$app_name = "feiyu_${{ needs.build.outputs.version }}_${{ matrix.build }}_${{ matrix.arch }}.exe"
Get-ChildItem -Path ./ -Filter *.exe | Rename-Item -NewName $app_name
cd ${{ github.workspace }}
shell: pwsh
- name: 上传构建产物
uses: actions/upload-artifact@v4
with:
name: app_${{ matrix.build }}_${{ matrix.arch }}
path: |
packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/msi/*.msi
packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*.exe
build-for-linux:
name: Linux
needs: build
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
build: linux
os: ubuntu-latest
arch: x86_64
- target: aarch64-unknown-linux-gnu
build: linux
os: ubuntu-latest
arch: aarch64
# - target: armv7-unknown-linux-gnueabihf
# build: linux
# os: ubuntu-latest
# arch: armv7
# - target: i686-unknown-linux-gnu
# build: linux
# os: ubuntu-latest
# arch: i686
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: 下载构建产物
uses: actions/download-artifact@v4
with:
name: dist
path: packages/feiyu/dist
- name: 初始化 Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: 初始化 Rust 缓存
uses: swatinem/rust-cache@v2
with:
workspaces: "packages/feiyu-desktop/src-tauri/${{ matrix.target }} -> target"
- name: 初始化 apt sources.list
if: matrix.arch != 'x86_64'
run: |
cat << EOF | sudo tee /etc/apt/sources.list
# x86 Support
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy main restricted universe multiverse
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-security main restricted universe multiverse
# ARM Support
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted universe multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted universe multiverse
EOF
- name: 初始化 Linux 构建环境
id: pkg
run: |
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
sudo apt-get update
sudo apt install -y libwebkit2gtk-4.1-dev libgtk-3-dev patchelf librsvg2-dev libappindicator3-dev libsoup-3.0-dev libjavascriptcoregtk-4.1-dev
elif [ "${{ matrix.target }}" = "i686-unknown-linux-gnu" ]; then
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y gcc-multilib g++-multilib lib32stdc++6 libc6-dev-i386 libssl-dev:i386
sudo apt install -y libwebkit2gtk-4.1-dev:i386 libgtk-3-dev:i386 librsvg2-dev:i386 libsoup-3.0-dev:i386 libjavascriptcoregtk-4.1-dev:i386
echo "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH" >> $GITHUB_OUTPUT
echo "PKG_CONFIG_SYSROOT_DIR=/usr/i386-linux-gnu/:$PKG_CONFIG_SYSROOT_DIR" >> $GITHUB_OUTPUT
elif [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
sudo dpkg --add-architecture arm64
sudo apt update
sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross libssl-dev:arm64
sudo apt install -y libwebkit2gtk-4.1-dev:arm64 libgtk-3-dev:arm64 patchelf:arm64 librsvg2-dev:arm64 libayatana-appindicator3-dev:arm64 libsoup-3.0-dev:arm64 libjavascriptcoregtk-4.1-dev:arm64
echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH" >> $GITHUB_OUTPUT
echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/:$PKG_CONFIG_SYSROOT_DIR" >> $GITHUB_OUTPUT
elif [ "${{ matrix.target }}" = "armv7-unknown-linux-gnueabihf" ]; then
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross libssl-dev:armhf
sudo apt install -y libwebkit2gtk-4.1-dev:armhf libgtk-3-dev:armhf patchelf:armhf librsvg2-dev:armhf libayatana-appindicator3-dev:armhf libsoup-3.0-dev:armhf libjavascriptcoregtk-4.1-dev:armhf
echo "PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig/:$PKG_CONFIG_PATH" >> $GITHUB_OUTPUT
echo "PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/:$PKG_CONFIG_SYSROOT_DIR" >> $GITHUB_OUTPUT
fi
- name: 构建飞鱼 APP
id: app
run: |
cd packages/feiyu-desktop
cargo install tauri-cli --version "^2.0.0-beta"
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
cargo tauri build --target ${{ matrix.target }}
else
cargo tauri build --target ${{ matrix.target }} -b deb,rpm
fi
cd ${{ github.workspace }}
env:
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
PKG_CONFIG_ALLOW_CROSS: 1
PKG_CONFIG_PATH: ${{ steps.pkg.outputs.PKG_CONFIG_PATH }}
PKG_CONFIG_SYSROOT_DIR: ${{ steps.pkg.outputs.PKG_CONFIG_SYSROOT_DIR }}
I686_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR: /usr/lib/i386-linux-gnu/
I686_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR: /usr/include/openssl/
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
- name: 重命名安装包
run: |
# .deb
cd ./packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/deb
app_name=feiyu_${{ needs.build.outputs.version }}_${{ matrix.build }}_${{ matrix.arch }}.deb
for f in *.deb; do mv "$f" "$app_name"; done
cd ${{ github.workspace }}
# .rpm
cd packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/rpm
app_name=feiyu_${{ needs.build.outputs.version }}_${{ matrix.build }}_${{ matrix.arch }}.rpm
for f in *.rpm; do mv "$f" "$app_name"; done
cd ${{ github.workspace }}
# .AppImage
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
cd packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/appimage
app_name=feiyu_${{ needs.build.outputs.version }}_${{ matrix.build }}_${{ matrix.arch }}.AppImage
for f in *.AppImage; do mv "$f" "$app_name"; done
cd ${{ github.workspace }}
fi
- name: 上传构建产物
uses: actions/upload-artifact@v4
with:
name: app_${{ matrix.build }}_${{ matrix.arch }}
path: |
packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
packages/feiyu-desktop/src-tauri/target/${{ matrix.target }}/release/bundle/*/*.AppImage
release:
name: Release
needs: [build, build-for-macos, build-for-windows, build-for-linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 下载构建产物
uses: actions/download-artifact@v4
with:
pattern: app_*
path: temp
merge-multiple: true
- name: 整理构建产物
run: |
shopt -s globstar
mkdir -p dist
for file in temp/**
do
if [ -d "$file" ]
then
continue
fi
mv "$file" dist/
done
- name: 发布飞鱼 v${{ needs.build.outputs.version }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ inputs.release_message }}
name: 飞鱼 v${{ needs.build.outputs.version }}
tag: v${{ needs.build.outputs.version }}
draft: true
prerelease: false
artifacts: dist/*