Add files
This commit is contained in:
parent
74b365684f
commit
2d9667cb1a
|
@ -0,0 +1,10 @@
|
|||
pages:
|
||||
stage: deploy
|
||||
script:
|
||||
- mkdir public
|
||||
- cp -r * public
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
@ -0,0 +1,171 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.4.0"
|
||||
classpath "gradle.plugin.com.modrinth.minotaur:Minotaur:1.2.1"
|
||||
classpath "net.fabricmc:fabric-loom:0.10-SNAPSHOT"
|
||||
classpath "org.ajoberstar.grgit:grgit-gradle:3.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: com.matthewprenger.cursegradle.CurseGradlePlugin
|
||||
apply plugin: com.modrinth.minotaur.Minotaur
|
||||
apply plugin: net.fabricmc.loom.bootstrap.LoomGradlePluginBootstrap
|
||||
apply plugin: org.ajoberstar.grgit.gradle.GrgitPlugin
|
||||
|
||||
import com.modrinth.minotaur.request.VersionType
|
||||
|
||||
// Fetch changelog
|
||||
def changelogStr = "No changelog"
|
||||
ext.currentType = VersionType.ALPHA
|
||||
if (grgit != null) {
|
||||
grgit.open(dir: project.projectDir.toString())
|
||||
def tagList = grgit.tag.list()
|
||||
if (tagList.size() >= 1) {
|
||||
def currentTag = tagList.get(tagList.size() - 1)
|
||||
ext.currentType = VersionType.RELEASE
|
||||
version = currentTag.getName()
|
||||
switch (version[0]) {
|
||||
case 'v':
|
||||
version = version.substring(1)
|
||||
break
|
||||
case 'b':
|
||||
version = version.substring(1)
|
||||
ext.currentType = VersionType.BETA
|
||||
break
|
||||
case 'a':
|
||||
version = version.substring(1)
|
||||
ext.currentType = VersionType.ALPHA
|
||||
break
|
||||
}
|
||||
if (tagList.size() >= 2) {
|
||||
changelogStr = "Commits in " + ext.currentType.toString().toLowerCase() + " " + version + ":"
|
||||
for (def commit : grgit.log{range(tagList.get(tagList.size() - 2).fullName, currentTag.fullName)}) {
|
||||
changelogStr += "\n- " + commit.shortMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
version = "0.0.0+notag"
|
||||
}
|
||||
}
|
||||
else {
|
||||
version = "0.0.0+nogit"
|
||||
}
|
||||
if (!project.hasProperty("release")) {
|
||||
version += "-" + Instant.now().getEpochSecond()
|
||||
}
|
||||
println(changelogStr)
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_16
|
||||
targetCompatibility = JavaVersion.VERSION_16
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
group = project.maven_group
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// this fixes some edge cases with special characters not displaying correctly
|
||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
// If Javadoc is generated, this must be specified in that task too.
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
// Minecraft 1.17 (21w19a) upwards uses Java 16.
|
||||
it.options.release = 16
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.archivesBaseName}"}
|
||||
}
|
||||
}
|
||||
|
||||
task modrinth(type: com.modrinth.minotaur.TaskModrinthUpload, dependsOn: build) {
|
||||
token = System.getenv().MODRINTH_API_TOKEN
|
||||
projectId = project.modrinth_id
|
||||
versionNumber = version
|
||||
versionName = "[${project.minecraft_version}] ${version}"
|
||||
versionType = project.ext.currentType
|
||||
changelog = changelogStr
|
||||
uploadFile = remapJar
|
||||
addGameVersion("${project.minecraft_version}")
|
||||
addLoader('fabric')
|
||||
if (!project.modrinth_required_dependencies.isEmpty()) {
|
||||
project.modrinth_required_dependencies.split(", ").each {
|
||||
String dep -> addDependency(dep, com.modrinth.minotaur.request.Dependency.DependencyType.REQUIRED)
|
||||
}
|
||||
}
|
||||
if (!project.modrinth_optional_dependencies.isEmpty()) {
|
||||
project.modrinth_optional_dependencies.split(", ").each {
|
||||
String dep -> addDependency(dep, com.modrinth.minotaur.request.Dependency.DependencyType.OPTIONAL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
curseforge {
|
||||
if (System.getenv().CURSEFORGE_API_TOKEN) {
|
||||
apiKey = System.getenv().CURSEFORGE_API_TOKEN
|
||||
} else {
|
||||
println "No CURSEFORGE_API_TOKEN specified"
|
||||
}
|
||||
project {
|
||||
id = project.curseforge_id
|
||||
releaseType = 'release'
|
||||
addGameVersion "Fabric"
|
||||
addGameVersion "${project.minecraft_version}"
|
||||
changelog = changelogStr
|
||||
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
|
||||
mainArtifact.displayName = "[${project.minecraft_version}] ${version}"
|
||||
if (!project.curseforge_required_dependencies.isEmpty() || !project.curseforge_optional_dependencies.isEmpty()) {
|
||||
relations {
|
||||
if (!project.curseforge_required_dependencies.isEmpty()) {
|
||||
project.curseforge_required_dependencies.split(", ").each {
|
||||
String dep -> requiredDependency dep
|
||||
}
|
||||
}
|
||||
if (!project.curseforge_optional_dependencies.isEmpty()) {
|
||||
project.curseforge_optional_dependencies.split(", ").each {
|
||||
String dep -> optionalDependency dep
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
releaseType = project.ext.currentType.toString().toLowerCase()
|
||||
afterEvaluate {
|
||||
uploadTask.dependsOn(build)
|
||||
}
|
||||
}
|
||||
options {
|
||||
forgeGradleIntegration = false
|
||||
}
|
||||
}
|
||||
|
||||
ext.download = { String url, String name ->
|
||||
File file = new File("$buildDir/download/${name}.jar")
|
||||
file.parentFile.mkdirs()
|
||||
if (!file.exists()) {
|
||||
new URL(url).withInputStream { downloadStream ->
|
||||
file.withOutputStream { fileOut ->
|
||||
fileOut << downloadStream
|
||||
}
|
||||
}
|
||||
}
|
||||
return dependencies.implementation(files(file.absolutePath))
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
image: gradle:jdk17
|
||||
|
||||
variables:
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
|
||||
before_script:
|
||||
- export GRADLE_USER_HOME=`pwd`/.gradle
|
||||
|
||||
stages:
|
||||
- build
|
||||
- deploy
|
||||
|
||||
build_test:
|
||||
stage: build
|
||||
script:
|
||||
- gradle --build-cache build
|
||||
- cp build/libs/* ./
|
||||
- mv *-dev.jar dev.zip
|
||||
- mv *.jar latest.jar
|
||||
- mv dev.zip latest-dev.jar
|
||||
artifacts:
|
||||
paths:
|
||||
- build/libs
|
||||
- latest.jar
|
||||
- latest-dev.jar
|
||||
|
||||
deploy:
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG && '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^master/'
|
||||
stage: deploy
|
||||
script:
|
||||
- gradle --build-cache build curseforge modrinth -Prelease
|
Loading…
Reference in New Issue