Skip to content

Commit 9ef8e55

Browse files
authored
chore: add semantic-release (#14)
* chore: add semantic-release Signed-off-by: JunHyung Lim <entrypointkr@gmail.com> * chore: use @sr/exec instead of gradle-semantic-release Signed-off-by: JunHyung Lim <entrypointkr@gmail.com> * chore: fix @sr/exec location Signed-off-by: JunHyung Lim <entrypointkr@gmail.com> * chore: use 'assemble' task instead of 'jar' Signed-off-by: JunHyung Lim <entrypointkr@gmail.com>
1 parent e936c46 commit 9ef8e55

7 files changed

Lines changed: 5272 additions & 2 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,7 @@ gradle-app.setting
108108
**/build/
109109

110110
# End of https://www.gitignore.io/api/git,java,gradle,intellij+iml
111+
112+
### NodeJS ###
113+
node_modules/
114+
package-lock.json

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import kr.entree.spigradle.build.VersionTask
2+
13
plugins {
24
`kotlin-dsl`
35
`kotlin-kapt`
@@ -8,7 +10,7 @@ plugins {
810
}
911

1012
group = "kr.entree"
11-
version = "1.3.1"
13+
version = VersionTask.readVersion()
1214
description = "An intelligent Gradle plugin for developing Minecraft resources."
1315

1416
gradlePlugin {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2020 Spigradle contributors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package kr.entree.spigradle.build
18+
19+
import org.gradle.api.DefaultTask
20+
import org.gradle.api.tasks.Input
21+
import org.gradle.api.tasks.TaskAction
22+
import org.gradle.api.tasks.options.Option
23+
import org.gradle.kotlin.dsl.property
24+
import java.io.File
25+
26+
/**
27+
* Created by JunHyung Lim on 2020-06-30
28+
*/
29+
@Suppress("UnstableApiUsage")
30+
open class VersionTask : DefaultTask() {
31+
companion object {
32+
val versionFile get() = File("version.txt")
33+
fun readVersion() = versionFile.readText()
34+
}
35+
36+
@Input
37+
@Option(option = "build-version", description = "Configure the version of Spigradle.")
38+
val version = project.objects.property<String>()
39+
40+
@TaskAction
41+
fun execute() {
42+
versionFile.writeText(version.get())
43+
}
44+
}

buildSrc/src/main/kotlin/spigradle-publish.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,6 @@ pluginBundle {
9292
description = formatDesc("NukkitX")
9393
}
9494
}
95-
}
95+
}
96+
97+
tasks.register<VersionTask>("setVersion")

package.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"devDependencies": {
3+
"@commitlint/cli": "^9.0.1",
4+
"@commitlint/config-conventional": "^9.0.1",
5+
"@semantic-release/changelog": "^5.0.1",
6+
"@semantic-release/git": "^9.0.0",
7+
"@semantic-release/github": "^7.0.7",
8+
"gradle-semantic-release-plugin": "^1.4.1",
9+
"husky": "^4.2.5",
10+
"semantic-release": "^17.1.1",
11+
"@semantic-release/exec": "^5.0.0"
12+
},
13+
"scripts": {
14+
"semantic-release": "semantic-release"
15+
},
16+
"husky": {
17+
"hooks": {
18+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
19+
}
20+
},
21+
"commitlint": {
22+
"extends": [
23+
"@commitlint/config-conventional"
24+
],
25+
"rules": {
26+
"body-max-line-length": [
27+
0
28+
]
29+
}
30+
},
31+
"release": {
32+
"repositoryUrl": "https://github.com/EntryPointKR/Spigradle",
33+
"branches": [
34+
"master"
35+
],
36+
"tagFormat": "v${version}",
37+
"plugins": [
38+
"@semantic-release/commit-analyzer",
39+
"@semantic-release/release-notes-generator",
40+
"@semantic-release/changelog",
41+
[
42+
"@semantic-release/exec",
43+
{
44+
"prepareCmd": "./gradlew setVersion --build-version ${nextRelease.version}",
45+
"publishCmd": "./gradlew assemble"
46+
}
47+
],
48+
[
49+
"@semantic-release/git",
50+
{
51+
"assets": [
52+
"version.txt",
53+
"CHANGELOG.md"
54+
]
55+
}
56+
],
57+
[
58+
"@semantic-release/github",
59+
{
60+
"assets": [
61+
"build/libs/*.jar"
62+
]
63+
}
64+
]
65+
]
66+
}
67+
}

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.3.1

0 commit comments

Comments
 (0)