actions publishing

This commit is contained in:
Him188 2022-07-02 16:10:20 +08:00
parent fd67ba9204
commit b82517e513
6 changed files with 345 additions and 55 deletions

View File

@ -1,6 +1,15 @@
name: Build name: Build
on: [ push, pull_request ]
on:
push:
paths-ignore:
- 'docs/**'
- '**/README*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '**/README*.md'
jobs: jobs:
build-mirai-jvm: build-mirai-jvm:
@ -13,7 +22,7 @@ jobs:
- windows-2022 - windows-2022
- macos-12 - macos-12
env: env:
gradleArgs: --scan "-Dmirai.target=jvm;android;!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8" gradleArgs: --scan "-Dmirai.target=jvm;android;!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx6000m -Dfile.encoding=UTF-8"
isMac: ${{ startsWith(matrix.os, 'macos') }} isMac: ${{ startsWith(matrix.os, 'macos') }}
isWindows: ${{ startsWith(matrix.os, 'windows') }} isWindows: ${{ startsWith(matrix.os, 'windows') }}
isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }} isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
@ -37,7 +46,7 @@ jobs:
- if: ${{ env.isWindows == 'true' }} - if: ${{ env.isWindows == 'true' }}
name: Setup Memory Environment on Windows name: Setup Memory Environment on Windows
run: > run: >
wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=9216 & wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=18432 &
net stop mongodb net stop mongodb
shell: cmd shell: cmd
continue-on-error: true continue-on-error: true
@ -233,6 +242,7 @@ jobs:
os: os:
- macos-12 - macos-12
env: env:
enableLocalPublishingTest: 'false'
gradleArgs: --scan gradleArgs: --scan
isMac: ${{ startsWith(matrix.os, 'macos') }} isMac: ${{ startsWith(matrix.os, 'macos') }}
isWindows: ${{ startsWith(matrix.os, 'windows') }} isWindows: ${{ startsWith(matrix.os, 'windows') }}
@ -277,11 +287,21 @@ jobs:
- name: Clean and download dependencies - name: Clean and download dependencies
run: ./gradlew clean ${{ env.gradleArgs }} run: ./gradlew clean ${{ env.gradleArgs }}
- run: >
./gradlew updateSnapshotVersion ${{ env.gradleArgs }}
env:
MIRAI_IS_SNAPSHOTS_PUBLISHING: true
SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
CURRENT_BRANCH_NAME: dev # always use -dev for now
- name: "Assemble" - name: "Assemble"
run: ./gradlew assemble ${{ env.gradleArgs }} run: ./gradlew assemble ${{ env.gradleArgs }}
- name: Publish Local Artifacts - name: Publish Local Artifacts
run: ./gradlew :mirai-deps-test:publishMiraiLocalArtifacts ${{ env.gradleArgs }} if: ${{ env.enableLocalPublishingTest == 'true' }}
run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
- name: "Check" - name: "Check"
run: ./gradlew check ${{ env.gradleArgs }} run: ./gradlew check ${{ env.gradleArgs }}
@ -290,6 +310,15 @@ jobs:
name: Ensure KDoc valid name: Ensure KDoc valid
run: ./gradlew dokkaHtmlMultiModule run: ./gradlew dokkaHtmlMultiModule
- name: Publish Snapshots
if: ${{ env.isMac == 'true' }}
run: ./gradlew publishAllPublicationsToMiraiRepoRepository ${{ env.gradleArgs }}
env:
MIRAI_IS_SNAPSHOTS_PUBLISHING: true
SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
CURRENT_BRANCH_NAME: dev
build-mirai-core-native: build-mirai-core-native:
name: "Native (${{ matrix.os }})" name: "Native (${{ matrix.os }})"
@ -317,6 +346,7 @@ jobs:
env: env:
# FIXME there must be two or more targets, or we'll get error on `@OptionalExpectation` # 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 # > Declaration annotated with '@OptionalExpectation' can only be used in common module sources
enableLocalPublishingTest: 'false'
gradleArgs: --scan "-Dmirai.target=jvm;${{ matrix.targetName }};!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dorg.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8" 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') }} isMac: ${{ startsWith(matrix.os, 'macos') }}
isWindows: ${{ startsWith(matrix.os, 'windows') }} isWindows: ${{ startsWith(matrix.os, 'windows') }}
@ -398,6 +428,15 @@ jobs:
- name: Clean and download dependencies - name: Clean and download dependencies
run: ./gradlew clean ${{ env.gradleArgs }} run: ./gradlew clean ${{ env.gradleArgs }}
- run: >
./gradlew updateSnapshotVersion ${{ env.gradleArgs }}
env:
MIRAI_IS_SNAPSHOTS_PUBLISHING: true
SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
CURRENT_BRANCH_NAME: dev # always use -dev for now
- name: "Test mirai-core-utils for ${{ matrix.os }}" - name: "Test mirai-core-utils for ${{ matrix.os }}"
run: ./gradlew :mirai-core-utils:${{ matrix.targetName }}Test ${{ env.gradleArgs }} run: ./gradlew :mirai-core-utils:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
@ -408,7 +447,41 @@ jobs:
run: ./gradlew :mirai-core:${{ matrix.targetName }}Test ${{ env.gradleArgs }} run: ./gradlew :mirai-core:${{ matrix.targetName }}Test ${{ env.gradleArgs }}
- name: Publish Local Artifacts - name: Publish Local Artifacts
run: ./gradlew :mirai-deps-test:publishMiraiLocalArtifacts ${{ env.gradleArgs }} if: ${{ env.enableLocalPublishingTest == 'true' }}
run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
- name: Check Publication - name: Check Publication
run: ./gradlew :mirai-deps-test:check ${{ env.gradleArgs }} run: ./gradlew :mirai-deps-test:check ${{ env.gradleArgs }}
# Publish native snapshots. Other artifacts are published in build-mirai-all
- name: Publish MingwX64 Snapshots
if: ${{ env.isWindows == 'true' }}
run: ./gradlew publishMingwX64PublicationToMiraiRepoRepository ${{ env.gradleArgs }}
env:
MIRAI_IS_SNAPSHOTS_PUBLISHING: true
SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
CURRENT_BRANCH_NAME: dev
- name: Publish LinuxX64 Snapshots
if: ${{ env.isUbuntu == 'true' }}
run: ./gradlew publishLinuxX64PublicationToMiraiRepoRepository ${{ env.gradleArgs }}
env:
MIRAI_IS_SNAPSHOTS_PUBLISHING: true
SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
CURRENT_BRANCH_NAME: dev
- name: Publish macOSX64 Snapshots
if: ${{ env.isMac == 'true' }}
run: ./gradlew publishMacosX64PublicationToMiraiRepoRepository ${{ env.gradleArgs }}
env:
MIRAI_IS_SNAPSHOTS_PUBLISHING: true
SNAPSHOTS_PUBLISHING_USER: ${{ secrets.SNAPSHOTS_PUBLISHING_USER }}
SNAPSHOTS_PUBLISHING_KEY: ${{ secrets.SNAPSHOTS_PUBLISHING_KEY }}
SNAPSHOTS_PUBLISHING_URL: ${{ secrets.SNAPSHOTS_PUBLISHING_URL }}
CURRENT_BRANCH_NAME: dev

View File

@ -4,25 +4,36 @@ on:
push: push:
tags: tags:
- 'v*' # 正式版本 - 'v*' # 正式版本
paths-ignore:
- 'docs/**'
- '**/README*.md'
jobs: jobs:
publish-mirai:
runs-on: macos-12 # 14G memory build-mirai-all:
name: "Everything (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-12
env:
enableLocalPublishingTest: 'false'
gradleArgs: --scan
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: steps:
- name: Checkout repository - uses: actions/checkout@v2
uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Setup JDK 11
uses: actions/setup-java@v2
with: with:
distribution: 'adopt' submodules: 'recursive'
java-version: '11'
- name: chmod -R 777 * - uses: actions/setup-java@v2
run: chmod -R 777 * with:
distribution: 'temurin'
java-version: '17'
- name: Keys setup - name: Keys setup
shell: bash shell: bash
@ -39,38 +50,235 @@ jobs:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }} SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
- name: Init gradle project - name: Setup Gradle
run: ./gradlew clean --scan uses: gradle/gradle-build-action@v2
- name: Cache konan
uses: pat-s/always-upload-cache@v3
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: Check keys - name: Check keys
run: ./gradlew ensureMavenCentralAvailable run: ./gradlew ensureMavenCentralAvailable ${{ env.gradleArgs }}
- name: Assemble - name: "Assemble"
run: ./gradlew assemble --scan run: ./gradlew assemble ${{ env.gradleArgs }}
- name: Check - name: Publish Local Artifacts
run: > if: ${{ env.enableLocalPublishingTest == 'true' }}
./gradlew check --scan --no-parallel run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
-Dmirai.network.show.all.components=true
-Dkotlinx.coroutines.debug=on
-Dmirai.network.show.packet.details=true
- name: Ensure all compilations completed before publish
run: >
./gradlew publishToMavenLocal --info --scan
- name: Publish all artifacts - name: "Check"
run: > run: ./gradlew check ${{ env.gradleArgs }}
./gradlew publish --no-parallel --info --scan
- if: ${{ env.isMac == 'true' }}
name: Ensure KDoc valid
run: ./gradlew dokkaHtmlMultiModule
- name: Publish
if: ${{ env.isMac == 'true' }}
run: ./gradlew publish ${{ env.gradleArgs }}
- name: Publish Gradle plugin - name: Publish Gradle plugin
run: > run: ./gradlew
./gradlew :mirai-console-gradle:publishPlugins ${{ env.gradleArgs }}
:mirai-console-gradle:publishPlugins --scan
-Dgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} -Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} -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 }} -Dgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }} -Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
- name: Gradle :ci-release-helper:closeRepository build-mirai-core-native:
name: "Native (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-2022
- ubuntu-20.04
- ubuntu-18.04
- macos-12
- macos-11
include:
- os: windows-2022
targetName: mingwX64
- os: ubuntu-20.04
targetName: linuxX64
- os: ubuntu-18.04
targetName: linuxX64
- os: macos-12
targetName: macosX64
- os: macos-11
targetName: macosX64
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
enableLocalPublishingTest: 'false'
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
mkdir build-secret-keys
echo "$SONATYPE_USER" > build-secret-keys/sonatype.key
echo "$SONATYPE_KEY" >> build-secret-keys/sonatype.key
env:
GPG_PRIVATE: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PUBLIC_: ${{ secrets.GPG_PUBLIC_KEY }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Cache konan
uses: pat-s/always-upload-cache@v3
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/always-upload-cache@v3
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: > run: >
./gradlew git clone https://github.com/openssl/openssl.git --recursive &&
:ci-release-helper:closeRepository --info --scan 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: Check keys
run: ./gradlew ensureMavenCentralAvailable ${{ 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: 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 Publication
run: ./gradlew :mirai-deps-test:check ${{ env.gradleArgs }}
# Publish native snapshots. Other artifacts are published in publish-mirai-all
- name: Publish MingwX64 Snapshots
if: ${{ env.isWindows == 'true' }}
run: ./gradlew publishMingwX64PublicationToMavenCentralRepository ${{ env.gradleArgs }}
- name: Publish LinuxX64 Snapshots
if: ${{ env.isUbuntu == 'true' }}
run: ./gradlew publishLinuxX64PublicationToMavenCentralRepository ${{ env.gradleArgs }}
- name: Publish macOSX64 Snapshots
if: ${{ env.isMac == 'true' }}
run: ./gradlew publishMacosX64PublicationToMavenCentralRepository ${{ env.gradleArgs }}
close-repository:
runs-on: macos-12
needs:
- publish-mirai-others
- publish-mirai-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

View File

@ -12,6 +12,9 @@ on:
jobs: jobs:
publish-mirai: publish-mirai:
runs-on: macos-12 # 14G memory runs-on: macos-12 # 14G memory
env:
enableLocalPublishingTest: 'false'
gradleArgs: --scan "-Dmirai.target=android,jvm;macosX64;!other" "-Pkotlin.compiler.execution.strategy=in-process" "-Dfile.encoding=UTF-8"
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: git submodule update --init --recursive - run: git submodule update --init --recursive
@ -38,8 +41,8 @@ jobs:
run: ./gradlew assemble --scan run: ./gradlew assemble --scan
- name: Publish Local Artifacts - name: Publish Local Artifacts
run: > if: ${{ env.enableLocalPublishingTest == 'true' }}
./gradlew :mirai-deps-test:publishMiraiLocalArtifacts --scan run: ./gradlew :mirai-deps-test:publishMiraiArtifactsToMavenLocal ${{ env.gradleArgs }} "-Dmirai.build.project.version=2.99.0-deps-test"
- name: Check - name: Check
run: > run: >

View File

@ -17,7 +17,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
// mirai-deps-test DEPENDS ON THE PATH. // mirai-deps-test DEPENDS ON THE PATH.
object Versions { object Versions {
val project = System.getenv("mirai.build.project.version") val project = System.getenv("mirai.build.project.version")?.takeIf { it.isNotBlank() }
?: System.getProperty("mirai.build.project.version")?.takeIf { it.isNotBlank() }
?: /*PROJECT_VERSION_START*/"2.13.0"/*PROJECT_VERSION_END*/ ?: /*PROJECT_VERSION_START*/"2.13.0"/*PROJECT_VERSION_END*/
val core = project val core = project

View File

@ -1 +1 @@
src/BuildConfig.kt test/BuildConfig.kt

View File

@ -57,7 +57,16 @@ tasks.register("generateBuildConfig") {
group = "mirai" group = "mirai"
doLast { doLast {
val text = """ generateBuildConfig()
}
tasks.getByName("testClasses").dependsOn(this)
tasks.getByName("compileTestKotlin").dependsOn(this)
}
generateBuildConfig() // somehow "generateBuildConfig" won't execute
fun generateBuildConfig() {
val text = """
package net.mamoe.mirai.deps.test package net.mamoe.mirai.deps.test
/** /**
@ -70,14 +79,10 @@ tasks.register("generateBuildConfig") {
const val kotlinVersion = "${Versions.kotlinCompiler}" const val kotlinVersion = "${Versions.kotlinCompiler}"
} }
""".trimIndent() + "\n" """.trimIndent() + "\n"
val file = project.projectDir.resolve("src/BuildConfig.kt") val file = project.projectDir.resolve("test/BuildConfig.kt")
if (!file.exists() || file.readText() != text) { if (!file.exists() || file.readText() != text) {
file.writeText(text) file.writeText(text)
}
} }
tasks.getByName("assemble").dependsOn(this) // if src is empty, compileKotlin will be skipped.
tasks.getByName("compileKotlin").dependsOn(this)
tasks.getByName("compileTestKotlin").dependsOn(this)
} }
tasks.register("publishMiraiLocalArtifacts", Exec::class) { tasks.register("publishMiraiLocalArtifacts", Exec::class) {