build-app.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. steps:
  20. - name: 检出仓库
  21. uses: actions/checkout@v4
  22. - name: 获取 yaa 的版本号
  23. id: get-version
  24. run: |
  25. YAA_VERSION=$(grep '^version' ./Cargo.toml | awk -F= '{print $2}' | tr -d '" ')
  26. echo "::set-output name=version::$YAA_VERSION"
  27. build-app:
  28. needs: get-version
  29. name: 编译(${{ matrix.os }})
  30. runs-on: ${{ matrix.os }}
  31. env:
  32. HTML_PATH: 'client/index.html'
  33. NAME: 'yaa'
  34. ICON: 'assets/yaa_512.png'
  35. INSTALLER_LANGUAGE: zh-CN
  36. TARGETS: 'appimage'
  37. strategy:
  38. matrix:
  39. build: [linux, macos, windows]
  40. include:
  41. - build: linux
  42. os: ubuntu-latest
  43. - build: windows
  44. os: windows-latest
  45. - build: macos
  46. os: macos-latest
  47. steps:
  48. - name: 检出仓库
  49. uses: actions/checkout@v4
  50. - name: 安装 Node.js
  51. uses: actions/setup-node@v3
  52. with:
  53. node-version: 18
  54. - name: 为 ubuntu-latest 安装 Rust
  55. if: matrix.os == 'ubuntu-latest'
  56. uses: dtolnay/rust-toolchain@stable
  57. with:
  58. toolchain: stable
  59. target: x86_64-unknown-linux-musl
  60. - name: 为 windows-latest 安装 Rust
  61. if: matrix.os == 'windows-latest'
  62. uses: dtolnay/rust-toolchain@stable
  63. with:
  64. toolchain: stable-x86_64-msvc
  65. target: x86_64-pc-windows-msvc
  66. - name: 为 macos-latest 安装 Rust
  67. if: matrix.os == 'macos-latest'
  68. uses: dtolnay/rust-toolchain@stable
  69. with:
  70. toolchain: stable
  71. target: x86_64-apple-darwin
  72. - name: 安装依赖(仅 Ubuntu 需)
  73. if: matrix.os == 'ubuntu-24.04'
  74. uses: awalsh128/[email protected]
  75. with:
  76. 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
  77. version: 1.1
  78. - name: 安装 pake-cli
  79. run: |
  80. npm install pake-cli
  81. - name: 恢复 Rust 缓存
  82. uses: actions/cache/restore@v3
  83. id: cache_store
  84. with:
  85. path: |
  86. ~/.cargo/bin/
  87. ~/.cargo/registry/index/
  88. ~/.cargo/registry/cache/
  89. ~/.cargo/git/db/
  90. key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  91. - name: 安装依赖
  92. run: |
  93. npm install -g shelljs
  94. npm install -g axios
  95. - name: 安装 Pake
  96. run: |
  97. npm install -g pake-cli && pake --version
  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 ${{ needs.get-version.outputs.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') }}