|
| 1 | +# Workflow's name |
| 2 | +name: Build Test Client |
| 3 | + |
| 4 | +# Workflow's trigger |
| 5 | +# 在release_test 分支收到推送的时候触发 |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - "release_test" |
| 10 | + - "release_test_2" |
| 11 | + - "release_test_3" |
| 12 | + |
| 13 | +# Workflow's jobs |
| 14 | +# 一共需要3台电脑运行 |
| 15 | +# windows |
| 16 | +# macos-latest x86_64 |
| 17 | +# macos-latest arm64 |
| 18 | +jobs: |
| 19 | + release: |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - os: windows-latest |
| 25 | + - os: macos-latest |
| 26 | + arch: x86_64 |
| 27 | + - os: macos-latest |
| 28 | + arch: arm64 |
| 29 | + - os: ubuntu-latest |
| 30 | + runs-on: ${{ matrix.os }} |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Check out git repository |
| 34 | + uses: actions/checkout@main |
| 35 | + |
| 36 | + # 安装jre Windows |
| 37 | + - name: Install Jre for Windows |
| 38 | + if: ${{ runner.os == 'Windows' }} |
| 39 | + uses: actions/setup-java@main |
| 40 | + with: |
| 41 | + java-version: "17" |
| 42 | + distribution: "temurin" |
| 43 | + java-package: "jre" |
| 44 | + |
| 45 | + # 安装jre MacOS X64 |
| 46 | + - name: Install Jre MacOS X64 |
| 47 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'x86_64' }} |
| 48 | + uses: actions/setup-java@main |
| 49 | + with: |
| 50 | + java-version: "17" |
| 51 | + distribution: "temurin" |
| 52 | + java-package: "jre" |
| 53 | + |
| 54 | + # 安装jre MacOS arm64 |
| 55 | + - name: Install Jre MacOS arm64 |
| 56 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'arm64' }} |
| 57 | + uses: actions/setup-java@main |
| 58 | + with: |
| 59 | + java-version: "17" |
| 60 | + distribution: "temurin" |
| 61 | + java-package: "jre" |
| 62 | + architecture: "aarch64" |
| 63 | + |
| 64 | + # 安装jre Linux |
| 65 | + - name: Install Jre for Linux |
| 66 | + if: ${{ runner.os == 'Linux' }} |
| 67 | + uses: actions/setup-java@main |
| 68 | + with: |
| 69 | + java-version: "17" |
| 70 | + distribution: "temurin" |
| 71 | + java-package: "jre" |
| 72 | + |
| 73 | + # java.security 开放tls1 Windows |
| 74 | + - name: Enable tls1 |
| 75 | + if: ${{ runner.os == 'Windows' }} |
| 76 | + run: | |
| 77 | + sed -i '' "s/\(^jdk.tls.disabledAlgorithms=\)\(.*\)\( TLSv1, TLSv1.1,\)\(.*\)/\1\2\4/" "${{ env.JAVA_HOME }}/conf/security/java.security" |
| 78 | +
|
| 79 | + # java.security 开放tls1 macOS |
| 80 | + - name: Enable tls1 |
| 81 | + if: ${{ runner.os == 'macOS' }} |
| 82 | + run: | |
| 83 | + sed -i '' "s/\(^jdk.tls.disabledAlgorithms=\)\(.*\)\( TLSv1, TLSv1.1,\)\(.*\)/\1\2\4/" $JAVA_HOME/conf/security/java.security |
| 84 | +
|
| 85 | + # java.security 开放tls1 Linux |
| 86 | + - name: Enable tls1 |
| 87 | + if: ${{ runner.os == 'Linux' }} |
| 88 | + run: | |
| 89 | + sed -i "s/\(^jdk.tls.disabledAlgorithms=\)\(.*\)\( TLSv1, TLSv1.1,\)\(.*\)/\1\2\4/" ${{ env.JAVA_HOME }}/conf/security/java.security |
| 90 | +
|
| 91 | + # 复制jre Windows |
| 92 | + - name: Copy Jre for Windows |
| 93 | + if: ${{ runner.os == 'Windows' }} |
| 94 | + run: | |
| 95 | + mkdir chat2db-client/static |
| 96 | + cp -r "${{ env.JAVA_HOME }}" chat2db-client/static/jre |
| 97 | +
|
| 98 | + # 复制jre macOS |
| 99 | + - name: Copy Jre for macOS |
| 100 | + if: ${{ runner.os == 'macOS' }} |
| 101 | + run: | |
| 102 | + mkdir chat2db-client/static |
| 103 | + cp -r $JAVA_HOME chat2db-client/static/jre |
| 104 | + chmod -R 777 chat2db-client/static/jre/ |
| 105 | +
|
| 106 | + # 复制jre Linux |
| 107 | + - name: Copy Jre for Linux |
| 108 | + if: ${{ runner.os == 'Linux' }} |
| 109 | + run: | |
| 110 | + mkdir chat2db-client/static |
| 111 | + cp -r $JAVA_HOME chat2db-client/static/jre |
| 112 | + chmod -R 777 chat2db-client/static/jre/ |
| 113 | +
|
| 114 | + # 安装node |
| 115 | + - name: Install Node.js |
| 116 | + uses: actions/setup-node@main |
| 117 | + with: |
| 118 | + node-version: 16 |
| 119 | + cache: "yarn" |
| 120 | + cache-dependency-path: chat2db-client/yarn.lock |
| 121 | + |
| 122 | + # 安装java |
| 123 | + - name: Install Java and Maven |
| 124 | + uses: actions/setup-java@main |
| 125 | + with: |
| 126 | + java-version: "17" |
| 127 | + distribution: "temurin" |
| 128 | + cache: "maven" |
| 129 | + |
| 130 | + # 构建静态文件信息 |
| 131 | + - name: Yarn install & build & copy |
| 132 | + run: | |
| 133 | + cd chat2db-client |
| 134 | + yarn install |
| 135 | + yarn run build:web:prod --app_version=99.0.${{ github.run_id }} --app_port=10822 |
| 136 | + cp -r dist ../chat2db-server/chat2db-server-start/src/main/resources/static/front |
| 137 | + cp -r dist/index.html ../chat2db-server/chat2db-server-start/src/main/resources/thymeleaf/ |
| 138 | +
|
| 139 | + # 编译服务端java版本 |
| 140 | + - name: Build Java |
| 141 | + run: mvn clean package -B '-Dmaven.test.skip=true' -f chat2db-server/pom.xml |
| 142 | + |
| 143 | + # touch versions |
| 144 | + - name: touch versions |
| 145 | + run: | |
| 146 | + cd chat2db-client |
| 147 | + mkdir versions |
| 148 | + mkdir versions/99.0.${{ github.run_id }} |
| 149 | + mkdir versions/99.0.${{ github.run_id }}/static |
| 150 | + touch version |
| 151 | + echo -n 99.0.${{ github.run_id }} > version |
| 152 | + cp -r version ./versions/ |
| 153 | +
|
| 154 | + # 复制服务端java 到指定位置 |
| 155 | + - name: Copy App |
| 156 | + run: | |
| 157 | + cp chat2db-server/chat2db-server-start/target/chat2db-server-start.jar chat2db-client/versions/99.0.${{ github.run_id }}/static/ |
| 158 | + # cp -r chat2db-server/chat2db-server-start/target/lib chat2db-client/versions/99.0.${{ github.run_id }}/static/lib |
| 159 | + |
| 160 | + - name: Prepare Build Electron |
| 161 | + run: | |
| 162 | + cd chat2db-client |
| 163 | + yarn run build:web:desktop --app_version=99.0.${{ github.run_id }} --app_port=10822 |
| 164 | + cp -r dist ./versions/99.0.${{ github.run_id }}/ |
| 165 | + rm -r dist |
| 166 | +
|
| 167 | + # windows |
| 168 | + - name: Build/release Electron app for Windows |
| 169 | + if: ${{ runner.os == 'Windows' }} |
| 170 | + uses: samuelmeuli/action-electron-builder@v1 |
| 171 | + with: |
| 172 | + package_root: "chat2db-client/" |
| 173 | + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
| 174 | + mac_certs: ${{ secrets.mac_certs }} |
| 175 | + mac_certs_password: ${{ secrets.mac_certs_password }} |
| 176 | + skip_build: true |
| 177 | + args: "-c.appId=com.chat2db.test -c.productName=Chat2DB-Test -c.win.publisherName=Chat2DB-Test -c.nsis.shortcutName=Chat2DB-Test -c.extraMetadata.version=99.0.${{ github.run_id }}-Test --win --x64" |
| 178 | + |
| 179 | + # macos x86_64 |
| 180 | + - name: Build/release Electron app for MacOS X64 |
| 181 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'x86_64' }} |
| 182 | + uses: samuelmeuli/action-electron-builder@v1 |
| 183 | + with: |
| 184 | + package_root: "chat2db-client/" |
| 185 | + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
| 186 | + mac_certs: ${{ secrets.mac_certs }} |
| 187 | + mac_certs_password: ${{ secrets.mac_certs_password }} |
| 188 | + skip_build: true |
| 189 | + args: "-c.appId=com.chat2db.test -c.productName=Chat2DB-Test -c.nsis.shortcutName=Chat2DB-Test -c.extraMetadata.version=99.0.${{ github.run_id }}-Test --mac --x64" |
| 190 | + |
| 191 | + # x86_64 notarization |
| 192 | + - name: Notarization x86_64 App |
| 193 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'x86_64' }} |
| 194 | + run: | |
| 195 | + xcrun notarytool store-credentials "Chat2DB" --apple-id "${{secrets.MAC_APPLE_ID}}" --password "${{secrets.MAC_APPLE_PASSWORD}}" --team-id "${{secrets.MAC_TEAM_ID}}" |
| 196 | + xcrun notarytool submit chat2db-client/release/Chat2DB-Test-99.0.${{ github.run_id }}-Test.dmg --keychain-profile "Chat2DB" |
| 197 | + |
| 198 | + # macos arm64 |
| 199 | + - name: Build/release Electron app for MacOS arm64 |
| 200 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'arm64' }} |
| 201 | + uses: samuelmeuli/action-electron-builder@v1 |
| 202 | + with: |
| 203 | + package_root: "chat2db-client/" |
| 204 | + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
| 205 | + mac_certs: ${{ secrets.mac_certs }} |
| 206 | + mac_certs_password: ${{ secrets.mac_certs_password }} |
| 207 | + skip_build: true |
| 208 | + args: "-c.appId=com.chat2db.test -c.productName=Chat2DB-Test -c.nsis.shortcutName=Chat2DB-Test -c.extraMetadata.version=99.0.${{ github.run_id }}-Test --mac --arm64" |
| 209 | + |
| 210 | + # arm notarization |
| 211 | + - name: Notarization arm64 App |
| 212 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'arm64' }} |
| 213 | + run: | |
| 214 | + xcrun notarytool store-credentials "Chat2DB" --apple-id "${{secrets.MAC_APPLE_ID}}" --password "${{secrets.MAC_APPLE_PASSWORD}}" --team-id "${{secrets.MAC_TEAM_ID}}" |
| 215 | + xcrun notarytool submit chat2db-client/release/Chat2DB-Test-99.0.${{ github.run_id }}-Test-arm64.dmg --keychain-profile "Chat2DB" |
| 216 | +
|
| 217 | + # Linux |
| 218 | + - name: Delete File |
| 219 | + if: ${{ runner.os == 'Linux' }} |
| 220 | + run: | |
| 221 | + cd chat2db-client/static/jre/ |
| 222 | + ls -la |
| 223 | + rm -rf legal |
| 224 | + ls -la |
| 225 | +
|
| 226 | + - name: Build/release Electron app for Linux |
| 227 | + if: ${{ runner.os == 'Linux' }} |
| 228 | + uses: samuelmeuli/action-electron-builder@v1 |
| 229 | + with: |
| 230 | + package_root: "chat2db-client/" |
| 231 | + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
| 232 | + skip_build: true |
| 233 | + args: "-c.appId=com.chat2db.test -c.productName=test -c.nsis.shortcutName=test -c.extraMetadata.version=99.1.${{ github.run_id }} --linux" |
| 234 | + |
| 235 | + # 准备要需要的数据 Windows |
| 236 | + - name: Prepare upload for Windows |
| 237 | + if: runner.os == 'Windows' |
| 238 | + run: | |
| 239 | + mkdir oss_temp_file |
| 240 | + cp -r chat2db-client/release/*Setup*.exe ./oss_temp_file |
| 241 | +
|
| 242 | + # 准备要需要的数据 MacOS x86_64 |
| 243 | + - name: Prepare upload for MacOS x86_64 |
| 244 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'x86_64' }} |
| 245 | + run: | |
| 246 | + mkdir oss_temp_file |
| 247 | + cp chat2db-client/versions/99.0.${{ github.run_id }}/static/chat2db-server-start.jar ./oss_temp_file |
| 248 | + cp -r chat2db-client/release/*.dmg ./oss_temp_file |
| 249 | + cp -r chat2db-client/versions/99.0.${{ github.run_id }}/dist ./oss_temp_file/dist |
| 250 | + cd chat2db-client/versions/99.0.${{ github.run_id }}/ && zip -r 99.0.${{ github.run_id }}.zip ./ |
| 251 | + cp -r 99.0.${{ github.run_id }}.zip ../../../oss_temp_file |
| 252 | + cd static/ && zip -r chat2db-server-start.zip ./ |
| 253 | + cp -r chat2db-server-start.zip ../../../../oss_temp_file |
| 254 | +
|
| 255 | + # 准备要需要的数据 MacOS arm64 |
| 256 | + - name: Prepare upload for MacOS arm64 |
| 257 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'arm64' }} |
| 258 | + run: | |
| 259 | + mkdir oss_temp_file |
| 260 | + cp -r chat2db-client/release/*.dmg ./oss_temp_file |
| 261 | +
|
| 262 | + # 准备要需要的数据 Linux |
| 263 | + - name: Prepare upload for Linux |
| 264 | + if: runner.os == 'Linux' |
| 265 | + run: | |
| 266 | + mkdir oss_temp_file |
| 267 | + cp -r chat2db-client/release/*.AppImage ./oss_temp_file |
| 268 | +
|
| 269 | + # 把文件上传到OSS 方便下载 |
| 270 | + - name: Set up oss utils |
| 271 | + uses: yizhoumo/setup-ossutil@v1 |
| 272 | + with: |
| 273 | + endpoint: "oss-accelerate.aliyuncs.com" |
| 274 | + access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }} |
| 275 | + access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }} |
| 276 | + ossutil-version: "1.7.16" |
| 277 | + - name: Upload to oss |
| 278 | + run: | |
| 279 | + ossutil cp -rf --acl=public-read ./oss_temp_file/ oss://chat2db-client/test/99.0.${{ github.run_id }}/ |
| 280 | +
|
| 281 | + # 构建完成通知 |
| 282 | + - name: Send dingtalk message for Windows |
| 283 | + if: ${{ runner.os == 'Windows' }} |
| 284 | + uses: ghostoy/dingtalk-action@master |
| 285 | + with: |
| 286 | + webhook: ${{ secrets.DINGTALK_WEBHOOK }} |
| 287 | + msgtype: markdown |
| 288 | + content: | |
| 289 | + { |
| 290 | + "title": "Windows-test-打包完成通知", |
| 291 | + "text": "# Windows-test-打包完成通知 \n  \n ### 任务id:[${{ github.run_id }}](https://github.com/chat2db/Chat2DB/actions/runs/${{ github.run_id }}) \n ### Windows下载地址:[https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/Chat2DB-Test%20Setup%2099.0.${{ github.run_id }}-Test.exe](https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/Chat2DB-Test%20Setup%2099.0.${{ github.run_id }}-Test.exe) " |
| 292 | + } |
| 293 | +
|
| 294 | + # 构建完成通知 |
| 295 | + - name: Send dingtalk message for MacOS x86_64 |
| 296 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'x86_64' }} |
| 297 | + uses: ghostoy/dingtalk-action@master |
| 298 | + with: |
| 299 | + webhook: ${{ secrets.DINGTALK_WEBHOOK }} |
| 300 | + msgtype: markdown |
| 301 | + content: | |
| 302 | + { |
| 303 | + "title": "MacOS-x86_64-test-构建完成通知", |
| 304 | + "text": "# MacOS-x86_64-test-打包完成通知 \n  \n ### 任务id:[${{ github.run_id }}](https://github.com/chat2db/Chat2DB/actions/runs/${{ github.run_id }}) \n ### Intel芯片下载地址:[https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/Chat2DB-Test-99.0.${{ github.run_id }}-Test.dmg](https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/Chat2DB-Test-99.0.${{ github.run_id }}-Test.dmg) \n ### jar包下载地址:[https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/chat2db-server-start.zip](https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/chat2db-server-start.zip) " |
| 305 | + } |
| 306 | +
|
| 307 | + # 构建完成通知 |
| 308 | + - name: Send dingtalk message for MacOS arm64 |
| 309 | + if: ${{ runner.os == 'macOS' && matrix.arch == 'arm64' }} |
| 310 | + uses: ghostoy/dingtalk-action@master |
| 311 | + with: |
| 312 | + webhook: ${{ secrets.DINGTALK_WEBHOOK }} |
| 313 | + msgtype: markdown |
| 314 | + content: | |
| 315 | + { |
| 316 | + "title": "MacOS-arm64-test-构建完成通知", |
| 317 | + "text": "# MacOS-arm64-test-打包完成通知 \n  \n ### 任务id:[${{ github.run_id }}](https://github.com/chat2db/Chat2DB/actions/runs/${{ github.run_id }}) \n ### Apple芯片下载地址:[https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/Chat2DB-Test-99.0.${{ github.run_id }}-Test-arm64.dmg](https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/Chat2DB-Test-99.0.${{ github.run_id }}-Test-arm64.dmg) " |
| 318 | + } |
| 319 | +
|
| 320 | + # 构建完成通知 |
| 321 | + - name: Send dingtalk message for Linux |
| 322 | + if: ${{ runner.os == 'Linux' }} |
| 323 | + uses: ghostoy/dingtalk-action@master |
| 324 | + with: |
| 325 | + webhook: ${{ secrets.DINGTALK_WEBHOOK }} |
| 326 | + msgtype: markdown |
| 327 | + content: | |
| 328 | + { |
| 329 | + "title": "Linux-test-打包完成通知", |
| 330 | + "text": "# Linux-test-打包完成通知 \n  \n ### 任务id:[${{ github.run_id }}](https://github.com/chat2db/Chat2DB/actions/runs/${{ github.run_id }}) \n ### Linux下载地址:[https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/Chat2DB-Test-99.0.${{ github.run_id }}-Test.AppImage](https://oss.sqlgpt.cn/test/99.0.${{ github.run_id }}/Chat2DB-Test-99.0.${{ github.run_id }}-Test.AppImage) " |
| 331 | + } |
0 commit comments