2
0

build-app.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. name: 编译
  2. on:
  3. workflow_dispatch:
  4. push:
  5. paths:
  6. - '.github/workflows/build-app.yaml'
  7. - 'client/**'
  8. - 'src/**'
  9. concurrency:
  10. group: "build"
  11. cancel-in-progress: true
  12. permissions:
  13. contents: read
  14. id-token: write
  15. jobs:
  16. get-version:
  17. name: 获取版本号
  18. runs-on: ubuntu-latest
  19. outputs:
  20. VERSION: ${{ steps.get-yaa-version.outputs.version }}
  21. steps:
  22. - name: 检出仓库
  23. uses: actions/checkout@v4
  24. - name: 获取 yaa 的版本号
  25. id: get-yaa-version
  26. run: |
  27. YAA_VERSION=$(grep '^version' ./Cargo.toml | awk -F= '{print $2}' | tr -d '" ')
  28. echo "version=$YAA_VERSION" >> "$GITHUB_OUTPUT"
  29. build-app:
  30. needs: get-version
  31. name: 编译(${{ matrix.os }})
  32. runs-on: ${{ matrix.os }}
  33. env:
  34. HTML_PATH: 'client/index.html'
  35. NAME: 'yaa'
  36. ICON: 'assets/yaa_512.png'
  37. INSTALLER_LANGUAGE: zh-CN
  38. VERSION: ${{ needs.get-version.outputs.VERSION }}
  39. TARGETS: 'appimage'
  40. strategy:
  41. matrix:
  42. build: [linux, macos, windows]
  43. include:
  44. - build: linux
  45. os: ubuntu-latest
  46. - build: windows
  47. os: windows-latest
  48. - build: macos
  49. os: macos-latest
  50. steps:
  51. - name: 检出仓库
  52. uses: actions/checkout@v4
  53. - name: 安装 Node.js
  54. uses: actions/setup-node@v3
  55. with:
  56. node-version: 18
  57. - name: 为 ubuntu-latest 安装 Rust
  58. if: matrix.os == 'ubuntu-latest'
  59. uses: dtolnay/rust-toolchain@stable
  60. with:
  61. toolchain: stable
  62. target: x86_64-unknown-linux-musl
  63. - name: 为 windows-latest 安装 Rust
  64. if: matrix.os == 'windows-latest'
  65. uses: dtolnay/rust-toolchain@stable
  66. with:
  67. toolchain: stable-x86_64-msvc
  68. target: x86_64-pc-windows-msvc
  69. - name: 为 macos-latest 安装 Rust
  70. if: matrix.os == 'macos-latest'
  71. uses: dtolnay/rust-toolchain@stable
  72. with:
  73. toolchain: stable
  74. target: x86_64-apple-darwin
  75. - name: 安装依赖(仅 Ubuntu 需)
  76. if: matrix.os == 'ubuntu-24.04'
  77. uses: awalsh128/[email protected]
  78. with:
  79. 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
  80. version: 1.1
  81. - name: 安装 pake-cli
  82. run: |
  83. npm install -g pake-cli && pake --version
  84. - name: 恢复 Rust 缓存
  85. uses: actions/cache/restore@v3
  86. id: cache_store
  87. with:
  88. path: |
  89. ~/.cargo/bin/
  90. ~/.cargo/registry/index/
  91. ~/.cargo/registry/cache/
  92. ~/.cargo/git/db/
  93. key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  94. - name: 安装依赖
  95. run: |
  96. npm install -g shelljs
  97. npm install -g axios
  98. - name: 编译服务端
  99. run: |
  100. cargo build --release
  101. - name: 编译客户端
  102. run: |
  103. mkdir -p target/client
  104. cd target/client
  105. pake ../../${{ env.HTML_PATH }} \
  106. --name ${{ env.NAME }} \
  107. --icon ../../${{ env.ICON }} \
  108. --installer-language ${{ env.INSTALLER_LANGUAGE }} \
  109. --app-version ${{ env.VERSION }} \
  110. --targets ${{ env.TARGETS }} \
  111. --use-local-file
  112. cd ../..
  113. shell: bash
  114. - name: 收集包
  115. run: |
  116. mkdir -p yaa-${{ matrix.build }}
  117. cp -r node_modules/pake-cli/output/* yaa-${{ matrix.build }}
  118. if [ "${{ matrix.os }}" == "windows-latest" ]; then
  119. cp target/release/yaa.exe yaa-${{ matrix.build }}/
  120. else
  121. cp target/release/yaa yaa-${{ matrix.build }}/
  122. fi
  123. shell: bash
  124. - name: 上传包
  125. uses: actions/upload-artifact@v4
  126. with:
  127. name: yaa-${{ matrix.os }}.zip
  128. path: yaa-${{ matrix.build }}/**/*
  129. retention-days: 3
  130. - name: 保存 Rust 缓存
  131. uses: actions/cache/save@v3
  132. if: steps.cache_store.outputs.cache-hit != 'true'
  133. with:
  134. path: |
  135. ~/.cargo/bin/
  136. ~/.cargo/registry/index/
  137. ~/.cargo/registry/cache/
  138. ~/.cargo/git/db/
  139. key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}