Skip to content

Build and Release

Build and Release #42

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
# id: 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: i686-unknown-linux-gnu
build: linux
os: ubuntu-latest
arch: i686
- target: aarch64-unknown-linux-gnu
build: linux
os: ubuntu-latest
arch: aarch64
- target: armv7-unknown-linux-gnueabihf
build: linux
os: ubuntu-latest
arch: armv7
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: 初始化 Linux 构建环境
run: |
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
sudo apt-get update
sudo apt-get 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-get update
sudo apt-get install -y libstdc++6:i386 libgdk-pixbuf2.0-dev:i386 libatomic1:i386 gcc-multilib g++-multilib libssl-dev:i386 \
libwebkit2gtk-4.0-dev:i386 libgtk-3-dev:i386 patchelf:i386 librsvg2-dev:i386 libayatana-appindicator3-dev:i386
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH
export PKG_CONFIG_SYSROOT_DIR=/
elif [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
sudo dpkg --add-architecture arm64
sudo apt-get update
sudo apt-get install -y libncurses6:arm64 libtinfo6:arm64 linux-libc-dev:arm64 libncursesw6:arm64 libcups2:arm64
sudo apt-get install -y --no-install-recommends g++-aarch64-linux-gnu libc6-dev-arm64-cross libssl-dev:arm64 \
libwebkit2gtk-4.0-dev:arm64 libgtk-3-dev:arm64 patchelf:arm64 librsvg2-dev:arm64 libayatana-appindicator3-dev:arm64
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
export PKG_CONFIG_ALLOW_CROSS=1
elif [ "${{ matrix.target }}" = "armv7-unknown-linux-gnueabihf" ]; then
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install -y libncurses6:armhf libtinfo6:armhf linux-libc-dev:armhf libncursesw6:armhf libcups2:armhf
sudo apt-get install -y --no-install-recommends g++-arm-linux-gnueabihf libc6-dev-armhf-cross libssl-dev:armhf \
libwebkit2gtk-4.0-dev:armhf libgtk-3-dev:armhf patchelf:armhf librsvg2-dev:armhf libayatana-appindicator3-dev:armhf
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
export CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
export PKG_CONFIG_ALLOW_CROSS=1
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 }}
- 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
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 }}
- 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/*.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/*