Compare commits

..

9 Commits

Author SHA1 Message Date
bc3caaed7d Merge pull request '1.20.2' (#26) from dev into master
Some checks failed
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 4m37s
Test and Deploy / deploy (17, ubuntu-latest) (push) Failing after 4m20s
Reviewed-on: #26
2024-01-06 22:50:29 +01:00
4731cc5698 Update .gitea/workflows/ci.yml
Some checks failed
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 4m46s
Test and Deploy / deploy (17, ubuntu-latest) (push) Has been skipped
/ build (17, ubuntu-latest) (pull_request) Successful in 6m21s
/ deploy (17, ubuntu-latest) (pull_request) Has been cancelled
2024-01-06 22:28:57 +01:00
6276ba58d7 Update .gitea/workflows/ci.yml
Some checks failed
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 5m11s
Test and Deploy / deploy (17, ubuntu-latest) (push) Has been skipped
/ build (17, ubuntu-latest) (pull_request) Successful in 5m17s
/ deploy (17, ubuntu-latest) (pull_request) Has been cancelled
2024-01-06 22:13:05 +01:00
c3ee389d55 Merge remote-tracking branch 'origin/dev' into dev
Some checks failed
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 4m47s
Test and Deploy / deploy (17, ubuntu-latest) (push) Has been skipped
/ build (17, ubuntu-latest) (pull_request) Successful in 5m36s
/ deploy (17, ubuntu-latest) (pull_request) Has been cancelled
# Conflicts:
#	build.gradle
#	gradle.properties
2024-01-06 21:47:34 +01:00
0c67018eda Dump to 4.4.0 2024-01-06 21:44:36 +01:00
59161400e8 Update to 1.20.2 2024-01-06 21:42:25 +01:00
c098820076 Remove unnecessary semicolon
All checks were successful
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 4m15s
Test and Deploy / deploy (17, ubuntu-latest) (push) Has been skipped
2023-08-29 22:50:56 +02:00
40768b2ec1 Added Command and AbstractCommand
All checks were successful
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 4m12s
Test and Deploy / deploy (17, ubuntu-latest) (push) Has been skipped
2023-08-29 22:50:21 +02:00
10edfe5ef6 Improve CI: now create a tag when publishing a new release
All checks were successful
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 4m21s
Test and Deploy / deploy (17, ubuntu-latest) (push) Has been skipped
2023-08-29 22:44:06 +02:00
12 changed files with 123 additions and 43 deletions

View File

@ -3,7 +3,7 @@
# certain platforms or Java versions, and provides a first line of defence # certain platforms or Java versions, and provides a first line of defence
# against bad commits. # against bad commits.
name: name: Test and Deploy
on: on:
push: push:
branches: [ master, dev ] branches: [ master, dev ]
@ -39,16 +39,14 @@ jobs:
chmod +x ./gradlew chmod +x ./gradlew
touch local.properties touch local.properties
- name: build - name: build
run: ./gradlew build --no-daemon --max-workers 1 run: ./gradlew build # compile classes, testClasses, assemble in jar and javadocJar, and then test
#- name: test
# run: ./gradlew test --no-daemon
deploy: deploy:
strategy: strategy:
matrix: matrix:
java: [ '17' ] java: [ '17' ]
os: [ ubuntu-latest ] os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
if: gitea.ref == 'refs/heads/master' if: ${{ gitea.ref == 'refs/heads/master' && gitea.event_name == 'push' }}
needs: build needs: build
steps: steps:
- name: checkout repository - name: checkout repository
@ -66,7 +64,9 @@ jobs:
chmod +x ./gradlew chmod +x ./gradlew
touch local.properties touch local.properties
- name: deploy - name: deploy
run: | run: ./gradlew publish
./gradlew publish - name: create tag
./gradlew reportToDiscord run: ./gradlew createTag
- name: Report to Discord
run: ./gradlew reportToDiscord

View File

@ -0,0 +1,15 @@
package fr.altarik.toolbox.core.command;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.server.command.ServerCommandSource;
public abstract class AbstractCommand implements Command {
protected final ServerCommandSource source;
protected final CommandContext<ServerCommandSource> context;
protected AbstractCommand(CommandContext<ServerCommandSource> c) {
this.context = c;
this.source = c.getSource();
}
}

View File

@ -0,0 +1,9 @@
package fr.altarik.toolbox.core.command;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
public interface Command {
int run() throws CommandSyntaxException;
}

View File

@ -21,9 +21,9 @@
}, },
"mixins": [], "mixins": [],
"depends": { "depends": {
"fabricloader": "^0.14.12", "fabricloader": "^${loaderVersion}",
"fabric-api": "*", "fabric-api": "*",
"minecraft": "1.19.3", "minecraft": "${minecraftVersion}",
"java": ">=17" "java": ">=17"
} }
} }

View File

@ -21,9 +21,9 @@
}, },
"mixins": [], "mixins": [],
"depends": { "depends": {
"fabricloader": "^0.14.12", "fabricloader": "^${loaderVersion}",
"fabric-api": "*", "fabric-api": "*",
"minecraft": "1.19.3", "minecraft": "${minecraftVersion}",
"java": ">=17", "java": ">=17",
"toolbox-core": "${version}" "toolbox-core": "${version}"
} }

View File

@ -25,9 +25,9 @@
"Pagination.mixins.json" "Pagination.mixins.json"
], ],
"depends": { "depends": {
"fabricloader": "^0.14.12", "fabricloader": "^${loaderVersion}",
"fabric-api": "*", "fabric-api": "*",
"minecraft": "1.19.3", "minecraft": "${minecraftVersion}",
"java": ">=17" "java": ">=17"
} }
} }

View File

@ -25,9 +25,9 @@
"Task.mixins.json" "Task.mixins.json"
], ],
"depends": { "depends": {
"fabricloader": "^0.14.12", "fabricloader": "^${loaderVersion}",
"fabric-api": "*", "fabric-api": "*",
"minecraft": "1.19.3", "minecraft": "${minecraftVersion}",
"java": ">=17" "java": ">=17"
} }
} }

View File

@ -1,7 +1,8 @@
import fr.altarik.CreateTag
import fr.altarik.ReportDiscord import fr.altarik.ReportDiscord
plugins { plugins {
id 'fabric-loom' version '1.2-SNAPSHOT' apply false id 'fabric-loom' version '1.4-SNAPSHOT' apply false
} }
Properties local = new Properties() Properties local = new Properties()
@ -16,7 +17,12 @@ String webhookId = getEnv("DISCORD_PUB_ID", local.getProperty("discord_pub_id"))
String webhookToken = getEnv("DISCORD_PUB_TOKEN", local.getProperty("discord_pub_token")) String webhookToken = getEnv("DISCORD_PUB_TOKEN", local.getProperty("discord_pub_token"))
String repoUrl = "https://repo.altarik.fr/#/" + (project.version.endsWith('SNAPSHOT') ? 'snapshots/' : 'releases/') + project.group.replace(".", "/") + "/" + project.rootProject.name + "/" + project.version String repoUrl = "https://repo.altarik.fr/#/" + (project.version.endsWith('SNAPSHOT') ? 'snapshots/' : 'releases/') + project.group.replace(".", "/") + "/" + project.rootProject.name + "/" + project.version
var reportConfig = new ReportDiscord.ReportData("https://discord.com/api/", webhookId, webhookToken, project.rootProject.name, "Update " + project.version + " has been published", repoUrl); var reportConfig = new ReportDiscord.ReportData("https://discord.com/api/", webhookId, webhookToken, project.rootProject.name, "Update " + project.version + " has been published", repoUrl)
String giteaToken = getEnv("GITEA_TOKEN", local.getProperty("gitea_token"))
var releaseConfig = new CreateTag.CreateReleaseData("https://git.altarik.fr", project.git_owner, project.git_repo, "v" + project.version as String, giteaToken)
allprojects { allprojects {
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
@ -25,9 +31,6 @@ allprojects {
group = project.maven_group group = project.maven_group
version = project.maven_version version = project.maven_version
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories { repositories {
maven { maven {
name 'altarik-snapshots' name 'altarik-snapshots'
@ -64,26 +67,17 @@ allprojects {
processResources { processResources {
inputs.property "version", project.version inputs.property "version", project.version
inputs.property "minecraftVersion", project.minecraft_version
inputs.property "loaderVersion", project.loader_version
filesMatching("fabric.mod.json") { filesMatching("fabric.mod.json") {
expand "version": project.version expand inputs.properties
} }
} }
tasks.withType(JavaCompile).configureEach { 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" it.options.encoding = "UTF-8"
it.options.release = 17
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 17
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
} }
dependencies { dependencies {
@ -98,6 +92,9 @@ allprojects {
java { java {
withSourcesJar() withSourcesJar()
withJavadocJar() withJavadocJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
} }
test { test {
@ -107,8 +104,11 @@ allprojects {
} }
dependencies { dependencies {
implementation project(path: ":Core", configuration: "namedElements")
implementation project(path: ":Database", configuration: "namedElements")
implementation project(path: ":Pagination", configuration: "namedElements")
implementation project(path: ":Tasks", configuration: "namedElements")
include subprojects.collect { project -> project } include subprojects.collect { project -> project }
implementation subprojects.collect { project -> project }
} }
static def getEnv(String envName, String defaultValue) { static def getEnv(String envName, String defaultValue) {
@ -124,6 +124,11 @@ tasks.register("reportToDiscord", ReportDiscord) {
config.set(reportConfig) config.set(reportConfig)
} }
tasks.register("createTag", CreateTag) {
config.set(releaseConfig)
}
/*jar { /*jar {
dependsOn subprojects.jar dependsOn subprojects.jar
subprojects.each { project -> subprojects.each { project ->

View File

@ -0,0 +1,48 @@
package fr.altarik;
import okhttp3.*;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
import java.io.IOException;
public abstract class CreateTag extends DefaultTask {
public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
private final OkHttpClient client = new OkHttpClient();
@Input
public abstract Property<CreateReleaseData> getConfig();
@TaskAction
public void create() throws IOException {
CreateReleaseData data = getConfig().get();
String postUrl = data.baseUrl() + "/api/v1/repos/" + data.owner() + "/" + data.repoName() + "/tags";
RequestBody body = RequestBody.create("""
{
"tag_name": \"""" + data.tagName() + "\"" + """
}
""", JSON);
Request request = new Request.Builder()
.url(postUrl)
.post(body)
.header("Authorization", "token " + data.giteaToken())
.build();
try(Response response = client.newCall(request).execute()) {
if(!response.isSuccessful()) {
if(response.code() != 409)
throw new GradleException("Cannot create tag, server answer with code " + response.code() + " and message : " + response.message());
}
}
}
public record CreateReleaseData(String baseUrl, String owner, String repoName, String tagName, String giteaToken) {
}
}

View File

@ -1,11 +1,14 @@
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx1G
fabric.loom.multiProjectOptimisation=true fabric.loom.multiProjectOptimisation=true
junit_version=5.9.0 junit_version=5.9.0
minecraft_version=1.19.3 minecraft_version=1.20.2
yarn_mappings=1.19.3+build.5 yarn_mappings=1.20.2+build.4
loader_version=0.14.14 loader_version=0.15.3
fabric_version=0.75.1+1.19.3 fabric_version=0.91.3+1.20.2
maven_group=fr.altarik.toolbox maven_group=fr.altarik.toolbox
maven_version=4.3.2-SNAPSHOT maven_version=4.3.2-SNAPSHOT
git_owner=quentinlegot
git_repo=Toolbox

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -17,9 +17,9 @@
"icon": "assets/toolbox/icon.png", "icon": "assets/toolbox/icon.png",
"environment": "*", "environment": "*",
"depends": { "depends": {
"fabricloader": "^0.14.12", "fabricloader": "^${loaderVersion}",
"fabric-api": "*", "fabric-api": "*",
"minecraft": "1.19.3", "minecraft": "${minecraftVersion}",
"java": ">=17", "java": ">=17",
"toolbox-core": "${version}", "toolbox-core": "${version}",
"toolbox-database": "${version}", "toolbox-database": "${version}",