| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- name: 编译
- on:
- workflow_dispatch:
- push:
- paths:
- - '.github/workflows/build-app.yaml'
- - 'client/**'
- - 'src/**'
- concurrency:
- group: "build"
- cancel-in-progress: true
- permissions:
- contents: read
- id-token: write
- jobs:
- get-version:
- name: 获取版本号
- runs-on: ubuntu-latest
- outputs:
- VERSION: ${{ steps.get-yaa-version.outputs.version }}
- steps:
- - name: 检出仓库
- uses: actions/checkout@v4
- - name: 获取 yaa 的版本号
- id: get-yaa-version
- run: |
- YAA_VERSION=$(grep '^version' ./Cargo.toml | awk -F= '{print $2}' | tr -d '" ')
- echo "$YAA_VERSION"
- build-app:
- name: 编译(${{ matrix.os }})
- runs-on: ${{ matrix.os }}
- env:
- HTML_PATH: 'client/index.html'
- NAME: 'yaa'
- ICON: 'assets/yaa_512.png'
- INSTALLER_LANGUAGE: zh-CN
- VERSION: ${{ needs.get-version.outputs.VERSION }}
- TARGETS: 'appimage'
- strategy:
- matrix:
- build: [linux, macos, windows]
- include:
- - build: linux
- os: ubuntu-latest
- - build: windows
- os: windows-latest
- - build: macos
- os: macos-latest
- steps:
- - name: 检出仓库
- uses: actions/checkout@v4
- - name: 安装 Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
- - name: 为 ubuntu-latest 安装 Rust
- if: matrix.os == 'ubuntu-latest'
- uses: dtolnay/rust-toolchain@stable
- with:
- toolchain: stable
- target: x86_64-unknown-linux-musl
- - name: 为 windows-latest 安装 Rust
- if: matrix.os == 'windows-latest'
- uses: dtolnay/rust-toolchain@stable
- with:
- toolchain: stable-x86_64-msvc
- target: x86_64-pc-windows-msvc
- - name: 为 macos-latest 安装 Rust
- if: matrix.os == 'macos-latest'
- uses: dtolnay/rust-toolchain@stable
- with:
- toolchain: stable
- target: x86_64-apple-darwin
- - name: 安装依赖(仅 Ubuntu 需)
- if: matrix.os == 'ubuntu-24.04'
- uses: awalsh128/[email protected]
- with:
- packages: libsoup3.0-dev libdbus-1-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra
- version: 1.1
-
- - name: 安装 pake-cli
- run: |
- npm install pake-cli
- - name: 恢复 Rust 缓存
- uses: actions/cache/restore@v3
- id: cache_store
- with:
- path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
- key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- - name: 安装依赖
- run: |
- npm install -g shelljs
- npm install -g axios
-
- - name: 安装 Pake
- run: |
- npm install -g pake-cli && pake --version
- - name: 编译服务端
- run: |
- cargo build --release
-
- - name: 编译客户端
- run: |
- mkdir -p target/client
- cd target/client
- pake ../../${{ env.HTML_PATH }} \
- --name ${{ env.NAME }} \
- --icon ../../${{ env.ICON }} \
- --installer-language ${{ env.INSTALLER_LANGUAGE }} \
- --app-version ${{ env.VERSION }} \
- --targets ${{ env.TARGETS }} \
- --use-local-file
- cd ../..
- shell: bash
- - name: 收集包
- run: |
- mkdir -p yaa-${{ matrix.build }}
- cp -r node_modules/pake-cli/output/* yaa-${{ matrix.build }}
- if [ "${{ matrix.os }}" == "windows-latest" ]; then
- cp target/release/yaa.exe yaa-${{ matrix.build }}/
- else
- cp target/release/yaa yaa-${{ matrix.build }}/
- fi
- shell: bash
- - name: 上传包
- uses: actions/upload-artifact@v4
- with:
- name: yaa-${{ matrix.os }}.zip
- path: yaa-${{ matrix.build }}/**/*
- retention-days: 3
- - name: 保存 Rust 缓存
- uses: actions/cache/save@v3
- if: steps.cache_store.outputs.cache-hit != 'true'
- with:
- path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
- key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|