Skip to content

Commit

Permalink
添加模组自动发布, clean
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Feb 4, 2024
1 parent 46a9f64 commit 0366aa2
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 15 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Release

on:
workflow_dispatch:
release:
types:
- published

permissions:
contents: write

jobs:
Build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 20
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 20
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'build.gradle') }}
- uses: gradle/wrapper-validation-action@v1
- run: |
chmod +x gradlew
./gradlew mergeJars publishMods --stacktrace -Porg.gradle.parallel.threads=4
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Changelog
- Add mod release workflow
- clean code

## Changelog
- 添加 mod release workflow
- 代码清理
43 changes: 39 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "io.github.pacifistmc.forgix" version "1.2.6"
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}

architectury {
Expand All @@ -23,7 +24,7 @@ allprojects {
apply plugin: "maven-publish"

archivesBaseName = rootProject.archives_base_name
version = "${rootProject.mod_version}-${rootProject.minecraft_version}"
version = "${rootProject.mod_version}+mc${rootProject.minecraft_version}"
group = rootProject.maven_group

repositories {
Expand All @@ -46,21 +47,55 @@ allprojects {

forgix {
group = rootProject.maven_group
mergedJarName = "${rootProject.archives_base_name}-${project.version}.jar"
mergedJarName = "${rootProject.archives_base_name}-${rootProject.version}.jar"
outputDir = "build/libs/forgix"

forge {
projectName = "forge"
jarLocation = "build/libs/${rootProject.archives_base_name}-forge-${ rootProject.version }.jar"
jarLocation = "build/libs/${rootProject.archives_base_name}-forge-${rootProject.version}.jar"
}

fabric {
projectName = "fabric"
jarLocation = "build/libs/${rootProject.archives_base_name}-fabric-${ rootProject.version }.jar"
jarLocation = "build/libs/${rootProject.archives_base_name}-fabric-${rootProject.version}.jar"
}

custom {
projectName = "neoforge"
jarLocation = "build/libs/${rootProject.archives_base_name}-neoforge-${ rootProject.version }.jar"
}
}

publishMods {
file = file(forgix.getOutputDir() + "/" + forgix.getMergedJarName())
changelog = file("CHANGELOG.md").getText('UTF-8')
type = STABLE
modLoaders = ["fabric", "forge", "neoforge"]

var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
if (CURSEFORGE_TOKEN != null) {
curseforge {
projectId = rootProject.curseforge_id
accessToken = providers.environmentVariable(CURSEFORGE_TOKEN as Provider<String>)
minecraftVersions = ["1.20.2"]

requires {
slug = ["architectury-api", "cloth-config"]
}
}
}


var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
if (MODRINTH_TOKEN != null) {
modrinth {
projectId = rootProject.modrinth_id
accessToken = providers.environmentVariable(MODRINTH_TOKEN as Provider<String>)
minecraftVersions = ["1.20.2"]
}

requires {
slug = ["architectury-api", "cloth-config"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ public class VMTranslationUpdate {
public static final String MODNAME = "VMTranslationUpdate";
public static final String MOD_ID = "vmtranslationupdate";
static MinecraftClient client = MinecraftClient.getInstance();

private static final boolean isStenographerLoaded = Platform.isModLoaded("stenographer"); // Stenographer 兼容
public static final Logger LOGGER = LoggerFactory.getLogger(MODNAME);
private static final boolean isStenographerLoaded = Platform.isModLoaded("stenographer"); // Stenographer 兼容

public static void init() {
if (ModConfigUtil.getConfig().autoSwitchLanguage && !isStenographerLoaded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public class ModConfigs implements ConfigData {
public String modPackTranslationVersion = "1.0.0";
public int tipsMinutes = 25;
public String traslationPackName = "VM汉化组模组汉化包1.20";
public String traslationPackUrl= "https://cdn.modrinth.com/data/IDWIdXwS/versions/V5YtW17O/VM汉化组模组汉化包1.20";
public String traslationPackUrl= "https://cdn.modrinth.com/data/IDWIdXwS/versions/V5YtW17O/";
public String nameUrl = "https://vmct-cn.top/name.json";
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package top.vmctcn.vmtranslationupdate.forge;

import dev.architectury.platform.forge.EventBuses;
import dev.architectury.utils.EnvExecutor;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.IExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLLoader;
import top.vmctcn.vmtranslationupdate.VMTranslationUpdate;
import top.vmctcn.vmtranslationupdate.util.ModConfigUtil;

Expand All @@ -16,7 +16,9 @@ public VMTranslationUpdateClientForge() {
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true));
EventBuses.registerModEventBus(VMTranslationUpdate.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());

EnvExecutor.runInEnv(Dist.CLIENT, () -> this::onInitializeClient);
if (FMLLoader.getDist() == Dist.CLIENT) {
onInitializeClient();
}
}

public void onInitializeClient() {
Expand Down
8 changes: 5 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ org.gradle.jvmargs=-Xmx2048M

minecraft_version=1.20.2
enabled_platforms=fabric,forge,neoforge

yarn_mappings=1.20.2+build.4

archives_base_name=VMTranslationUpdate
mod_version=2.3
maven_group=top.vmctcn
mod_version=2.3.1
maven_group=top.vmctcn.vmtranslationupdate

architectury_version=10.0.17

Expand All @@ -19,3 +18,6 @@ fabric_api_version=0.91.1+1.20.2
forge_version=1.20.2-48.1.0

neoforge_version=20.2.88

curseforge_id=890229
modrinth_id=wvCSIW08
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package top.vmctcn.vmtranslationupdate.neoforge;

import dev.architectury.utils.EnvExecutor;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.neoforge.network.NetworkConstants;
import top.vmctcn.vmtranslationupdate.VMTranslationUpdate;
import top.vmctcn.vmtranslationupdate.util.ModConfigUtil;
Expand All @@ -14,7 +14,9 @@ public class VMTranslationUpdateClientNeoForge {
public VMTranslationUpdateClientNeoForge() {
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true));

EnvExecutor.runInEnv(Dist.CLIENT, () -> this::onInitializeClient);
if (FMLLoader.getDist() == Dist.CLIENT) {
onInitializeClient();
}
}

public void onInitializeClient() {
Expand Down

0 comments on commit 0366aa2

Please sign in to comment.