Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GitHub actions to latest #73

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 17 # Use Java 17 here because the Loom test env needs it
distribution: temurin

- name: Cache Gradle files
uses: actions/cache@v2
uses: actions/cache@v4
if: ${{ !env.ACT }}
with:
path: |
Expand All @@ -27,18 +27,18 @@ jobs:

- name: Build with Gradle
run: ./gradlew build publishToMavenLocal
env:
EXCLUDE_SUBPROJECTS: true

- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: ${{ !env.ACT }}
with:
name: Artifacts
path: build/libs

- name: Test with Gradle
run: ./gradlew fg:modrinth loom:modrinth
run: |
./gradlew -p fg modrinth
./gradlew -p loom modrinth
if: ${{ !contains(github.event.head_commit.message, 'skip test') }}
env:
MODRINTH_TOKEN: dummy_token_for_CI
9 changes: 3 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 17 # Use Java 17 here because the Loom test env needs it
distribution: temurin

- name: Cache Gradle files
uses: actions/cache@v2
uses: actions/cache@v4
if: ${{ !env.ACT }}
with:
path: |
Expand All @@ -30,13 +30,10 @@ jobs:

- name: Build with Gradle
run: ./gradlew build
env:
EXCLUDE_SUBPROJECTS: true

- name: Release Build
if: startsWith(github.ref, 'refs/tags/v')
run: ./gradlew publishPlugins -Pgradle.publish.key=$GRADLE_PUBLISH_KEY -Pgradle.publish.secret=$GRADLE_PUBLISH_SECRET
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
EXCLUDE_SUBPROJECTS: true
21 changes: 6 additions & 15 deletions fg/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.+', changing: true
}
}

plugins {
id "com.modrinth.minotaur" version "2.+"
id "net.minecraftforge.gradle" version "6.+"
id "java"
id "idea"
}
Expand All @@ -33,20 +25,19 @@ import com.modrinth.minotaur.dependencies.ModDependency
import com.modrinth.minotaur.dependencies.VersionDependency

modrinth {
apiUrl = STAGING_API_URL
projectId = "fred-3"
projectId = "mudmod"
uploadFile = jar
additionalFiles = [project.file("build/libs/fg-$version-sources.jar")]
versionType = "beta"
dependencies = [
new ModDependency("test-project", "optional"),
new VersionDependency("CE5sWFeF", DependencyType.INCOMPATIBLE)
new VersionDependency("dG06oDvH", DependencyType.INCOMPATIBLE)
]
dependencies {
required.project "corrupted"
optional.version "UakHulqw"
incompatible.version "kdIr8lsr", "b1.2+mod"
embedded.project "sbbGxWge"
optional.version "9MsDOrJE"
incompatible.version "mOgUt4GM", "13.0.0"
embedded.project "uiW75cBG"
}
debugMode = true
}
Expand Down
1 change: 1 addition & 0 deletions fg/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx2G
13 changes: 13 additions & 0 deletions fg/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pluginManagement {
repositories {
mavenLocal()
maven {
name = 'Forge'
url = 'https://maven.minecraftforge.net'
}
mavenCentral()
gradlePluginPortal()
}
}

includeBuild("../")
13 changes: 6 additions & 7 deletions loom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ import com.modrinth.minotaur.dependencies.ModDependency
import com.modrinth.minotaur.dependencies.VersionDependency

modrinth {
apiUrl = STAGING_API_URL
projectId = "fred-3"
projectId = "mudmod"
uploadFile = remapJar
additionalFiles = [project.file("build/libs/loom-$version-sources.jar")]
versionType = "alpha"
dependencies = [
new ModDependency("test-project", "optional"),
new VersionDependency("CE5sWFeF", DependencyType.INCOMPATIBLE)
new VersionDependency("dG06oDvH", DependencyType.INCOMPATIBLE)
]
dependencies {
required.project "corrupted"
optional.version "UakHulqw"
incompatible.version "kdIr8lsr", "b1.2+mod"
embedded.project "sbbGxWge"
required.version "test-project", "1.19.4-SNAPSHOT"
optional.version "9MsDOrJE"
incompatible.version "mOgUt4GM", "13.0.0"
embedded.project "uiW75cBG"
required.version "modmenu", "11.0.2"
}
debugMode = true
}
1 change: 1 addition & 0 deletions loom/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx2G
13 changes: 13 additions & 0 deletions loom/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pluginManagement {
repositories {
mavenLocal()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}

includeBuild("../")
14 changes: 0 additions & 14 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
pluginManagement {
repositories {
mavenLocal()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}
rootProject.name = 'Minotaur'
if (!System.getenv().EXCLUDE_SUBPROJECTS) {
include 'fg', 'loom'
}
3 changes: 2 additions & 1 deletion src/main/java/com/modrinth/minotaur/ModrinthExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ModrinthExtension extends DependencyDSL {
/**
* The default token in use for uploading. Exposed as a fallback utility.
*/
@Deprecated
public static final String DEFAULT_TOKEN = System.getenv("MODRINTH_TOKEN");
/**
* The default changelog if one was not provided. Exposed as a fallback utility.
Expand All @@ -48,7 +49,7 @@ public class ModrinthExtension extends DependencyDSL {
public ModrinthExtension(Project project) {
super(project.getObjects());
apiUrl = project.getObjects().property(String.class).convention(DEFAULT_API_URL);
token = project.getObjects().property(String.class).convention(DEFAULT_TOKEN);
token = project.getObjects().property(String.class).convention(project.getProviders().environmentVariable("MODRINTH_TOKEN"));
projectId = project.getObjects().property(String.class);
versionNumber = project.getObjects().property(String.class);
versionName = project.getObjects().property(String.class);
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/modrinth/minotaur/TaskModrinthUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,16 @@ public void apply() {
try {
ModrinthAPI api = api(getProject());

String id = Objects.requireNonNull(api.projects().getProjectIdBySlug(ext.getProjectId().get()).join());
String slug = ext.getProjectId().get();
String id = api.projects().getProjectIdBySlug(slug).join();
if (id == null) {
if (ext.getDebugMode().get()) {
getLogger().error("Cannot find project with id '{}'.", slug);
id = "<unknown>";
} else {
throw new GradleException(String.format("Cannot find project with id '%s'", slug));
}
}
getLogger().debug("Uploading version to project {}", id);

// Add version name if it's null
Expand Down Expand Up @@ -248,7 +257,7 @@ && getProject().getExtensions().findByName("loom") != null) {
getLogger().lifecycle(
"Successfully uploaded version {} to {} ({}) as version ID {}. {}",
newVersion.getVersionNumber(),
ext.getProjectId().get(),
slug,
id,
newVersion.getId(),
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public ProjectDependency toNew(ModrinthAPI api) {
} catch (Exception e) {
throw new GradleException("Failed to resolve version \"" + dep.getVersionId() + "\"!", e);
}

if (version == null) {
throw new GradleException(String.format("Failed to resolve version \"%s\"", dep.getVersionId()));
}

return new ProjectDependency(version.getId(), version.getProjectId(), null, dep.getDependencyType());
} else {
throw new GradleException("Dependency was not an instance of ModDependency or VersionDependency!");
Expand Down