release.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. name: Release Publish
  2. on:
  3. push:
  4. tags:
  5. - 'v*' # 正式版本
  6. paths-ignore:
  7. - 'docs/**'
  8. - 'mirai-console/docs/**'
  9. - '**/*.md'
  10. jobs:
  11. initialize-sonatype-stage:
  12. name: "Initialize sonatype staging repository"
  13. runs-on: ubuntu-latest
  14. steps:
  15. - uses: actions/checkout@v2
  16. with:
  17. submodules: 'recursive'
  18. - uses: actions/setup-java@v2
  19. with:
  20. distribution: 'temurin'
  21. java-version: '17'
  22. - name: Setup Gradle
  23. uses: gradle/gradle-build-action@v2
  24. - run: chmod -R 777 *
  25. - name: Create publishing staging repository
  26. run: ./gradlew runcihelper --args create-stage-repo --scan "-Pcihelper.cert.username=${{ secrets.SONATYPE_USER }}" "-Pcihelper.cert.password=${{ secrets.SONATYPE_KEY }}" "-Pcihelper.cert.profileid=${{ secrets.SONATYPE_PROFILEID }}"
  27. - name: Cache staging repository id
  28. uses: actions/upload-artifact@v3
  29. with:
  30. name: publish-stage-id
  31. path: ci-release-helper/repoid
  32. publish-others:
  33. name: "Others (${{ matrix.os }})"
  34. runs-on: ${{ matrix.os }}
  35. needs: [ initialize-sonatype-stage ]
  36. strategy:
  37. fail-fast: false
  38. matrix:
  39. os:
  40. - macos-12
  41. env:
  42. # All targets MUST be enabled. See #2270.
  43. gradleArgs: --scan "-Dmirai.target=other" "-Pkotlin.compiler.execution.strategy=in-process"
  44. isMac: ${{ startsWith(matrix.os, 'macos') }}
  45. isWindows: ${{ startsWith(matrix.os, 'windows') }}
  46. isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
  47. isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
  48. steps:
  49. - uses: actions/checkout@v2
  50. with:
  51. submodules: 'recursive'
  52. - uses: actions/setup-java@v2
  53. with:
  54. distribution: 'temurin'
  55. java-version: '17'
  56. - name: Keys setup
  57. shell: bash
  58. run: |
  59. mkdir build-gpg-sign
  60. echo "$GPG_PRIVATE" > build-gpg-sign/keys.gpg
  61. echo "$GPG_PUBLIC_" > build-gpg-sign/keys.gpg.pub
  62. env:
  63. GPG_PRIVATE: ${{ secrets.GPG_PRIVATE_KEY }}
  64. GPG_PUBLIC_: ${{ secrets.GPG_PUBLIC_KEY }}
  65. - name: Setup Gradle
  66. uses: gradle/gradle-build-action@v2
  67. - name: Cache konan
  68. uses: pat-s/[email protected]
  69. with:
  70. path: ~/.konan
  71. key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
  72. restore-keys: |
  73. ${{ runner.os }}-gradle-
  74. - if: ${{ env.isUnix == 'true' }}
  75. run: chmod -R 777 *
  76. # Prepare environment for linking for macOS
  77. - if: ${{ env.isMac == 'true' }}
  78. name: Install OpenSSL
  79. run: >
  80. git clone https://github.com/openssl/openssl.git --recursive &&
  81. cd openssl &&
  82. git checkout tags/openssl-3.0.3 &&
  83. ./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl &&
  84. make &&
  85. sudo make install
  86. - name: Clean and download dependencies
  87. run: ./gradlew clean ${{ env.gradleArgs }}
  88. - name: "Assemble"
  89. run: ./gradlew assemble ${{ env.gradleArgs }}
  90. - name: Publish Local Artifacts
  91. if: ${{ env.enableLocalPublishingTest == 'true' }}
  92. run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
  93. - name: "Check"
  94. run: ./gradlew check ${{ env.gradleArgs }}
  95. - if: ${{ env.isMac == 'true' }}
  96. name: Ensure KDoc valid
  97. run: ./gradlew dokkaHtmlMultiModule ${{ env.gradleArgs }}
  98. - name: Initialize Publishing Caching Repository
  99. run: ./gradlew runcihelper --args sync-maven-metadata ${{ env.gradleArgs }}
  100. - name: Publish
  101. if: ${{ env.isMac == 'true' }}
  102. run: ./gradlew publishAllPublicationsToMiraiStageRepoRepository ${{ env.gradleArgs }}
  103. - name: Restore staging repository id
  104. uses: actions/download-artifact@v3
  105. with:
  106. name: publish-stage-id
  107. path: ci-release-helper/repoid
  108. - name: Release RAM
  109. run: node ci-release-helper/scripts/kill-java.js
  110. - name: Publish to maven central
  111. run: ./gradlew runcihelper --args publish-to-maven-central --scan "-Pcihelper.cert.username=${{ secrets.SONATYPE_USER }}" "-Pcihelper.cert.password=${{ secrets.SONATYPE_KEY }}"
  112. - name: Publish Gradle plugin
  113. run: ./gradlew
  114. :mirai-console-gradle:publishPlugins ${{ env.gradleArgs }}
  115. -Dgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} -Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }}
  116. -Dgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }} -Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
  117. continue-on-error: true
  118. publish-core-native:
  119. name: "Native (${{ matrix.os }})"
  120. needs: [ publish-others ] # Allow MPP metadata to be uploaded first.
  121. runs-on: ${{ matrix.os }}
  122. strategy:
  123. fail-fast: false
  124. matrix:
  125. os:
  126. - windows-2022
  127. - ubuntu-20.04
  128. # - macos-12 # macOS artifacts published in 'publish-others'
  129. include:
  130. - os: windows-2022
  131. targetName: mingwX64
  132. # parallelCompilation: false
  133. - os: ubuntu-20.04
  134. targetName: linuxX64
  135. # parallelCompilation: false
  136. - os: macos-12
  137. targetName: macosX64
  138. # parallelCompilation: true # macOS machine has 14G
  139. env:
  140. # FIXME there must be two or more targets, or we'll get error on `@OptionalExpectation`
  141. # > Declaration annotated with '@OptionalExpectation' can only be used in common module sources
  142. gradleArgs: --scan "-Dmirai.target=jvm;${{ matrix.targetName }};~other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m" "-Dfile.encoding=UTF-8"
  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. VCPKG_DEFAULT_BINARY_CACHE: ${{ startsWith(matrix.os, 'windows') && 'C:\vcpkg\binary_cache' || '/usr/local/share/vcpkg/binary_cache' }}
  148. steps:
  149. - uses: actions/checkout@v2
  150. with:
  151. submodules: 'recursive'
  152. - uses: actions/setup-java@v2
  153. with:
  154. distribution: 'adopt-openj9'
  155. java-version: '17'
  156. - name: Keys setup
  157. shell: bash
  158. run: |
  159. mkdir build-gpg-sign
  160. echo "$GPG_PRIVATE" > build-gpg-sign/keys.gpg
  161. echo "$GPG_PUBLIC_" > build-gpg-sign/keys.gpg.pub
  162. env:
  163. GPG_PRIVATE: ${{ secrets.GPG_PRIVATE_KEY }}
  164. GPG_PUBLIC_: ${{ secrets.GPG_PUBLIC_KEY }}
  165. - name: Setup Gradle
  166. uses: gradle/gradle-build-action@v2
  167. - name: Cache konan
  168. uses: pat-s/[email protected]
  169. with:
  170. path: ~/.konan
  171. key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
  172. restore-keys: |
  173. ${{ runner.os }}-gradle-
  174. - name: Prepare to cache vcpkg
  175. if: ${{ env.isWindows == 'true' }}
  176. run: mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  177. - name: Cache vcpkg
  178. if: ${{ env.isWindows == 'true' }}
  179. uses: pat-s/[email protected]
  180. with:
  181. path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  182. key: ${{ runner.os }}-vcpkg-binary-cache-${{ github.job }}
  183. restore-keys: |
  184. ${{ runner.os }}-vcpkg-binary-cache-
  185. - if: ${{ env.isUnix == 'true' }}
  186. run: chmod -R 777 *
  187. # Prepare environment for linking on macOS
  188. - if: ${{ env.isMac == 'true' }}
  189. name: Install OpenSSL on Mac OS
  190. run: >
  191. git clone https://github.com/openssl/openssl.git --recursive &&
  192. cd openssl &&
  193. git checkout tags/openssl-3.0.3 &&
  194. ./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl &&
  195. make &&
  196. sudo make install
  197. # Prepare environment for linking on Ubuntu
  198. - if: ${{ env.isUbuntu == 'true' }}
  199. name: Install OpenSSL on Ubuntu
  200. run: sudo apt install libssl-dev -y
  201. # Prepare environment for linking on Windows
  202. - if: ${{ env.isWindows == 'true' }}
  203. name: Setup Memory Environment on Windows
  204. run: >
  205. wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=9216 &
  206. net stop mongodb
  207. shell: cmd
  208. continue-on-error: true
  209. - if: ${{ env.isWindows == 'true' }}
  210. name: Install OpenSSL & cURL on Windows
  211. run: |
  212. echo "set(VCPKG_BUILD_TYPE release)" | Out-File -FilePath "$env:VCPKG_INSTALLATION_ROOT\triplets\x64-windows.cmake" -Encoding utf8 -Append
  213. vcpkg install openssl:x64-windows curl[core,ssl]:x64-windows
  214. 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
  215. 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
  216. 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
  217. echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  218. - name: Clean and download dependencies
  219. run: ./gradlew clean ${{ env.gradleArgs }}
  220. - name: "Test mirai-core-utils for ${{ matrix.os }}"
  221. run: ./gradlew :mirai-core-utils:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  222. - name: "Test mirai-core-api for ${{ matrix.os }}"
  223. run: ./gradlew :mirai-core-api:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  224. - name: "Test mirai-core for ${{ matrix.os }}"
  225. run: ./gradlew :mirai-core:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
  226. - name: Initialize Publishing Caching Repository
  227. run: ./gradlew runcihelper --args sync-maven-metadata ${{ env.gradleArgs }}
  228. - name: Release RAM
  229. run: node ci-release-helper/scripts/kill-java.js
  230. # # Parallel compilation will exhaust machine memory causing OOM
  231. # - name: Assemble
  232. # run: ./gradlew assemble ${{ env.gradleArgs }} "-Porg.gradle.parallel=${{ matrix.parallelCompilation }}"
  233. - name: Publish MingwX64
  234. if: ${{ env.isWindows == 'true' }}
  235. run: ./gradlew publishMingwX64PublicationToMiraiStageRepoRepository ${{ env.gradleArgs }}
  236. - name: Publish LinuxX64
  237. if: ${{ env.isUbuntu == 'true' }}
  238. run: ./gradlew publishLinuxX64PublicationToMiraiStageRepoRepository ${{ env.gradleArgs }}
  239. - name: Publish macOSX64
  240. if: ${{ env.isMac == 'true' }}
  241. run: ./gradlew publishMacosX64PublicationToMiraiStageRepoRepository ${{ env.gradleArgs }}
  242. - name: Restore staging repository id
  243. uses: actions/download-artifact@v3
  244. with:
  245. name: publish-stage-id
  246. path: ci-release-helper/repoid
  247. - name: Release RAM
  248. run: node ci-release-helper/scripts/kill-java.js
  249. - name: Publish to maven central
  250. run: ./gradlew runcihelper --args publish-to-maven-central --scan "-Pcihelper.cert.username=${{ secrets.SONATYPE_USER }}" "-Pcihelper.cert.password=${{ secrets.SONATYPE_KEY }}"
  251. #
  252. # close-repository:
  253. # runs-on: macos-12
  254. # needs:
  255. # - publish-others
  256. # - publish-core-native
  257. # steps:
  258. # - uses: actions/checkout@v2
  259. # with:
  260. # submodules: 'recursive'
  261. #
  262. # - uses: actions/setup-java@v2
  263. # with:
  264. # distribution: 'adopt-openj9'
  265. # java-version: '17'
  266. #
  267. # - name: Setup Gradle
  268. # uses: gradle/gradle-build-action@v2
  269. #
  270. # - name: Close repository
  271. # run: ./gradlew :ci-release-helper:closeRepository --scan