feat: publishing CI

This commit is contained in:
Michael Hillcox 2024-10-27 11:31:14 +00:00
parent 19d0eb3aea
commit c0b0111060
No known key found for this signature in database
14 changed files with 240 additions and 278 deletions

29
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,29 @@
name: "Release"
on:
push:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: "microsoft"
java-version: 21
- name: Fix borked permissions
run: chmod +x ./gradlew
- name: Run gradle tasks
uses: gradle/gradle-build-action@v2
env:
MR_TOKEN: ${{ secrets.MR_TOKEN }}
CF_TOKEN: ${{ secrets.CF_TOKEN }}
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
arguments: clean build publish publishMods

1
.gitignore vendored
View file

@ -20,3 +20,4 @@
*.launch
.settings/org.eclipse.jdt.core.prefs
*.prefs
.DS_Store

View file

@ -1,4 +1,4 @@
# 1.3.6+mc1.21.1
# 1.3.7+mc1.21.1
* Added recipes for AA crops in the IE cloche.
# 1.3.6+mc1.21.1

35
Jenkinsfile vendored
View file

@ -1,35 +0,0 @@
pipeline {
agent any
stages {
stage('Clean') {
steps {
sh './gradlew clean --no-daemon'
}
}
stage('Build') {
steps {
sh './gradlew build --no-daemon'
}
}
stage('Upload Artifacts') {
steps {
archiveArtifacts 'build/libs/**.jar'
}
}
stage('Publish') {
when {
branch '1.12.2'
}
steps {
sh './gradlew publish --no-daemon'
}
}
}
environment {
local_maven = '/var/www/maven'
}
}

View file

@ -1,44 +1,40 @@
plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.165'
id 'net.neoforged.moddev' version '1.0.21'
id "me.modmuss50.mod-publish-plugin" version "0.7.4"
}
def buildSuffix = System.getenv('BUILD_NUMBER') ? "-b${System.getenv('BUILD_NUMBER')}" : ""
tasks.named('wrapper', Wrapper).configure {
distributionType = Wrapper.DistributionType.BIN
}
version = "$mod_version+mc${game_version}"
group = "de.ellpeck"
version = "$mod_version+mc${game_version}${buildSuffix}"
group = "de.ellpeck.actuallyadditions"
base {
archivesName = "ActuallyAdditions"
archivesName = "actuallyadditions"
}
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
if (rootProject.file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
neoForge {
version = project.neo_version
parchment {
mappingsVersion = project.parchment_mappings_version
minecraftVersion = project.hasProperty("parchment_minecraft_version") ? project.parchment_minecraft_version : project.game_version
}
runs {
// applies to all the run configs below
configureEach { net.neoforged.gradle.dsl.common.runs.run.Run run ->
//Limit ram usage for the dev environment to 4GB
jvmArgument '-Xmx4G'
if (run.project.javaToolchains.launcherFor(java.toolchain).map { it.metadata.vendor }.getOrElse("").contains("JetBrains")) {
run.jvmArgument("-XX:+AllowEnhancedClassRedefinition")
}
modSource project.sourceSets.main
}
client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
client()
systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions"
programArguments.addAll '--width=1920', '--height=1080'
}
client2 {
configure ("client")
client()
programArguments.addAll '--username', 'Dev2'
@ -47,30 +43,50 @@ runs {
}
server {
systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions"
server()
programArgument '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions"
}
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', "actuallyadditions"
}
data {
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// workingDirectory project.file('run-data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
data()
programArguments.addAll '--mod', "actuallyadditions", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
configureEach { run ->
systemProperty 'forge.logging.markers', 'REGISTRIES'
logLevel = org.slf4j.event.Level.DEBUG
jvmArgument '-Xmx4G'
if (run.project.javaToolchains.launcherFor(java.toolchain).map { it.metadata.vendor }.getOrElse("").contains("JetBrains")) {
run.jvmArgument("-XX:+AllowEnhancedClassRedefinition")
}
}
}
mods {
"actuallyadditions" {
sourceSet(sourceSets.main)
}
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
// Sets up a dependency configuration called 'localRuntime'.
// This configuration should be used instead of 'runtimeOnly' to declare
// a dependency that will be present for runtime testing but that is
// "optional", meaning it will not be pulled by dependents of this mod.
configurations {
runtimeClasspath.extendsFrom localRuntime
}
repositories {
maven {
url = "https://maven.neoforged.net/releases"
}
maven {
url = "https://maven.blamejared.com"
}
@ -84,8 +100,6 @@ repositories {
}
dependencies {
implementation "net.neoforged:neoforge:${neo_version}"
compileOnly "mezz.jei:jei-${jei_minecraft}-common-api:${jei_version}"
compileOnly "mezz.jei:jei-${jei_minecraft}-neoforge-api:${jei_version}"
@ -126,7 +140,28 @@ jar {
from sourceSets.main.output
}
task apiJar(type: Jar) {
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
var replaceProperties = [
minecraft_version : game_version,
minecraft_version_range: game_version_range,
neo_version : neo_version,
neo_version_range : neo_version_range,
loader_version_range : loader_version_range,
mod_id : "actuallyadditions",
mod_name : "Actually Additions",
mod_version : mod_version,
]
inputs.properties replaceProperties
expand replaceProperties
from "src/main/templates"
into "build/generated/sources/modMetadata"
}
sourceSets.main.resources.srcDir generateModMetadata
neoForge.ideSyncTask generateModMetadata
tasks.register('apiJar', Jar) {
from sourceSets.main.output
from sourceSets.main.java
archiveClassifier.set('api')
@ -137,12 +172,13 @@ javadoc {
include 'de/ellpeck/actuallyadditions/api/**'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
tasks.register('javadocJar', Jar) {
dependsOn javadoc
from 'build/docs/javadoc'
archiveClassifier.set('javadoc')
}
task sourcesJar(type: Jar) {
tasks.register('sourcesJar', Jar) {
from sourceSets.main.java
archiveClassifier.set('sources')
}
@ -151,38 +187,111 @@ artifacts {
archives sourcesJar, apiJar, javadocJar
}
publishing {
tasks.publish.dependsOn build
publications {
mavenJava(MavenPublication) {
groupId = group
artifactId = base.archivesName.get()
version = version
publishing {
publications {
register('mavenJava', MavenPublication) {
from components.java
// Add sources and javadoc to the publication
artifact sourcesJar
artifact apiJar
artifact javadocJar
}
}
pom.withXml {
def node = asNode()
if (node.dependencies.size() > 0)
node.remove(node.dependencies)
}
}
}
repositories {
def token = providers.environmentVariable("MAVEN_TOKEN")
if (token.isPresent()) {
maven {
url "file://" + System.getenv("local_maven")
url "https://maven.saps.dev/releases"
credentials {
username = "ell"
password = token.get()
}
}
}
}
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
/**
* Seek out the changelog for the current version and return it as a string.
*/
def createChangelog = () -> {
def changelogText = new File("CHANGELOG.md").text
def changelog = ""
def lines = changelogText.split("\n")
def inChangelog = false
for (int i = 0; i < lines.size(); i++) {
def line = lines[i]
if (line.startsWith("# ")) {
if (inChangelog) {
break
} else {
if (line.contains(mod_version)) {
inChangelog = true
}
}
}
if (inChangelog) {
changelog += line + "\n"
}
}
def output = changelog.trim()
return output.empty ? "No changelog found" : output
}
def cfToken = providers.environmentVariable("CF_TOKEN")
def mrToken = providers.environmentVariable("MR_TOKEN")
def ghToken = providers.environmentVariable("GITHUB_TOKEN")
publishMods {
dryRun = !cfToken.isPresent() || !mrToken.isPresent() || !ghToken.isPresent()
changelog = createChangelog().trim()
version = mod_version
displayName = "Actually Additions ${mod_version}"
type = STABLE
file = jar.archiveFile
additionalFiles.from apiJar.archiveFile
additionalFiles.from javadocJar.archiveFile
additionalFiles.from sourcesJar.archiveFile
modLoaders.add("neoforge")
curseforge {
accessToken = cfToken
projectId = "228404"
minecraftVersions.add(game_version)
javaVersions.add(JavaVersion.VERSION_21)
}
modrinth {
accessToken = mrToken
projectId = "4K7Q3nqd"
minecraftVersions.add(game_version)
}
github {
repository = "Ellpeck/ActuallyAdditions"
accessToken = ghToken
commitish = providers.environmentVariable("GITHUB_SHA").orElse("dryRun")
tagName = providers.environmentVariable("GITHUB_REF_NAME").orElse("dryRun")
}
}

View file

@ -1,17 +1,23 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# Actually Additions
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=false
mod_version=1.3.7
# Forge
game_version=1.21.1
game_version_range=[1.21.1,1.22)
neo_version=21.1.71
neo_version_range=[21.1,21.2)
loader_version_range=4
# Parchment (Mappings)
neogradle.subsystems.parchment.minecraftVersion=1.21
neogradle.subsystems.parchment.mappingsVersion=2024.07.28
neogradle.subsystems.conventions.runs.create-default-run-per-type=false
# Uncomment to apply a different mc version for parchment
parchment_minecraft_version=1.21
parchment_mappings_version=2024.07.28
# Other mods
jei_minecraft=1.21.1

View file

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

Binary file not shown.

View file

@ -11,4 +11,5 @@ pluginManagement {
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}
rootProject.name = "actuallyadditions"

View file

@ -1,85 +0,0 @@
/*
* This file ("ThreadUpdateChecker.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.update;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.util.Util;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Properties;
public class ThreadUpdateChecker extends Thread {
public ThreadUpdateChecker() {
this.setName(ActuallyAdditions.NAME + " Update Checker");
this.setDaemon(true);
this.start();
}
@Override
public void run() {
ActuallyAdditions.LOGGER.info("Starting Update Check...");
try {
URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/main/update/updateVersions.properties");
Properties updateProperties = new Properties();
updateProperties.load(new InputStreamReader(newestURL.openStream()));
String currentMcVersion = Util.getMcVersion();
if (CommonConfig.Other.UPDATE_CHECK_VERSION_SPECIFIC.get()) {
String newestVersionProp = updateProperties.getProperty(currentMcVersion);
UpdateChecker.updateVersionInt = Integer.parseInt(newestVersionProp);
UpdateChecker.updateVersionString = currentMcVersion + "-r" + newestVersionProp;
} else {
int highest = 0;
String highestString = "";
for (String updateMC : updateProperties.stringPropertyNames()) {
String updateVersion = updateProperties.getProperty(updateMC);
int update = Integer.parseInt(updateVersion);
if (highest < update) {
highest = update;
highestString = updateMC + "-r" + updateVersion;
}
}
UpdateChecker.updateVersionInt = highest;
UpdateChecker.updateVersionString = highestString;
}
String clientVersionString = Util.getMajorModVersion();
int clientVersion = Integer.parseInt(clientVersionString.contains("_") ? clientVersionString.substring(0, clientVersionString.indexOf("_")) : clientVersionString);
if (UpdateChecker.updateVersionInt > clientVersion) {
UpdateChecker.needsUpdateNotify = true;
}
ActuallyAdditions.LOGGER.info("Update Check done!");
} catch (Exception e) {
ActuallyAdditions.LOGGER.error("Update Check failed!", e);
UpdateChecker.checkFailed = true;
}
if (!UpdateChecker.checkFailed) {
if (UpdateChecker.needsUpdateNotify) {
ActuallyAdditions.LOGGER.info("There is an Update for " + ActuallyAdditions.NAME + " available!");
ActuallyAdditions.LOGGER.info("Current Version: " + ActuallyAdditions.VERSION + ", newest Version: " + UpdateChecker.updateVersionString + "!");
ActuallyAdditions.LOGGER.info("View the Changelog at " + UpdateChecker.CHANGELOG_LINK);
ActuallyAdditions.LOGGER.info("Download at " + UpdateChecker.DOWNLOAD_LINK);
} else {
ActuallyAdditions.LOGGER.info(ActuallyAdditions.NAME + " is up to date!");
}
}
UpdateChecker.threadFinished = true;
}
}

View file

@ -1,56 +0,0 @@
/*
* This file ("UpdateChecker.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.update;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.client.event.ClientTickEvent;
import net.neoforged.neoforge.common.NeoForge;
public class UpdateChecker {
public static final String DOWNLOAD_LINK = "http://ellpeck.de/actadddownload";
public static final String CHANGELOG_LINK = "http://ellpeck.de/actaddchangelog";
public static boolean checkFailed;
public static boolean needsUpdateNotify;
public static int updateVersionInt;
public static String updateVersionString;
public static boolean threadFinished = false;
public UpdateChecker() {
// if (CommonConfig.OTHER.DO_UPDATE_CHECK.get() && !Util.isDevVersion()) {
// ActuallyAdditions.LOGGER.info("Initializing Update Checker...");
// new ThreadUpdateChecker();
// MinecraftForge.EVENT_BUS.register(this);
// }
}
@SubscribeEvent(receiveCanceled = true)
public void onTick(ClientTickEvent.Pre event) {
if (Minecraft.getInstance().player != null) {
Player player = Minecraft.getInstance().player;
if (UpdateChecker.checkFailed) {
player.displayClientMessage(Component.translatable("info.actuallyadditions.update.failed"), false);
} else if (UpdateChecker.needsUpdateNotify) {
player.displayClientMessage(Component.translatable("info.actuallyadditions.update.generic"), false);
player.displayClientMessage(Component.translatable("info.actuallyadditions.update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString), false);
player.displayClientMessage(Component.translatable("info.actuallyadditions.update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK), false);
}
if (threadFinished) {
NeoForge.EVENT_BUS.unregister(this);
}
}
}
}

View file

@ -1,30 +1,33 @@
modLoader="javafml"
loaderVersion="[4,)"
loaderVersion="${loader_version_range}"
license="MIT"
issueTrackerURL="https://github.com/Ellpeck/ActuallyAdditions/issues"
[[mods]]
modId="actuallyadditions"
version="${file.jarVersion}"
displayName="Actually Additions"
#logoFile="logo.png"
version="${mod_version}"
displayName="${mod_name}"
displayURL="https://github.com/Ellpeck/ActuallyAdditions"
credits="Author: Ellpeck; Textures and Models: BootyToast, GlenthorLP, canitzp; Porters: Flanks, MrBysco, ErrorMikey; 1.20+ Textures: Ridanisaurus"
authors="Ellpeck"
description='''
Do you want Automation? Wireless Transport? Better Machines? A cup o\' Coffee? Chests? Better Hoppers? Leaf Blowers? Faster Growth? Plants? Well, Actually Additions has all that and a lot more!
'''
[[mixins]]
config = "actuallyadditions.mixins.json"
[[dependencies.actuallyadditions]]
modId="neoforge"
type="required"
versionRange="[21.1.1,)"
versionRange="${neo_version_range}"
ordering="NONE"
side="BOTH"
# Here's another dependency
[[dependencies.actuallyadditions]]
modId="minecraft"
type="required"
versionRange="[1.21.1,1.22)"
versionRange="${minecraft_version_range}"
ordering="NONE"
side="BOTH"

View file

@ -1,11 +0,0 @@
1.7.10=21
1.8.9=26
1.9=33
1.9.4=45
1.10=46
1.10.2=105
1.11=92
1.11.2=110
1.12=118
1.12.1=121
1.12.2=151