Skip to content

Commit c1cec82

Browse files
committed
配置部分CI;调整部分配置
1 parent f6ad0ee commit c1cec82

File tree

10 files changed

+368
-6
lines changed

10 files changed

+368
-6
lines changed

.github/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- 'for-release'
5+
- 'ignore-in-release'
6+
categories:
7+
- title: '⚠️ 不兼容变更'
8+
labels:
9+
- '不兼容'
10+
- title: '🔧 Bug Fix'
11+
labels:
12+
- 'bug'
13+
- title: '⚙️ 修补缺陷'
14+
labels:
15+
- '缺陷'
16+
- title: '🎉 新特性'
17+
labels:
18+
- '特性'
19+
- title: '✨ 优化'
20+
labels:
21+
- '优化'
22+
- title: '📦 依赖更新'
23+
labels:
24+
- 'dependencies'
25+
- title: '👀 其他变更'
26+
labels:
27+
- '*'
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Publish Snapshot
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
- dev/ver/**
8+
- dev/main
9+
paths:
10+
- 'buildSrc'
11+
- '**src/**/kotlin/**.kt'
12+
- '**src/**/java/**.java'
13+
- '**/src/**/kotlin/**.kt'
14+
- '**/src/**/java/**.java'
15+
- '**/build.gradle.kts'
16+
- 'build.gradle.kts'
17+
- 'settings.gradle.kts'
18+
- 'gradle.properties'
19+
20+
# 手动触发工作流
21+
workflow_dispatch:
22+
23+
env:
24+
IS_CI: true
25+
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
26+
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
27+
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
28+
OSSRH_USER: ${{ secrets.SONATYPE_USERNAME }}
29+
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
30+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
31+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
32+
SIMBOT_IS_SNAPSHOT: true
33+
SIMBOT_SNAPSHOT_ONLY: true
34+
GRADLE_OPTS: "-Dfile.encoding=UTF-8"
35+
36+
37+
jobs:
38+
publish-snapshot:
39+
name: Publish snapshot
40+
strategy:
41+
matrix:
42+
os: [ macos-latest, windows-latest, ubuntu-latest ]
43+
runs-on: ${{ matrix.os }}
44+
steps:
45+
# 检出仓库代码
46+
- name: Check out repo
47+
uses: actions/checkout@v4
48+
49+
# setup Java
50+
- name: Setup java
51+
uses: actions/setup-java@v4
52+
with:
53+
distribution: 'zulu'
54+
java-version: 21
55+
56+
# setup Gradle
57+
- name: Gradle test and publish snapshot
58+
uses: gradle/actions/setup-gradle@v3
59+
with:
60+
gradle-version: 8.5
61+
arguments: |
62+
test
63+
publishToSonatype
64+
closeAndReleaseStagingRepository
65+
--info
66+
--warning-mode all
67+
-Porg.gradle.jvmargs="-Xmx8g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
68+
-Porg.gradle.daemon=false
69+
70+
deploy-doc:
71+
name: Deploy-doc
72+
runs-on: ubuntu-latest
73+
needs: publish-snapshot
74+
steps:
75+
# 检出仓库代码
76+
- name: Check out repo
77+
uses: actions/checkout@v4
78+
with:
79+
persist-credentials: false
80+
fetch-depth: 0
81+
# setup Java
82+
- name: Setup java
83+
uses: actions/setup-java@v4
84+
with:
85+
distribution: 'zulu'
86+
java-version: 21
87+
88+
# setup Gradle
89+
- name: Gradle generate documentation
90+
uses: gradle/actions/setup-gradle@v3
91+
with:
92+
gradle-version: 8.5
93+
arguments: |
94+
-Porg.gradle.jvmargs="-Xmx4g -Xms4g -XX:MaxMetaspaceSize=2g -Dfile.encoding=UTF-8"
95+
-Porg.gradle.daemon=false
96+
-DisSnapshot=false
97+
--info
98+
--warning-mode all
99+
-x test
100+
--build-cache
101+
dokkaHtmlMultiModule
102+
103+
- name: Push to doc repository
104+
uses: peaceiris/actions-gh-pages@v3
105+
with:
106+
personal_token: ${{ secrets.PUSH_TOKEN }}
107+
external_repository: simple-robot-library/simbot3-api-docs
108+
publish_branch: kdoc-deploy/snapshots/component-onebot
109+
publish_dir: ./build/dokka/html
110+
# deploy to sub dir
111+
destination_dir: snapshots/components/onebot
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Qodana
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches:
7+
- dev/main
8+
- master
9+
- main
10+
11+
jobs:
12+
qodana:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: 'Qodana Scan'
19+
uses: JetBrains/[email protected]
20+
env:
21+
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

.github/workflows/test-branch.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Test Branch
2+
on:
3+
pull_request:
4+
branches:
5+
- 'dev/**'
6+
paths:
7+
- '**.java'
8+
- '**.kt'
9+
- '**.kts'
10+
- '*/src/*/kotlin/**'
11+
- '*/src/*/java/**'
12+
- '*/src/*/resource/**'
13+
- 'gradle/**'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
env:
20+
IS_CI: true
21+
GRADLE_OPTS: "-Dfile.encoding=UTF-8"
22+
23+
jobs:
24+
build-test:
25+
name: Build and test
26+
strategy:
27+
matrix:
28+
os: [ macos-latest, windows-latest, ubuntu-latest ]
29+
runs-on: ${{ matrix.os }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-java@v4
33+
with:
34+
distribution: 'zulu'
35+
java-version: 21
36+
# cache: 'gradle'
37+
38+
- name: Run All Tests
39+
uses: gradle/actions/setup-gradle@v3
40+
with:
41+
gradle-version: 8.5
42+
arguments: |
43+
assemble
44+
build
45+
allTests
46+
--info
47+
--warning-mode all
48+
# --build-cache
49+
# -Porg.gradle.daemon=false
50+
# -Porg.gradle.jvmargs="-Xmx4g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
51+
52+
- name: Upload test reports
53+
uses: actions/upload-artifact@v4
54+
if: ${{ always() }}
55+
with:
56+
name: test-reports-${{ matrix.os }}
57+
path: '**/build/reports/tests'
58+
retention-days: 7

buildSrc/src/main/kotlin/JsConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ inline fun Project.configWasmJsTest(block: () -> Unit = {}) {
9797
// see https://youtrack.jetbrains.com/issue/KT-63014/Running-tests-with-wasmJs-in-1.9.20-requires-Chrome-Canary#focus=Comments-27-8321383.0-0
9898
rootProject.the<NodeJsRootExtension>().apply {
9999
// nodeVersion = "21.0.0-v8-canary202309143a48826a08"
100-
nodeVersion = "21.0.0-v8-canary202309143a48826a08"
101-
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
100+
version = "21.0.0-v8-canary202309143a48826a08"
101+
downloadBaseUrl = "https://nodejs.org/download/v8-canary"
102102
}
103103

104104
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/*
2+
* Copyright (c) 2024. ForteScarlet.
3+
*
4+
* This file is part of simbot-component-onebot.
5+
*
6+
* simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms
7+
* of the GNU Lesser General Public License as published by the Free Software Foundation,
8+
* either version 3 of the License, or (at your option) any later version.
9+
*
10+
* simbot-component-onebot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
* See the GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot.
15+
* If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
19+
import love.forte.gradle.common.core.Gpg
20+
import love.forte.gradle.common.core.project.setup
21+
import love.forte.gradle.common.core.property.systemProp
22+
import love.forte.gradle.common.publication.configure.multiplatformConfigPublishing
23+
24+
plugins {
25+
signing
26+
`maven-publish`
27+
}
28+
29+
setup(P.ComponentOneBot)
30+
31+
val p = project
32+
multiplatformConfigPublishing {
33+
project = P.ComponentOneBot
34+
isSnapshot = project.version.toString().contains("SNAPSHOT", true)
35+
releasesRepository = ReleaseRepository
36+
snapshotRepository = SnapshotRepository
37+
gpg = Gpg.ofSystemPropOrNull()
38+
39+
// publishing {
40+
// publications.withType<MavenPublication> {
41+
// val dokkaJar = p.tasks.register("${name}DokkaJar", Jar::class) {
42+
// group = JavaBasePlugin.DOCUMENTATION_GROUP
43+
// description = "Assembles Kotlin docs with Dokka into a Javadoc jar"
44+
// archiveClassifier.set("javadoc")
45+
// from(tasks.named("dokkaHtml"))
46+
//
47+
// // Each archive name should be distinct, to avoid implicit dependency issues.
48+
// // We use the same format as the sources Jar tasks.
49+
// // https://youtrack.jetbrains.com/issue/KT-46466
50+
// archiveBaseName.set("${archiveBaseName.get()}-${name}")
51+
// }
52+
// artifact(dokkaJar)
53+
// }
54+
// }
55+
56+
val jarJavadoc by tasks.registering(Jar::class) {
57+
group = "documentation"
58+
archiveClassifier.set("javadoc")
59+
if (!(isSnapshot || isSnapshot() || isSimbotLocal())) {
60+
dependsOn(tasks.dokkaHtml)
61+
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
62+
// from(tasks.findByName("dokkaHtml"))
63+
}
64+
}
65+
66+
67+
// val dokkaJar = p.tasks.register("${publication.name}DokkaJar", Jar::class) {
68+
// group = JavaBasePlugin.DOCUMENTATION_GROUP
69+
// description = "Assembles Kotlin docs with Dokka into a Javadoc jar"
70+
// archiveClassifier.set("javadoc")
71+
// from(tasks.named("dokkaHtml"))
72+
//
73+
// // Each archive name should be distinct, to avoid implicit dependency issues.
74+
// // We use the same format as the sources Jar tasks.
75+
// // https://youtrack.jetbrains.com/issue/KT-46466
76+
// archiveBaseName.set("${archiveBaseName.get()}-${publication.name}")
77+
// }
78+
79+
artifact(jarJavadoc)
80+
81+
if (isSimbotLocal()) {
82+
logger.info("Is 'SIMBOT_LOCAL', mainHost set as null")
83+
mainHost = null
84+
}
85+
86+
publicationsFromMainHost += listOf("wasm", "wasm32", "wasm_js")
87+
mainHostSupportedTargets += listOf("wasm", "wasm32", "wasm_js")
88+
}
89+
90+
// TODO see https://github.com/gradle-nexus/publish-plugin/issues/208#issuecomment-1465029831
91+
val signingTasks: TaskCollection<Sign> = tasks.withType<Sign>()
92+
tasks.withType<PublishToMavenRepository>().configureEach {
93+
mustRunAfter(signingTasks)
94+
}
95+
// TODO see https://github.com/gradle/gradle/issues/26132
96+
// Resolves issues with .asc task output of the sign task of native targets.
97+
// See: https://github.com/gradle/gradle/issues/26132
98+
// And: https://youtrack.jetbrains.com/issue/KT-46466
99+
tasks.withType<Sign>().configureEach {
100+
val pubName = name.removePrefix("sign").removeSuffix("Publication")
101+
logger.info("config Sign with pubName {}", pubName)
102+
103+
// These tasks only exist for native targets, hence findByName() to avoid trying to find them for other targets
104+
105+
// Task ':linkDebugTest<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
106+
tasks.findByName("linkDebugTest$pubName")?.let {
107+
mustRunAfter(it)
108+
}
109+
// Task ':compileTestKotlin<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
110+
tasks.findByName("compileTestKotlin$pubName")?.let {
111+
mustRunAfter(it)
112+
}
113+
114+
logger.info("linkDebugTest{}", pubName)
115+
logger.info("compileTestKotlin{}", pubName)
116+
}
117+
118+
show()
119+
120+
fun show() {
121+
// // show project info
122+
logger.info(
123+
"""
124+
|=======================================================
125+
|= project.group: {}
126+
|= project.name: {}
127+
|= project.version: {}
128+
|= project.description: {}
129+
|= os.name: {}
130+
|=======================================================
131+
""".trimIndent(),
132+
group,
133+
name,
134+
version,
135+
description,
136+
systemProp("os.name")
137+
)
138+
}
139+
140+
141+
inline val Project.sourceSets: SourceSetContainer
142+
get() = extensions.getByName("sourceSets") as SourceSetContainer
143+
144+
internal val TaskContainer.dokkaHtml: TaskProvider<org.jetbrains.dokka.gradle.DokkaTask>
145+
get() = named<org.jetbrains.dokka.gradle.DokkaTask>("dokkaHtml")

simbot-component-onebot11-common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ plugins {
2727
}
2828

2929
configJavaCompileWithModule("simbot.component.onebot11v.common")
30-
// apply(plugin = "simbot-onebot-multiplatform-maven-publish")
30+
apply(plugin = "simbot-onebot-multiplatform-maven-publish")
3131

3232
kotlin {
3333
explicitApi()

simbot-component-onebot11-core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ plugins {
3131
}
3232

3333
configJavaCompileWithModule("simbot.component.onebot11v.core")
34-
// apply(plugin = "simbot-onebot-multiplatform-maven-publish")
34+
apply(plugin = "simbot-onebot-multiplatform-maven-publish")
3535

3636
kotlin {
3737
explicitApi()

0 commit comments

Comments
 (0)