2
0

build-client.yaml.bak 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. INJECT: 'assets/fix-cors.js'
  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. mkdir -p target/client
  101. cd target/client
  102. pake ../../${{ env.HTML_PATH }} \
  103. --name ${{ env.NAME }} \
  104. --icon ../../${{ env.ICON }} \
  105. --installer-language ${{ env.INSTALLER_LANGUAGE }} \
  106. --inject ../.. ${{ env.INJECT }} \
  107. --app-version ${{ env.VERSION }} \
  108. --targets ${{ env.TARGETS }} \
  109. --use-local-file
  110. cd ../..
  111. shell: bash
  112. - name: 收集包
  113. run: |
  114. mkdir -p yaa_client_${{ matrix.build }}
  115. cp -r target/client/* yaa_client_${{ matrix.build }}
  116. shell: bash
  117. - name: 上传包
  118. uses: actions/upload-artifact@v4
  119. with:
  120. name: yaa_client_${{ matrix.os }}.zip
  121. path: yaa_client_${{ matrix.build }}/**/*
  122. retention-days: 3
  123. - name: 保存 Rust 缓存
  124. uses: actions/cache/save@v3
  125. if: steps.cache_store.outputs.cache-hit != 'true'
  126. with:
  127. path: |
  128. ~/.cargo/bin/
  129. ~/.cargo/registry/index/
  130. ~/.cargo/registry/cache/
  131. ~/.cargo/git/db/
  132. key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}