1.0-SNAPSHOT #1
38
.gitea/workflows/deploy.yml
Normal file
38
.gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
name: deploy
|
||||||
|
description: Deploy artifact to maven repo
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
env:
|
||||||
|
REPO_USERNAME: Altarik
|
||||||
|
REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }}
|
||||||
|
DISCORD_PUB_ID: ${{ secrets.DISCORD_PUB_ID }}
|
||||||
|
DISCORD_PUB_TOKEN: ${{ secrets.DISCORD_PUB_TOKEN }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# if: gitea.ref == 'refs/heads/main'
|
||||||
|
steps:
|
||||||
|
- name: checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: validate gradle wrapper
|
||||||
|
uses: https://github.com/gradle/wrapper-validation-action@v1
|
||||||
|
- name: setup jdk
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: 17
|
||||||
|
distribution: 'oracle'
|
||||||
|
- name: make gradle wrapper executable
|
||||||
|
if: ${{ runner.os != 'Windows' }}
|
||||||
|
run: |
|
||||||
|
chmod +x ./gradlew
|
||||||
|
touch local.properties
|
||||||
|
- name: deploy
|
||||||
|
run: ./gradlew publish
|
||||||
|
- name: create tag
|
||||||
|
run: ./gradlew createTag
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
- name: report to discord
|
||||||
|
run: ./gradlew reportToDiscord
|
25
.github/workflows/AAAAAHHHHHHHHHHH!!!!!!!!.yml
vendored
25
.github/workflows/AAAAAHHHHHHHHHHH!!!!!!!!.yml
vendored
@ -1,25 +0,0 @@
|
|||||||
name: AAAAHHHHHHHHHHHH!!!!!!!!!!
|
|
||||||
|
|
||||||
on: [push, pull_request, workflow_dispatch]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '17'
|
|
||||||
|
|
||||||
- uses: gradle/wrapper-validation-action@v1
|
|
||||||
|
|
||||||
- uses: gradle/gradle-build-action@v2.4.2
|
|
||||||
with:
|
|
||||||
arguments: clean build
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: AHHHHHHHHHHH!!!!!!!!!!
|
|
||||||
path: build/libs
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,7 +1,7 @@
|
|||||||
# Compiled nonsense that does not belong in *source* control
|
# Compiled nonsense that does not belong in *source* control
|
||||||
/build
|
/build
|
||||||
/bin
|
/bin
|
||||||
/.gradle
|
.gradle
|
||||||
/minecraft
|
/minecraft
|
||||||
/out
|
/out
|
||||||
/run
|
/run
|
||||||
@ -32,5 +32,4 @@ local.properties
|
|||||||
*.png~
|
*.png~
|
||||||
*-autosave.kra
|
*-autosave.kra
|
||||||
*.kra~
|
*.kra~
|
||||||
/gradle/
|
|
||||||
/src/generated/
|
/src/generated/
|
||||||
|
68
build.gradle
68
build.gradle
@ -1,11 +1,33 @@
|
|||||||
|
import fr.altarik.ReportDiscord
|
||||||
|
import fr.altarik.CreateTag
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.5-SNAPSHOT'
|
id 'fabric-loom' version '1.5-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Properties local = new Properties()
|
||||||
|
try {
|
||||||
|
local.load(new FileInputStream(rootProject.file("local.properties")))
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
|
||||||
version = project.mod_version
|
version = project.mod_version
|
||||||
group = project.maven_group
|
group = project.maven_group
|
||||||
|
|
||||||
|
|
||||||
|
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, 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)
|
||||||
|
|
||||||
|
|
||||||
base {
|
base {
|
||||||
archivesName = project.archives_base_name
|
archivesName = project.archives_base_name
|
||||||
}
|
}
|
||||||
@ -36,6 +58,16 @@ loom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
maven {
|
||||||
|
name 'altarik-snapshots'
|
||||||
|
url 'https://repo.altarik.fr/snapshots/'
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name 'altarik-releases'
|
||||||
|
url 'https://repo.altarik.fr/releases/'
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
|
|
||||||
// Add repositories to retrieve artifacts from in here.
|
// Add repositories to retrieve artifacts from in here.
|
||||||
// You should only use this when depending on other mods because
|
// You should only use this when depending on other mods because
|
||||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
@ -58,13 +90,11 @@ processResources {
|
|||||||
inputs.property "version", project.version
|
inputs.property "version", project.version
|
||||||
inputs.property "minecraft_version", project.minecraft_version
|
inputs.property "minecraft_version", project.minecraft_version
|
||||||
inputs.property "loader_version", project.loader_version
|
inputs.property "loader_version", project.loader_version
|
||||||
|
inputs.property "mod_id", project.mod_id
|
||||||
filteringCharset "UTF-8"
|
filteringCharset "UTF-8"
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
filesMatching("fabric.mod.json") {
|
||||||
expand "version": project.version,
|
expand inputs.properties
|
||||||
"mod_id": mod_id,
|
|
||||||
"minecraft_version": project.minecraft_version,
|
|
||||||
"loader_version": project.loader_version
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +111,9 @@ tasks.withType(JavaCompile).configureEach {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
||||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||||
if (JavaVersion.current() < javaVersion) {
|
if (JavaVersion.current() < javaVersion) {
|
||||||
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
||||||
@ -111,5 +144,32 @@ publishing {
|
|||||||
// Notice: This block does NOT have the same function as the block in the top level.
|
// Notice: This block does NOT have the same function as the block in the top level.
|
||||||
// The repositories here will be used for publishing your artifact, not for
|
// The repositories here will be used for publishing your artifact, not for
|
||||||
// retrieving dependencies.
|
// retrieving dependencies.
|
||||||
|
maven {
|
||||||
|
name 'altarik'
|
||||||
|
url 'https://repo.altarik.fr/'.concat(project.version.endsWith('SNAPSHOT') ? 'snapshots/' : 'releases/')
|
||||||
|
credentials {
|
||||||
|
username = getEnv("REPO_USERNAME", local.getProperty("repo_username"))
|
||||||
|
password = getEnv("REPO_PASSWORD", local.getProperty("repo_password"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.register("reportToDiscord", ReportDiscord) {
|
||||||
|
config.set(reportConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("createTag", CreateTag) {
|
||||||
|
config.set(releaseConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
static def getEnv(String envName, String defaultValue) {
|
||||||
|
String r = System.getenv(envName)
|
||||||
|
if(r != null) {
|
||||||
|
return r
|
||||||
|
} else {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
2
buildSrc/.gitignore
vendored
Normal file
2
buildSrc/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.gradle
|
||||||
|
build
|
11
buildSrc/build.gradle
Normal file
11
buildSrc/build.gradle
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "com.squareup.okhttp3:okhttp:${project.okhttp_version}"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
1
buildSrc/gradle.properties
Normal file
1
buildSrc/gradle.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
okhttp_version=4.12.0
|
7
buildSrc/settings.gradle
Normal file
7
buildSrc/settings.gradle
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootProject.name = "buildSrc"
|
47
buildSrc/src/main/java/fr/altarik/CreateTag.java
Normal file
47
buildSrc/src/main/java/fr/altarik/CreateTag.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
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) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
56
buildSrc/src/main/java/fr/altarik/ReportDiscord.java
Normal file
56
buildSrc/src/main/java/fr/altarik/ReportDiscord.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
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 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 of\s""" + data.projectName() + """
|
||||||
|
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");
|
||||||
|
if(!response.isSuccessful()) {
|
||||||
|
throw new GradleException("Discord returned a " + response.code() + " code: " + response.message());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ReportData(String baseUrl, String webhookId, String webhookToken, String projectName, String message, String url) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -15,4 +15,7 @@ mod_id = reframed
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# check this on https://modmuss50.me/fabric.html
|
# check this on https://modmuss50.me/fabric.html
|
||||||
fabric_version=0.95.4+1.20.4
|
fabric_version=0.95.4+1.20.4
|
||||||
|
|
||||||
|
git_owner=Altarik
|
||||||
|
git_repo=ReFramed
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
@ -26,8 +26,8 @@
|
|||||||
"reframed.mixins.json"
|
"reframed.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"minecraft": ">=${minecraft_version}",
|
"minecraft": "${minecraft_version}",
|
||||||
"fabricloader": "${loader_version}",
|
"fabricloader": "^${loader_version}",
|
||||||
"fabric-api": "*"
|
"fabric-api": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user