build.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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: Publish Snapshots
  198. if: ${{ github.event.pusher && env.isMac == 'true' }}
  199. run: ./gradlew publishAllPublicationsToMiraiRepoRepository ${{ env.gradleArgs }}
  200. env:
  201. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  202. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  203. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  204. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  205. CURRENT_BRANCH_NAME: dev
  206. build-mirai-core-native:
  207. name: "Native (${{ matrix.os }})"
  208. runs-on: ${{ matrix.os }}
  209. strategy:
  210. fail-fast: false
  211. matrix:
  212. os:
  213. - windows-2022
  214. - ubuntu-20.04
  215. # - ubuntu-18.04
  216. # - macos-12
  217. # - macos-11
  218. include:
  219. - os: windows-2022
  220. targetName: mingwX64
  221. - os: ubuntu-20.04
  222. targetName: linuxX64
  223. # - os: macos-12
  224. # targetName: macosX64
  225. # - os: macos-11
  226. # targetName: macosX64
  227. env:
  228. # FIXME there must be two or more targets, or we'll get error on `@OptionalExpectation`
  229. # > Declaration annotated with '@OptionalExpectation' can only be used in common module sources
  230. enableLocalPublishingTest: 'false'
  231. gradleArgs: --scan "-Dmirai.target=jvm;${{ matrix.targetName }};!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8"
  232. isMac: ${{ startsWith(matrix.os, 'macos') }}
  233. isWindows: ${{ startsWith(matrix.os, 'windows') }}
  234. isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
  235. isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
  236. VCPKG_DEFAULT_BINARY_CACHE: ${{ startsWith(matrix.os, 'windows') && 'C:\vcpkg\binary_cache' || '/usr/local/share/vcpkg/binary_cache' }}
  237. steps:
  238. - uses: actions/checkout@v2
  239. with:
  240. submodules: 'recursive'
  241. - uses: actions/setup-java@v2
  242. with:
  243. distribution: 'adopt-openj9'
  244. java-version: '17'
  245. - name: Setup Gradle
  246. uses: gradle/gradle-build-action@v2
  247. - name: Cache konan
  248. uses: pat-s/[email protected]
  249. with:
  250. path: ~/.konan
  251. key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
  252. restore-keys: |
  253. ${{ runner.os }}-gradle-
  254. - name: Prepare to cache vcpkg
  255. if: ${{ env.isWindows == 'true' }}
  256. run: mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  257. - name: Cache vcpkg
  258. if: ${{ env.isWindows == 'true' }}
  259. uses: pat-s/[email protected]
  260. with:
  261. path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  262. key: ${{ runner.os }}-vcpkg-binary-cache-${{ github.job }}
  263. restore-keys: |
  264. ${{ runner.os }}-vcpkg-binary-cache-
  265. - if: ${{ env.isUnix == 'true' }}
  266. run: chmod -R 777 *
  267. # Prepare environment for linking on macOS
  268. - if: ${{ env.isMac == 'true' }}
  269. name: Install OpenSSL on Mac OS
  270. run: >
  271. git clone https://github.com/openssl/openssl.git --recursive &&
  272. cd openssl &&
  273. git checkout tags/openssl-3.0.3 &&
  274. ./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl &&
  275. make &&
  276. sudo make install
  277. # Prepare environment for linking on Ubuntu
  278. - if: ${{ env.isUbuntu == 'true' }}
  279. name: Install OpenSSL on Ubuntu
  280. run: sudo apt install libssl-dev -y
  281. # Prepare environment for linking on Windows
  282. - if: ${{ env.isWindows == 'true' }}
  283. name: Setup Memory Environment on Windows
  284. run: >
  285. wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=9216 &
  286. net stop mongodb
  287. shell: cmd
  288. continue-on-error: true
  289. - if: ${{ env.isWindows == 'true' }}
  290. name: Install OpenSSL & cURL on Windows
  291. run: |
  292. echo "set(VCPKG_BUILD_TYPE release)" | Out-File -FilePath "$env:VCPKG_INSTALLATION_ROOT\triplets\x64-windows.cmake" -Encoding utf8 -Append
  293. vcpkg install openssl:x64-windows curl[core,ssl]:x64-windows
  294. 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
  295. 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
  296. 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
  297. echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  298. - name: Clean and download dependencies
  299. run: ./gradlew clean ${{ env.gradleArgs }}
  300. - run: >
  301. ./gradlew updateSnapshotVersion ${{ env.gradleArgs }}
  302. if: github.event.pusher
  303. env:
  304. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  305. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  306. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  307. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  308. CURRENT_BRANCH_NAME: dev # always use -dev for now
  309. - name: "Test mirai-core-utils for ${{ matrix.os }}"
  310. run: ./gradlew :mirai-core-utils:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  311. - name: "Test mirai-core-api for ${{ matrix.os }}"
  312. run: ./gradlew :mirai-core-api:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  313. - name: "Test mirai-core for ${{ matrix.os }}"
  314. run: ./gradlew :mirai-core:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  315. - name: Publish Local Artifacts
  316. if: ${{ env.enableLocalPublishingTest == 'true' }}
  317. run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
  318. - name: Check Publication
  319. if: ${{ env.enableLocalPublishingTest == 'true' }}
  320. run: ./gradlew :mirai-deps-test:check ${{ env.gradleArgs }}
  321. # Publish native snapshots. Other artifacts are published in build-mirai-all
  322. - name: Publish MingwX64 Snapshots
  323. if: ${{ github.event.pusher && env.isWindows == 'true' }}
  324. run: ./gradlew publishMingwX64PublicationToMiraiRepoRepository ${{ env.gradleArgs }}
  325. env:
  326. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  327. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  328. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  329. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  330. CURRENT_BRANCH_NAME: dev
  331. - name: Publish LinuxX64 Snapshots
  332. if: ${{ github.event.pusher && env.isUbuntu == 'true' }}
  333. run: ./gradlew publishLinuxX64PublicationToMiraiRepoRepository ${{ env.gradleArgs }}
  334. env:
  335. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  336. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  337. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  338. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  339. CURRENT_BRANCH_NAME: dev
  340. - name: Publish macOSX64 Snapshots
  341. if: ${{ github.event.pusher && env.isMac == 'true' }}
  342. run: ./gradlew publishMacosX64PublicationToMiraiRepoRepository ${{ env.gradleArgs }}
  343. env:
  344. MIRAI_IS_SNAPSHOTS_PUBLISHING: true
  345. SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
  346. SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
  347. SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
  348. CURRENT_BRANCH_NAME: dev