build.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. name: Build
  2. on:
  3. push:
  4. paths-ignore:
  5. - 'docs/**'
  6. - 'mirai-console/docs/**'
  7. - '**/*.md'
  8. pull_request:
  9. paths-ignore:
  10. - 'docs/**'
  11. - 'mirai-console/docs/**'
  12. - '**/*.md'
  13. jobs:
  14. build-mirai-jvm:
  15. name: "JVM (${{ matrix.os }})"
  16. runs-on: ${{ matrix.os }}
  17. strategy:
  18. fail-fast: false
  19. matrix:
  20. os: # You must use macos-12. Only macos-12 get 14GB memory while others have only 7GB.
  21. # - windows-2022
  22. - macos-12
  23. env:
  24. gradleArgs: --scan "-Dmirai.target=jvm;android;!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx6000m" "-Dfile.encoding=UTF-8"
  25. isMac: ${{ startsWith(matrix.os, 'macos') }}
  26. isWindows: ${{ startsWith(matrix.os, 'windows') }}
  27. isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
  28. isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
  29. steps:
  30. - uses: actions/checkout@v2
  31. with:
  32. submodules: 'recursive'
  33. - uses: actions/setup-java@v2
  34. with:
  35. distribution: 'temurin'
  36. java-version: '17'
  37. - name: Setup Gradle
  38. uses: gradle/gradle-build-action@v2
  39. - if: ${{ env.isUnix == 'true' }}
  40. run: chmod -R 777 *
  41. - if: ${{ env.isWindows == 'true' }}
  42. name: Setup Memory Environment on Windows
  43. run: >
  44. wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=18432 &
  45. net stop mongodb
  46. shell: cmd
  47. continue-on-error: true
  48. - name: Clean and download dependencies
  49. run: ./gradlew clean ${{ env.gradleArgs }}
  50. - run: >
  51. ./gradlew updateSnapshotVersion ${{ env.gradleArgs }}
  52. if: github.event.pusher
  53. env:
  54. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  55. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  56. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  57. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  58. CURRENT_BRANCH_NAME: dev # always use -dev for now
  59. - name: "Assemble"
  60. run: ./gradlew assemble ${{ env.gradleArgs }}
  61. - name: Publish Local Artifacts
  62. if: ${{ env.enableLocalPublishingTest == 'true' }}
  63. run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
  64. - name: "Check"
  65. run: ./gradlew check ${{ env.gradleArgs }}
  66. # Upload
  67. - name: Upload mirai-core-utils
  68. uses: actions/upload-artifact@v3
  69. with:
  70. name: mirai-core-utils
  71. path: mirai-core-utils/build/libs
  72. - name: Upload mirai-core-api
  73. uses: actions/upload-artifact@v3
  74. with:
  75. name: mirai-core-api
  76. path: mirai-core-api/build/libs
  77. - name: Upload mirai-core
  78. uses: actions/upload-artifact@v3
  79. with:
  80. name: mirai-core
  81. path: mirai-core/build/libs
  82. - name: Upload mirai-core-all
  83. uses: actions/upload-artifact@v3
  84. with:
  85. name: mirai-core-all
  86. path: mirai-core-all/build/libs
  87. - name: Upload mirai-console
  88. uses: actions/upload-artifact@v3
  89. with:
  90. name: mirai-console
  91. path: mirai-console/backend/mirai-console/build/libs
  92. - name: Upload mirai-console-terminal
  93. uses: actions/upload-artifact@v3
  94. with:
  95. name: mirai-console-terminal
  96. path: mirai-console/frontend/mirai-console-terminal/build/libs
  97. - name: Upload mirai-console-compiler-annotations
  98. uses: actions/upload-artifact@v3
  99. with:
  100. name: mirai-console-compiler-annotations
  101. path: mirai-console/tools/mirai-console-compiler-annotations/build/libs
  102. - name: Upload mirai-console-compiler-common
  103. uses: actions/upload-artifact@v3
  104. with:
  105. name: mirai-console-compiler-common
  106. path: mirai-console/tools/mirai-console-compiler-common/build/libs
  107. - name: Upload mirai-console-intellij
  108. uses: actions/upload-artifact@v3
  109. with:
  110. name: mirai-console-intellij
  111. path: mirai-console/tools/intelli-plugin/build/distribution
  112. - name: Upload mirai-logging-log4j2
  113. uses: actions/upload-artifact@v3
  114. with:
  115. name: mirai-logging-log4j2
  116. path: logging/mirai-logging-log4j2/build/libs
  117. - name: Upload mirai-logging-slf4j
  118. uses: actions/upload-artifact@v3
  119. with:
  120. name: mirai-logging-slf4j
  121. path: logging/mirai-logging-slf4j/build/libs
  122. - name: Upload mirai-logging-slf4j-logback
  123. uses: actions/upload-artifact@v3
  124. with:
  125. name: mirai-logging-slf4j-logback
  126. path: logging/mirai-logging-slf4j-logback/build/libs
  127. - name: Upload mirai-logging-slf4j-simple
  128. uses: actions/upload-artifact@v3
  129. with:
  130. name: mirai-logging-slf4j-simple
  131. path: logging/mirai-logging-slf4j-simple/build/libs
  132. build-mirai-all:
  133. name: "Everything (${{ matrix.os }})"
  134. runs-on: ${{ matrix.os }}
  135. strategy:
  136. fail-fast: false
  137. matrix:
  138. os:
  139. - macos-12
  140. env:
  141. enableLocalPublishingTest: 'false'
  142. gradleArgs: --scan
  143. isMac: ${{ startsWith(matrix.os, 'macos') }}
  144. isWindows: ${{ startsWith(matrix.os, 'windows') }}
  145. isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
  146. isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
  147. steps:
  148. - uses: actions/checkout@v2
  149. with:
  150. submodules: 'recursive'
  151. - uses: actions/setup-java@v2
  152. with:
  153. distribution: 'temurin'
  154. java-version: '17'
  155. - name: Setup Gradle
  156. uses: gradle/gradle-build-action@v2
  157. - name: Cache konan
  158. uses: pat-s/[email protected]
  159. with:
  160. path: ~/.konan
  161. key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
  162. restore-keys: |
  163. ${{ runner.os }}-gradle-
  164. - if: ${{ env.isUnix == 'true' }}
  165. run: chmod -R 777 *
  166. # Prepare environment for linking for macOS
  167. - if: ${{ env.isMac == 'true' }}
  168. name: Install OpenSSL
  169. run: >
  170. git clone https://github.com/openssl/openssl.git --recursive &&
  171. cd openssl &&
  172. git checkout tags/openssl-3.0.3 &&
  173. ./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl &&
  174. make &&
  175. sudo make install
  176. - name: Clean and download dependencies
  177. run: ./gradlew clean ${{ env.gradleArgs }}
  178. - run: >
  179. ./gradlew updateSnapshotVersion ${{ env.gradleArgs }}
  180. if: github.event.pusher
  181. env:
  182. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  183. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  184. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  185. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  186. CURRENT_BRANCH_NAME: dev # always use -dev for now
  187. - name: "Assemble"
  188. run: ./gradlew assemble ${{ env.gradleArgs }}
  189. - name: Publish Local Artifacts
  190. if: ${{ env.enableLocalPublishingTest == 'true' }}
  191. run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
  192. - name: "Check"
  193. run: ./gradlew check ${{ env.gradleArgs }}
  194. - if: ${{ env.isMac == 'true' }}
  195. name: Ensure KDoc valid
  196. run: ./gradlew dokkaHtmlMultiModule ${{ env.gradleArgs }}
  197. - name: Release RAM
  198. run: node ci-release-helper/scripts/kill-java.js
  199. - name: Publish Snapshots
  200. if: ${{ github.event.pusher && env.isMac == 'true' }}
  201. run: ./gradlew publishAllPublicationsToMiraiRepoRepository ${{ env.gradleArgs }}
  202. env:
  203. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  204. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  205. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  206. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  207. CURRENT_BRANCH_NAME: dev
  208. build-mirai-core-native:
  209. name: "Native (${{ matrix.os }})"
  210. runs-on: ${{ matrix.os }}
  211. strategy:
  212. fail-fast: false
  213. matrix:
  214. os:
  215. - windows-2022
  216. - ubuntu-20.04
  217. # - ubuntu-18.04
  218. # - macos-12
  219. # - macos-11
  220. include:
  221. - os: windows-2022
  222. targetName: mingwX64
  223. - os: ubuntu-20.04
  224. targetName: linuxX64
  225. # - os: macos-12
  226. # targetName: macosX64
  227. # - os: macos-11
  228. # targetName: macosX64
  229. env:
  230. # FIXME there must be two or more targets, or we'll get error on `@OptionalExpectation`
  231. # > Declaration annotated with '@OptionalExpectation' can only be used in common module sources
  232. enableLocalPublishingTest: 'false'
  233. gradleArgs: --scan "-Dmirai.target=jvm;${{ matrix.targetName }};!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8"
  234. isMac: ${{ startsWith(matrix.os, 'macos') }}
  235. isWindows: ${{ startsWith(matrix.os, 'windows') }}
  236. isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
  237. isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
  238. VCPKG_DEFAULT_BINARY_CACHE: ${{ startsWith(matrix.os, 'windows') && 'C:\vcpkg\binary_cache' || '/usr/local/share/vcpkg/binary_cache' }}
  239. steps:
  240. - uses: actions/checkout@v2
  241. with:
  242. submodules: 'recursive'
  243. - uses: actions/setup-java@v2
  244. with:
  245. distribution: 'adopt-openj9'
  246. java-version: '17'
  247. - name: Setup Gradle
  248. uses: gradle/gradle-build-action@v2
  249. - name: Cache konan
  250. uses: pat-s/[email protected]
  251. with:
  252. path: ~/.konan
  253. key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
  254. restore-keys: |
  255. ${{ runner.os }}-gradle-
  256. - name: Prepare to cache vcpkg
  257. if: ${{ env.isWindows == 'true' }}
  258. run: mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  259. - name: Cache vcpkg
  260. if: ${{ env.isWindows == 'true' }}
  261. uses: pat-s/[email protected]
  262. with:
  263. path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  264. key: ${{ runner.os }}-vcpkg-binary-cache-${{ github.job }}
  265. restore-keys: |
  266. ${{ runner.os }}-vcpkg-binary-cache-
  267. - if: ${{ env.isUnix == 'true' }}
  268. run: chmod -R 777 *
  269. # Prepare environment for linking on macOS
  270. - if: ${{ env.isMac == 'true' }}
  271. name: Install OpenSSL on Mac OS
  272. run: >
  273. git clone https://github.com/openssl/openssl.git --recursive &&
  274. cd openssl &&
  275. git checkout tags/openssl-3.0.3 &&
  276. ./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl &&
  277. make &&
  278. sudo make install
  279. # Prepare environment for linking on Ubuntu
  280. - if: ${{ env.isUbuntu == 'true' }}
  281. name: Install OpenSSL on Ubuntu
  282. run: sudo apt install libssl-dev -y
  283. # Prepare environment for linking on Windows
  284. - if: ${{ env.isWindows == 'true' }}
  285. name: Setup Memory Environment on Windows
  286. run: >
  287. wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=9216 &
  288. net stop mongodb
  289. shell: cmd
  290. continue-on-error: true
  291. - if: ${{ env.isWindows == 'true' }}
  292. name: Install OpenSSL & cURL on Windows
  293. run: |
  294. echo "set(VCPKG_BUILD_TYPE release)" | Out-File -FilePath "$env:VCPKG_INSTALLATION_ROOT\triplets\x64-windows.cmake" -Encoding utf8 -Append
  295. vcpkg install openssl:x64-windows curl[core,ssl]:x64-windows
  296. New-Item -Path $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\crypto.lib -ItemType SymbolicLink -Value $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\libcrypto.lib
  297. New-Item -Path $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\ssl.lib -ItemType SymbolicLink -Value $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\libssl.lib
  298. New-Item -Path $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\curl.lib -ItemType SymbolicLink -Value $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\libcurl.lib
  299. echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  300. - name: Clean and download dependencies
  301. run: ./gradlew clean ${{ env.gradleArgs }}
  302. - run: >
  303. ./gradlew updateSnapshotVersion ${{ env.gradleArgs }}
  304. if: github.event.pusher
  305. env:
  306. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  307. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  308. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  309. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  310. CURRENT_BRANCH_NAME: dev # always use -dev for now
  311. - name: "Test mirai-core-utils for ${{ matrix.os }}"
  312. run: ./gradlew :mirai-core-utils:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  313. - name: "Test mirai-core-api for ${{ matrix.os }}"
  314. run: ./gradlew :mirai-core-api:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  315. - name: "Test mirai-core for ${{ matrix.os }}"
  316. run: ./gradlew :mirai-core:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  317. - name: Publish Local Artifacts
  318. if: ${{ env.enableLocalPublishingTest == 'true' }}
  319. run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
  320. - name: Check Publication
  321. if: ${{ env.enableLocalPublishingTest == 'true' }}
  322. run: ./gradlew :mirai-deps-test:check ${{ env.gradleArgs }}
  323. # Publish native snapshots. Other artifacts are published in build-mirai-all
  324. - name: Release RAM
  325. run: node ci-release-helper/scripts/kill-java.js
  326. - name: Publish MingwX64 Snapshots
  327. if: ${{ github.event.pusher && env.isWindows == 'true' }}
  328. run: ./gradlew publishMingwX64PublicationToMiraiRepoRepository ${{ env.gradleArgs }}
  329. env:
  330. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  331. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  332. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  333. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  334. CURRENT_BRANCH_NAME: dev
  335. - name: Publish LinuxX64 Snapshots
  336. if: ${{ github.event.pusher && env.isUbuntu == 'true' }}
  337. run: ./gradlew publishLinuxX64PublicationToMiraiRepoRepository ${{ env.gradleArgs }}
  338. env:
  339. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  340. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  341. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  342. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  343. CURRENT_BRANCH_NAME: dev
  344. - name: Publish macOSX64 Snapshots
  345. if: ${{ github.event.pusher && env.isMac == 'true' }}
  346. run: ./gradlew publishMacosX64PublicationToMiraiRepoRepository ${{ env.gradleArgs }}
  347. env:
  348. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  349. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  350. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  351. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  352. CURRENT_BRANCH_NAME: dev