1.20.2 #26

Merged
quentinlegot merged 8 commits from dev into master 2024-01-06 22:50:29 +01:00
6 changed files with 96 additions and 8 deletions
Showing only changes of commit c3ee389d55 - Show all commits

View File

@ -3,7 +3,7 @@
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.
name:
name: Test and Deploy
on:
push:
branches: [ master, dev ]
@ -13,6 +13,8 @@ on:
env:
REPO_USERNAME: Altarik
REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }}
DISCORD_PUB_ID: ${{ secrets.DISCORD_PUB_ID }}
DISCORD_PUB_TOKEN: ${{ secrets.DISCORD_PUB_TOKEN }}
jobs:
build:
@ -37,9 +39,7 @@ jobs:
chmod +x ./gradlew
touch local.properties
- name: build
run: ./gradlew build --no-daemon --max-workers 1
#- name: test
# run: ./gradlew test --no-daemon
run: ./gradlew build # compile classes, testClasses, assemble in jar and javadocJar, and then test
deploy:
strategy:
matrix:
@ -64,7 +64,9 @@ jobs:
chmod +x ./gradlew
touch local.properties
- name: deploy
run: |
./gradlew publish
./gradlew reportToDiscord
run: ./gradlew publish
- name: create tag
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

@ -1,3 +1,4 @@
import fr.altarik.CreateTag
import fr.altarik.ReportDiscord
plugins {
@ -18,6 +19,11 @@ String repoUrl = "https://repo.altarik.fr/#/" + (project.version.endsWith('SNAPS
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 {
apply plugin: 'maven-publish'
apply plugin: 'fabric-loom'
@ -118,6 +124,11 @@ tasks.register("reportToDiscord", ReportDiscord) {
config.set(reportConfig)
}
tasks.register("createTag", CreateTag) {
config.set(releaseConfig)
}
/*jar {
dependsOn subprojects.jar
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

@ -8,4 +8,7 @@ loader_version=0.15.3
fabric_version=0.91.3+1.20.2
maven_group=fr.altarik.toolbox
maven_version=4.4.0
maven_version=4.3.2-SNAPSHOT
git_owner=quentinlegot
git_repo=Toolbox