forked from mamoe/mirai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dokka * test * Fix classpath * Fix deploy * Fix deploy * Fix deploy * GitHub workflows
- Loading branch information
Showing
13 changed files
with
289 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,17 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: mirai-doc Publish | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
mirai-core-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 1.8 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.8 | ||
push: | ||
tags: | ||
- 'v*' # 正式版本 | ||
|
||
- name: chmod -R 777 * | ||
run: chmod -R 777 * | ||
- name: Gradle build | ||
run: ./gradlew clean build # if test's failed, don't publish | ||
- name: Dokka | ||
run: ./gradlew :mirai-core-api:dokkaHtml | ||
- name: GitHub Pages Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
personal_token: ${{ secrets.MAMOE_TOKEN }} | ||
publish_dir: ./mirai-core-api/build/dokka | ||
external_repository: project-mirai/mirai-doc | ||
publish_branch: master | ||
user_name: 'mamoebot' | ||
user_email: '[email protected]' | ||
keep_files: true | ||
|
||
# This workflow contains a single job called "build" | ||
mirai-console-docs: | ||
jobs: | ||
mirai-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Checkout submodules | ||
run: git submodule update --init --recursive | ||
|
@@ -54,18 +23,17 @@ jobs: | |
|
||
- name: chmod -R 777 * | ||
run: chmod -R 777 * | ||
- name: Gradle build | ||
run: ./gradlew clean build # if test's failed, don't publish | ||
|
||
- name: Prepare environment | ||
run: ./gradlew :mirai-dokka:prepare | ||
|
||
- name: Dokka | ||
run: ./gradlew :mirai-console:dokkaHtml | ||
- name: GitHub Pages Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
personal_token: ${{ secrets.MAMOE_TOKEN }} | ||
publish_dir: ./mirai-console/build/dokka | ||
external_repository: project-mirai/mirai-doc | ||
publish_branch: master | ||
user_name: 'mamoebot' | ||
user_email: '[email protected]' | ||
keep_files: true | ||
run: ./gradlew dokkaHtmlMultiModule | ||
|
||
- name: Update version number | ||
run: ./gradlew :mirai-dokka:update-vers | ||
|
||
- name: Deploy | ||
run: ./gradlew :mirai-dokka:deployPages | ||
env: | ||
gh_token: ${{ secrets.MAMOE_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2019-2021 Mamoe Technologies and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. | ||
* | ||
* https://github.com/mamoe/mirai/blob/dev/LICENSE | ||
*/ | ||
|
||
plugins { | ||
kotlin("jvm") | ||
kotlin("plugin.serialization") | ||
id("java") | ||
`maven-publish` | ||
} | ||
|
||
dependencies { | ||
implementation(`kotlinx-serialization-core-jvm`) | ||
implementation(`kotlinx-serialization-json-jvm`) | ||
} | ||
|
||
fun Project.newExec(name: String, type: String, conf: JavaExec.() -> Unit) { | ||
tasks.create(name, JavaExec::class.java) { | ||
this.classpath = sourceSets["main"].runtimeClasspath | ||
this.mainClass.set("net.mamoe.mirai.dokka.${type}Kt") | ||
this.workingDir(rootProject.projectDir) | ||
this.environment("mirai_ver", rootProject.version.toString()) | ||
conf() | ||
} | ||
} | ||
|
||
newExec("prepare", "Prepare") { | ||
} | ||
|
||
newExec("deployPages", "DeployToGitHub") { | ||
} | ||
|
||
newExec("update-vers", "BuildVersionList") { | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// noinspection ES6ConvertVarToLetConst,JSUnresolvedVariable | ||
|
||
/* | ||
* Copyright 2019-2021 Mamoe Technologies and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. | ||
* | ||
* https://github.com/mamoe/mirai/blob/dev/LICENSE | ||
*/ | ||
|
||
|
||
|
||
(function () { | ||
fetch(window.pathToRoot + "../versions.json").then(function (it) { | ||
return it.json() | ||
}).then(function (rsp) { | ||
console.log(rsp); | ||
var dir = document.getElementById("searchBar").parentElement; | ||
var select = document.createElement("select"); | ||
dir.insertBefore(select, dir.firstElementChild); | ||
select.appendChild(document.createElement("option")).textContent = "other version"; | ||
var toLatest = select.appendChild(document.createElement("option")); | ||
toLatest.textContent = "latest"; | ||
toLatest.value = ""; | ||
for (var v of rsp) { | ||
var c = select.appendChild(document.createElement("option")); | ||
c.textContent = v; | ||
c.value = v; | ||
} | ||
select.addEventListener("change", function (event) { | ||
location.href = window.pathToRoot + "../" + c.value | ||
}) | ||
}).catch(function (error) { | ||
console.log(error); | ||
}) | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2019-2021 Mamoe Technologies and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. | ||
* | ||
* https://github.com/mamoe/mirai/blob/dev/LICENSE | ||
*/ | ||
|
||
package net.mamoe.mirai.dokka | ||
|
||
import kotlinx.serialization.builtins.ListSerializer | ||
import kotlinx.serialization.builtins.serializer | ||
|
||
|
||
fun main() { | ||
val currentVersion = System.getenv("mirai_ver") ?: error("version not found") | ||
|
||
val versions = pages.resolve("versions.json") | ||
|
||
json.decodeFromString(ListSerializer(String.serializer()), versions.readText()).toMutableList().let { list -> | ||
if (currentVersion in list) return@let | ||
list.add(currentVersion) | ||
versions.writeText(json.encodeToString(ListSerializer(String.serializer()), list)) | ||
} | ||
|
||
pages.resolve("snapshot").renameTo(pages.resolve(currentVersion)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019-2021 Mamoe Technologies and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. | ||
* | ||
* https://github.com/mamoe/mirai/blob/dev/LICENSE | ||
*/ | ||
|
||
package net.mamoe.mirai.dokka | ||
|
||
fun main() { | ||
val token = System.getenv("gh_token") ?: error("Token not found") | ||
val currentVersion = System.getenv("mirai_ver") ?: error("version not found") | ||
|
||
repoexec("git", "config", "--local", "http.https://github.com/.extraheader", "") | ||
runCatching { | ||
repoexec("git", "remote", "remove", "token") | ||
} | ||
repoexec( | ||
"git", "remote", "add", "token", | ||
"https://x-access-token:$token@github.com/project-mirai/mirai-doc.git" | ||
) | ||
|
||
repoexec("git", "config", "--local", "user.email", "[email protected]") | ||
repoexec("git", "config", "--local", "user.name", "mamoebot") | ||
repoexec("git", "add", "-A") | ||
repoexec( | ||
"git", "commit", "-m", currentVersion, | ||
nooutput = true, | ||
) | ||
repoexec("git", "push", "token", "HEAD:master") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2019-2021 Mamoe Technologies and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. | ||
* | ||
* https://github.com/mamoe/mirai/blob/dev/LICENSE | ||
*/ | ||
|
||
package net.mamoe.mirai.dokka | ||
|
||
fun main() { | ||
if (pages.resolve(".git").isDirectory) { | ||
return | ||
} | ||
exec("git", "clone", "https://github.com/project-mirai/mirai-doc.git", pages.absolutePath) | ||
} |
Oops, something went wrong.