check-publishing.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # 当修改构建脚本 (包括修改依赖版本) 时检查配置是否能正常发版
  2. # 发版检查非常慢, 因此不在 build.yml 做
  3. name: Check Publishing
  4. on:
  5. push:
  6. paths:
  7. - '**/**.gradle.kts'
  8. - '**/gradle.properties'
  9. - 'buildSrc/**'
  10. pull_request:
  11. paths:
  12. - '**/**.gradle.kts'
  13. - '**/gradle.properties'
  14. - 'buildSrc/**'
  15. jobs:
  16. check-publishing:
  17. name: "Check Publishing (${{ matrix.os }})"
  18. runs-on: ${{ matrix.os }}
  19. strategy:
  20. fail-fast: false
  21. matrix:
  22. os:
  23. # - windows-2022 # OOM
  24. - ubuntu-20.04
  25. - macos-12
  26. include:
  27. # - os: windows-2022
  28. # targetName: mingwX64
  29. # parallelCompilation: false
  30. - os: ubuntu-20.04
  31. targetName: linuxX64
  32. parallelCompilation: false
  33. - os: macos-12
  34. targetName: macosX64
  35. parallelCompilation: true # macOS machine has 14G
  36. env:
  37. # FIXME there must be two or more targets, or we'll get error on `@OptionalExpectation`
  38. # > Declaration annotated with '@OptionalExpectation' can only be used in common module sources
  39. gradleArgs: --scan
  40. isMac: ${{ startsWith(matrix.os, 'macos') }}
  41. isWindows: ${{ startsWith(matrix.os, 'windows') }}
  42. isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
  43. isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
  44. VCPKG_DEFAULT_BINARY_CACHE: ${{ startsWith(matrix.os, 'windows') && 'C:\vcpkg\binary_cache' || '/usr/local/share/vcpkg/binary_cache' }}
  45. steps:
  46. - uses: actions/checkout@v3
  47. with:
  48. submodules: 'recursive'
  49. - uses: actions/setup-java@v3
  50. with:
  51. distribution: 'adopt-openj9'
  52. java-version: '17'
  53. - name: Setup Gradle
  54. uses: gradle/gradle-build-action@v2
  55. - name: Cache konan
  56. uses: pat-s/always-upload-cache@v3.0.11
  57. with:
  58. path: ~/.konan
  59. key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
  60. restore-keys: |
  61. ${{ runner.os }}-gradle-
  62. - name: Prepare to cache vcpkg
  63. if: ${{ env.isWindows == 'true' }}
  64. run: mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  65. - name: Cache vcpkg
  66. if: ${{ env.isWindows == 'true' }}
  67. uses: pat-s/always-upload-cache@v3.0.11
  68. with:
  69. path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
  70. key: ${{ runner.os }}-vcpkg-binary-cache-${{ github.job }}
  71. restore-keys: |
  72. ${{ runner.os }}-vcpkg-binary-cache-
  73. - if: ${{ env.isUnix == 'true' }}
  74. run: chmod -R 777 *
  75. # Prepare environment for linking on Ubuntu
  76. - if: ${{ env.isUbuntu == 'true' }}
  77. name: Install OpenSSL on Ubuntu
  78. run: sudo apt install libssl-dev -y
  79. # Prepare environment for linking on Windows
  80. - if: ${{ env.isWindows == 'true' }}
  81. name: Setup Memory Environment on Windows
  82. run: >
  83. wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=9216 &
  84. net stop mongodb
  85. shell: cmd
  86. continue-on-error: true
  87. - if: ${{ env.isWindows == 'true' }}
  88. name: Install OpenSSL & cURL on Windows
  89. run: |
  90. echo "set(VCPKG_BUILD_TYPE release)" | Out-File -FilePath "$env:VCPKG_INSTALLATION_ROOT\triplets\x64-windows.cmake" -Encoding utf8 -Append
  91. vcpkg install openssl:x64-windows curl[core,ssl]:x64-windows
  92. 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
  93. 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
  94. 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
  95. echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  96. - name: Clean and download dependencies
  97. run: ./gradlew clean ${{ env.gradleArgs }}
  98. - name: Prepare deps test build
  99. run: ./gradlew :mirai-deps-test:updateProjectVersionForLocalDepsTest ${{ env.gradleArgs }} "-Porg.gradle.parallel=${{ matrix.parallelCompilation }}"
  100. - name: Build and Publish Local Artifacts
  101. run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Porg.gradle.parallel=${{ matrix.parallelCompilation }}"
  102. - name: Check Publication
  103. run: ./gradlew :mirai-deps-test:check ${{ env.gradleArgs }} "-Dmirai.deps.test.must.run=true" "-Porg.gradle.parallel=${{ matrix.parallelCompilation }}"