Build and Release #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
# 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: | | |
# sudo apt-get update | |
# sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libsoup-3.0-dev libjavascriptcoregtk-4.1-dev | |
# - name: 构建飞鱼 APP | |
# id: app | |
# run: | | |
# cd packages/feiyu-desktop | |
# 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: | | |
# # .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 | |
# It's fucking slooooooow... | |
# build-for-linux-arm: | |
# name: Linux ARM | |
# needs: build | |
# permissions: | |
# contents: write | |
# strategy: | |
# fail-fast: false | |
# matrix: | |
# include: | |
# - target: aarch64-unknown-linux-gnu | |
# build: linux | |
# os: ubuntu-latest | |
# arch: aarch64 | |
# cpu: cortex-a53 | |
# base_image: raspios_lite_arm64:latest | |
# - target: armv7-unknown-linux-gnueabihf | |
# build: linux | |
# os: ubuntu-latest | |
# arch: armv7l | |
# cpu: cortex-a7 | |
# base_image: raspios_lite:latest | |
# runs-on: ${{ matrix.os }} | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: 下载构建产物 | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: dist | |
# path: packages/feiyu/dist | |
# - name: 构建 ARM 产物 | |
# uses: pguyot/arm-runner-action@v2 | |
# with: | |
# base_image: ${{ matrix.base_image }} | |
# cpu: ${{ matrix.cpu }} | |
# bind_mount_repository: true | |
# image_additional_mb: 10240 | |
# commands: | | |
# # 初始化环境 | |
# apt-get update -y --allow-releaseinfo-change | |
# apt-get upgrade -y | |
# apt-get autoremove -y | |
# apt-get install curl | |
# # 安装 Rust | |
# export HOME=/root | |
# export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse | |
# curl https://sh.rustup.rs -sSf | sh -s -- -y | |
# . "$HOME/.cargo/env" | |
# # 安装依赖 | |
# apt-get install -y libwebkit2gtk-4.0-dev build-essential wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev | |
# cargo install tauri-cli --version "^2.0.0-beta" | |
# # 构建安装包 | |
# cd packages/feiyu-desktop | |
# export TAURI_PRIVATE_KEY=${{ secrets.TAURI_PRIVATE_KEY }} | |
# export TAURI_KEY_PASSWORD=${{ secrets.TAURI_KEY_PASSWORD }} | |
# cargo tauri build --target ${{ matrix.target }} | |
# - 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 | |
build-for-linux-i686: | |
name: Linux i686 | |
needs: build | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- 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: 初始化 Linux 构建环境 | |
run: | | |
sudo dpkg --add-architecture i386 | |
sudo apt-get update | |
sudo apt-get install -y gcc-multilib g++-multilib | |
sudo apt-get install gcc-i686-linux-gnu | |
sudo apt-get install -y \ | |
libwebkit2gtk-4.0-dev:i386 \ | |
libgtk-3-dev:i386 \ | |
librsvg2-dev:i386 \ | |
libssl-dev:i386 | |
# patchelf \ | |
# libsoup-3.0-dev \ | |
# libjavascriptcoregtk-4.1-dev | |
- name: 构建飞鱼 APP | |
id: app | |
run: | | |
cd packages/feiyu-desktop | |
export RUSTFLAGS="-C linker=i686-linux-gnu-gcc" | |
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig/ | |
export PKG_CONFIG_SYSROOT_DIR=/usr/lib/i386-linux-gnu | |
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: | | |
# .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, | |
# build-for-linux-arm, | |
build-for-linux-i686, | |
] | |
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/* |