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

Testpr #3

Closed
wants to merge 20 commits into from
Closed
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
27 changes: 27 additions & 0 deletions .github/workflows/actually-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Actually publish PR'

on:
workflow_run:
workflows: [Publish PRs]
types:
- completed

permissions:
packages: write
actions: write
checks: write
contents: write # Write for commit comments
issues: write
pull-requests: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Upload
uses: ForgeForce/action-pr-publishing@mainff
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
artifacts-base-path: net/neoforged/neoforge/
publishing-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .github/workflows/build-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ jobs:
with:
arguments: build
cache-read-only: false

- name: Publish artifacts
uses: neoforged/action-pr-publishing/upload@v1
43 changes: 43 additions & 0 deletions .github/workflows/publish-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish PRs

on:
pull_request:
types:
- opened
- synchronize

permissions:
contents: read
statuses: write

jobs:
upload:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1000
fetch-tags: true

# Switch to a new branch with the PR number and PR branch name,
# for the projects where the buildscript uses the branch name
- name: Create branch for commit
run:
git switch -C pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.ref }}

- name: Make Gradle executable
# language=bash
run: chmod +x ./gradlew # Thanks Windows

- name: Setup Java 17
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#java
# language=bash
run: export JAVA_HOME=$(echo $JAVA_HOME_17_X64)

- uses: gradle/gradle-build-action@v2
name: Setup
with:
arguments: :neoforge:setup

- uses: ForgeForce/action-pr-publishing/upload@mainff
20 changes: 19 additions & 1 deletion src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.CrashReportCallables;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModLoader;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.ModLoadingStage;
import net.neoforged.fml.ModLoadingWarning;
import net.neoforged.fml.StartupMessageManager;
import net.neoforged.fml.VersionChecker;
import net.neoforged.fml.common.Mod;
Expand Down Expand Up @@ -448,7 +452,7 @@ public static void enableMilkFluid() {
enableMilkFluid = true;
}

public NeoForgeMod(IEventBus modEventBus, Dist dist) {
public NeoForgeMod(IEventBus modEventBus, Dist dist, ModContainer container) {
LOGGER.info(NEOFORGEMOD, "NeoForge mod loading, version {}, for MC {} with MCP {}", NeoForgeVersion.getVersion(), NeoFormVersion.getMCVersion(), NeoFormVersion.getMCPVersion());
ForgeSnapshotsMod.logStartupWarning();

Expand Down Expand Up @@ -507,6 +511,12 @@ public NeoForgeMod(IEventBus modEventBus, Dist dist) {
NeoForge.EVENT_BUS.addListener(CapabilityHooks::invalidateCapsOnChunkLoad);
NeoForge.EVENT_BUS.addListener(CapabilityHooks::invalidateCapsOnChunkUnload);
NeoForge.EVENT_BUS.addListener(CapabilityHooks::cleanCapabilityListenerReferencesOnTick);

if (isPRBuild(container.getModInfo().getVersion().toString())) {
ModLoader.get().addWarning(new ModLoadingWarning(
container.getModInfo(), ModLoadingStage.CONSTRUCT,
"loadwarning.neoforge.prbuild"));
}
}

public void preInit(FMLCommonSetupEvent evt) {
Expand Down Expand Up @@ -614,4 +624,12 @@ public void registerLootData(RegisterEvent event) {
public void registerPermissionNodes(PermissionGatherEvent.Nodes event) {
event.addNodes(USE_SELECTORS_PERMISSION);
}

public static boolean isPRBuild(String neoVersion) {
// The -pr- being inside the actual version and a branch name is important.
// Since we checkout PRs on a branch named `pr-<number>-<headname>`, this assures that
// the regex will match PR builds published to Packages, but that it will not match local PR branches
// since those usually have the name `pr|pull/<number>`
return neoVersion.matches("\\d+\\.\\d+\\.\\d+(-beta)?-pr-\\d+-[\\w-]+");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.neoforged.neoforge.common.NeoForgeMod;

public class ForgeSnapshotsModClient {
public static void renderMainMenuWarning(String neoForgeVersion, GuiGraphics graphics, Font font, int width, int height, int alpha) {
if (neoForgeVersion.contains("-beta")) {
if (NeoForgeMod.isPRBuild(neoForgeVersion)) {
graphics.drawCenteredString(font, Component.translatable("loadwarning.neoforge.prbuild"), width / 2, 4, 0xFFFFFF | alpha);
} else if (neoForgeVersion.contains("-beta")) {
// Render a warning at the top of the screen
Component line = Component.translatable("neoforge.update.beta.1", ChatFormatting.RED, ChatFormatting.RESET).withStyle(ChatFormatting.RED);
graphics.drawCenteredString(font, line, width / 2, 4 + (0 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/assets/neoforge/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"fml.menu.mods": "Mods",
"fml.menu.mods.title": "Mods",
"fml.menu.mods": "Mods you say?",
"fml.menu.mods.title": "Mods hmmm",
"fml.menu.mods.normal": "Off",
"fml.menu.mods.search": "Search",
"fml.menu.mods.search": "Search pls",
"fml.menu.mods.a_to_z": "A-Z",
"fml.menu.mods.z_to_a": "Z-A",
"fml.menu.mods.config": "Config",
"fml.menu.mods.config": "Configurationnnnnn",
"fml.menu.mods.openmodsfolder": "Open mods folder",
"fml.menu.modoptions": "Mod Options...",
"fml.menu.mods.info.version":"Version: {0}",
Expand Down Expand Up @@ -106,6 +106,8 @@
"fml.messages.version.restriction.bounded.lowerexclusive":"above {0}, and {1} or below",
"fml.messages.version.restriction.bounded.upperexclusive":"{0} or above, and below {1}",

"loadwarning.neoforge.prbuild": "This build of NeoForge is coming from a Pull Request and is §c§lUNSUPPORTED§r",

"commands.neoforge.arguments.enum.invalid": "Enum constant must be one of {0}, found {1}",
"commands.neoforge.dimensions.list": "Currently registered dimensions by type:",
"commands.neoforge.entity.list.invalid": "Invalid filter, does not match any entities. Use /neoforge entity list for a proper list",
Expand Down
2 changes: 2 additions & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test
f
Loading