| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- name: Release Publish
- on:
- push:
- tags:
- - 'v*' # 正式版本
- paths-ignore:
- - 'docs/**'
- - 'mirai-console/docs/**'
- - '**/*.md'
- jobs:
- initialize-sonatype-stage:
- name: "Initialize sonatype staging repository"
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- submodules: 'recursive'
- - uses: actions/setup-java@v2
- with:
- distribution: 'temurin'
- java-version: '17'
- - name: Setup Gradle
- uses: gradle/gradle-build-action@v2
- - run: chmod -R 777 *
- - name: Create publishing staging repository
- 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 }}"
- - name: Cache staging repository id
- uses: actions/upload-artifact@v3
- with:
- name: publish-stage-id
- path: ci-release-helper/repoid
- publish-others:
- name: "Others (${{ matrix.os }})"
- runs-on: ${{ matrix.os }}
- needs: [ initialize-sonatype-stage ]
- strategy:
- fail-fast: false
- matrix:
- os:
- - macos-12
- env:
- # All targets MUST be enabled. See #2270.
- gradleArgs: --scan "-Dmirai.target=other" "-Pkotlin.compiler.execution.strategy=in-process"
- isMac: ${{ startsWith(matrix.os, 'macos') }}
- isWindows: ${{ startsWith(matrix.os, 'windows') }}
- isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
- isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
- steps:
- - uses: actions/checkout@v2
- with:
- submodules: 'recursive'
- - uses: actions/setup-java@v2
- with:
- distribution: 'temurin'
- java-version: '17'
- - name: Keys setup
- shell: bash
- run: |
- mkdir build-gpg-sign
- echo "$GPG_PRIVATE" > build-gpg-sign/keys.gpg
- echo "$GPG_PUBLIC_" > build-gpg-sign/keys.gpg.pub
- env:
- GPG_PRIVATE: ${{ secrets.GPG_PRIVATE_KEY }}
- GPG_PUBLIC_: ${{ secrets.GPG_PUBLIC_KEY }}
- - name: Setup Gradle
- uses: gradle/gradle-build-action@v2
- - name: Cache konan
- uses: pat-s/[email protected]
- with:
- path: ~/.konan
- key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
- restore-keys: |
- ${{ runner.os }}-gradle-
- - if: ${{ env.isUnix == 'true' }}
- run: chmod -R 777 *
- # Prepare environment for linking for macOS
- - if: ${{ env.isMac == 'true' }}
- name: Install OpenSSL
- run: >
- git clone https://github.com/openssl/openssl.git --recursive &&
- cd openssl &&
- git checkout tags/openssl-3.0.3 &&
- ./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl &&
- make &&
- sudo make install
- - name: Clean and download dependencies
- run: ./gradlew clean ${{ env.gradleArgs }}
- - name: "Assemble"
- run: ./gradlew assemble ${{ env.gradleArgs }}
- - name: Publish Local Artifacts
- if: ${{ env.enableLocalPublishingTest == 'true' }}
- run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
- - name: "Check"
- run: ./gradlew check ${{ env.gradleArgs }}
- - if: ${{ env.isMac == 'true' }}
- name: Ensure KDoc valid
- run: ./gradlew dokkaHtmlMultiModule ${{ env.gradleArgs }}
- - name: Initialize Publishing Caching Repository
- run: ./gradlew runcihelper --args sync-maven-metadata ${{ env.gradleArgs }}
- - name: Publish
- if: ${{ env.isMac == 'true' }}
- run: ./gradlew publishAllPublicationsToMiraiStageRepoRepository ${{ env.gradleArgs }}
- - name: Restore staging repository id
- uses: actions/download-artifact@v3
- with:
- name: publish-stage-id
- path: ci-release-helper/repoid
- - name: Release RAM
- run: node ci-release-helper/scripts/kill-java.js
- - name: Publish to maven central
- run: ./gradlew runcihelper --args publish-to-maven-central --scan "-Pcihelper.cert.username=${{ secrets.SONATYPE_USER }}" "-Pcihelper.cert.password=${{ secrets.SONATYPE_KEY }}"
- - name: Publish Gradle plugin
- run: ./gradlew
- :mirai-console-gradle:publishPlugins ${{ env.gradleArgs }}
- -Dgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} -Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }}
- -Dgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }} -Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
- continue-on-error: true
- publish-core-native:
- name: "Native (${{ matrix.os }})"
- needs: [ publish-others ] # Allow MPP metadata to be uploaded first.
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- os:
- - windows-2022
- - ubuntu-20.04
- # - macos-12 # macOS artifacts published in 'publish-others'
- include:
- - os: windows-2022
- targetName: mingwX64
- # parallelCompilation: false
- - os: ubuntu-20.04
- targetName: linuxX64
- # parallelCompilation: false
- - os: macos-12
- targetName: macosX64
- # parallelCompilation: true # macOS machine has 14G
- env:
- # FIXME there must be two or more targets, or we'll get error on `@OptionalExpectation`
- # > Declaration annotated with '@OptionalExpectation' can only be used in common module sources
- gradleArgs: --scan "-Dmirai.target=jvm;${{ matrix.targetName }};~other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m" "-Dfile.encoding=UTF-8"
- isMac: ${{ startsWith(matrix.os, 'macos') }}
- isWindows: ${{ startsWith(matrix.os, 'windows') }}
- isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
- isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }}
- VCPKG_DEFAULT_BINARY_CACHE: ${{ startsWith(matrix.os, 'windows') && 'C:\vcpkg\binary_cache' || '/usr/local/share/vcpkg/binary_cache' }}
- steps:
- - uses: actions/checkout@v2
- with:
- submodules: 'recursive'
- - uses: actions/setup-java@v2
- with:
- distribution: 'adopt-openj9'
- java-version: '17'
- - name: Keys setup
- shell: bash
- run: |
- mkdir build-gpg-sign
- echo "$GPG_PRIVATE" > build-gpg-sign/keys.gpg
- echo "$GPG_PUBLIC_" > build-gpg-sign/keys.gpg.pub
- env:
- GPG_PRIVATE: ${{ secrets.GPG_PRIVATE_KEY }}
- GPG_PUBLIC_: ${{ secrets.GPG_PUBLIC_KEY }}
- - name: Setup Gradle
- uses: gradle/gradle-build-action@v2
- - name: Cache konan
- uses: pat-s/[email protected]
- with:
- path: ~/.konan
- key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
- restore-keys: |
- ${{ runner.os }}-gradle-
- - name: Prepare to cache vcpkg
- if: ${{ env.isWindows == 'true' }}
- run: mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
- - name: Cache vcpkg
- if: ${{ env.isWindows == 'true' }}
- uses: pat-s/[email protected]
- with:
- path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
- key: ${{ runner.os }}-vcpkg-binary-cache-${{ github.job }}
- restore-keys: |
- ${{ runner.os }}-vcpkg-binary-cache-
- - if: ${{ env.isUnix == 'true' }}
- run: chmod -R 777 *
- # Prepare environment for linking on macOS
- - if: ${{ env.isMac == 'true' }}
- name: Install OpenSSL on Mac OS
- run: >
- git clone https://github.com/openssl/openssl.git --recursive &&
- cd openssl &&
- git checkout tags/openssl-3.0.3 &&
- ./Configure --prefix=/opt/openssl --openssldir=/usr/local/ssl &&
- make &&
- sudo make install
- # Prepare environment for linking on Ubuntu
- - if: ${{ env.isUbuntu == 'true' }}
- name: Install OpenSSL on Ubuntu
- run: sudo apt install libssl-dev -y
- # Prepare environment for linking on Windows
- - if: ${{ env.isWindows == 'true' }}
- name: Setup Memory Environment on Windows
- run: >
- wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=9216 &
- net stop mongodb
- shell: cmd
- continue-on-error: true
- - if: ${{ env.isWindows == 'true' }}
- name: Install OpenSSL & cURL on Windows
- run: |
- echo "set(VCPKG_BUILD_TYPE release)" | Out-File -FilePath "$env:VCPKG_INSTALLATION_ROOT\triplets\x64-windows.cmake" -Encoding utf8 -Append
- vcpkg install openssl:x64-windows curl[core,ssl]:x64-windows
- 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
- 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
- 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
- echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- - name: Clean and download dependencies
- run: ./gradlew clean ${{ env.gradleArgs }}
- - name: "Test mirai-core-utils for ${{ matrix.os }}"
- run: ./gradlew :mirai-core-utils:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
- - name: "Test mirai-core-api for ${{ matrix.os }}"
- run: ./gradlew :mirai-core-api:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
- - name: "Test mirai-core for ${{ matrix.os }}"
- run: ./gradlew :mirai-core:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
- - name: Initialize Publishing Caching Repository
- run: ./gradlew runcihelper --args sync-maven-metadata ${{ env.gradleArgs }}
- - name: Release RAM
- run: node ci-release-helper/scripts/kill-java.js
- # # Parallel compilation will exhaust machine memory causing OOM
- # - name: Assemble
- # run: ./gradlew assemble ${{ env.gradleArgs }} "-Porg.gradle.parallel=${{ matrix.parallelCompilation }}"
- - name: Publish MingwX64
- if: ${{ env.isWindows == 'true' }}
- run: ./gradlew publishMingwX64PublicationToMiraiStageRepoRepository ${{ env.gradleArgs }}
- - name: Publish LinuxX64
- if: ${{ env.isUbuntu == 'true' }}
- run: ./gradlew publishLinuxX64PublicationToMiraiStageRepoRepository ${{ env.gradleArgs }}
- - name: Publish macOSX64
- if: ${{ env.isMac == 'true' }}
- run: ./gradlew publishMacosX64PublicationToMiraiStageRepoRepository ${{ env.gradleArgs }}
- - name: Restore staging repository id
- uses: actions/download-artifact@v3
- with:
- name: publish-stage-id
- path: ci-release-helper/repoid
- - name: Release RAM
- run: node ci-release-helper/scripts/kill-java.js
- - name: Publish to maven central
- run: ./gradlew runcihelper --args publish-to-maven-central --scan "-Pcihelper.cert.username=${{ secrets.SONATYPE_USER }}" "-Pcihelper.cert.password=${{ secrets.SONATYPE_KEY }}"
- #
- # close-repository:
- # runs-on: macos-12
- # needs:
- # - publish-others
- # - publish-core-native
- # steps:
- # - uses: actions/checkout@v2
- # with:
- # submodules: 'recursive'
- #
- # - uses: actions/setup-java@v2
- # with:
- # distribution: 'adopt-openj9'
- # java-version: '17'
- #
- # - name: Setup Gradle
- # uses: gradle/gradle-build-action@v2
- #
- # - name: Close repository
- # run: ./gradlew :ci-release-helper:closeRepository --scan
|