Compare commits
No commits in common. "7adf20f1ed32177e8a77995783f41367bd993006" and "75217ffe30e4f77a549620142401fe59704ffeca" have entirely different histories.
7adf20f1ed
...
75217ffe30
@ -64,7 +64,5 @@ jobs:
|
|||||||
chmod +x ./gradlew
|
chmod +x ./gradlew
|
||||||
touch local.properties
|
touch local.properties
|
||||||
- name: deploy
|
- name: deploy
|
||||||
run: |
|
run: ./gradlew publish
|
||||||
./gradlew publish
|
|
||||||
./gradlew reportToDiscord
|
|
||||||
|
|
||||||
|
14
build.gradle
14
build.gradle
@ -1,5 +1,3 @@
|
|||||||
import fr.altarik.ReportDiscord
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.2-SNAPSHOT' apply false
|
id 'fabric-loom' version '1.2-SNAPSHOT' apply false
|
||||||
}
|
}
|
||||||
@ -9,14 +7,6 @@ try {
|
|||||||
local.load(new FileInputStream(rootProject.file("local.properties")))
|
local.load(new FileInputStream(rootProject.file("local.properties")))
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
|
|
||||||
group = project.maven_group
|
|
||||||
version = project.maven_version
|
|
||||||
|
|
||||||
String webhookId = getEnv("DISCORD_PUB_ID", local.getProperty("discord_pub_id"))
|
|
||||||
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
|
|
||||||
|
|
||||||
var reportConfig = new ReportDiscord.ReportData("https://discord.com/api/", webhookId, webhookToken, "Update " + project.version + " has been published", repoUrl);
|
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
@ -120,10 +110,6 @@ static def getEnv(String envName, String defaultValue) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register("reportToDiscord", ReportDiscord) {
|
|
||||||
config.set(reportConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
/*jar {
|
/*jar {
|
||||||
dependsOn subprojects.jar
|
dependsOn subprojects.jar
|
||||||
subprojects.each { project ->
|
subprojects.each { project ->
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'java'
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "com.squareup.okhttp3:okhttp:${project.okhttp_version}"
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
okhttp_version=4.10.0
|
|
@ -1,7 +0,0 @@
|
|||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rootProject.name = "buildSrc"
|
|
@ -1,51 +0,0 @@
|
|||||||
package fr.altarik;
|
|
||||||
|
|
||||||
import okhttp3.*;
|
|
||||||
import org.gradle.api.DefaultTask;
|
|
||||||
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 ReportDiscord extends DefaultTask {
|
|
||||||
|
|
||||||
public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
|
|
||||||
|
|
||||||
@Input
|
|
||||||
public abstract Property<ReportData> getConfig();
|
|
||||||
|
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
public void report() throws IOException {
|
|
||||||
ReportData data = getConfig().get();
|
|
||||||
String message = data.message();
|
|
||||||
RequestBody body = RequestBody.create("""
|
|
||||||
{
|
|
||||||
"embeds": [
|
|
||||||
{
|
|
||||||
"title": "A new update for Toolbox is available",
|
|
||||||
"description":\s""" + "\"" + message + "\"" + """
|
|
||||||
,
|
|
||||||
"url":\s""" + "\"" + data.url() + "\"" + """
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
""", JSON);
|
|
||||||
|
|
||||||
String url = data.baseUrl() + "/webhooks/" + data.webhookId + "/" + data.webhookToken;
|
|
||||||
Request request = new Request.Builder()
|
|
||||||
.url(url)
|
|
||||||
.post(body)
|
|
||||||
.build();
|
|
||||||
try(Response response = client.newCall(request).execute()) {
|
|
||||||
getLogger().info("report sent");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public record ReportData(String baseUrl, String webhookId, String webhookToken, String message, String url) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -8,4 +8,4 @@ loader_version=0.14.14
|
|||||||
fabric_version=0.75.1+1.19.3
|
fabric_version=0.75.1+1.19.3
|
||||||
|
|
||||||
maven_group=fr.altarik.toolbox
|
maven_group=fr.altarik.toolbox
|
||||||
maven_version=4.3.2-SNAPSHOT
|
maven_version=4.3.1-SNAPSHOT
|
||||||
|
Loading…
Reference in New Issue
Block a user