build-client.yaml 4.2 KB

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