Kir-Antipov/mc-publish

[Question] Unable to specify snapshot version range

UpcraftLP opened this issue · 1 comments

Description

I am trying to upload a mod for 1.21-pre4 to Curseforge and modrinth.

Expected Behavior

THe mod uploads correctly and uses 1.21-Snapshot as version on curseforge, based on detecting >=1.21- in the fabric.mod.json file

Actual Behavior

mc-publish throws the following error:
Error: ArgumentError: At least one game version should be specified to upload files to CurseForge. (Parameter 'request.gameVersions')

Version

995edad

Environment

GitHub Actions

Configuration

No response

Logs

No response

Other Information

see https://github.com/Up-Mods/Sparkweave/actions/runs/9418780513 and previous runs for various things I have attempted to fix this issue.
I've specified game-version-filter: any, and also tried to manually add 1.21-Snapshot to the game versions specified in the fabric.mod.json file

Hi! The problem is neither 1.21- nor CurseForge-specific. mc-publish throws this error because it cannot understand the range you use in this case. >=1.21- is not a standardized syntax, so, for example, some tools like Python's pip support it, while others like Node's npm do not. And even when supported, it can mean different things, so yeah, here's that.

I didn't implement a range parser myself for this project (welp, honestly, I did reinvent lots of wheels for mc-publish, it just happens to not be one of them). Instead, I used a pre-existing solution in the form of npm/node-semver. Therefore, I do not have full control over which syntax sugar is supported and whichever is not. You can check that repository to ensure the ranges you use will be understood by mc-publish.

While it’s definitely a bummer that mc-publish doesn't support a small piece of functionality that Fabric does, since I consider this project Fabric-first, I do not plan on re-implementing a range parsing solution from scratch anytime soon, as I already have many tasks on my plate, and the benefits of undertaking this particular one (which is pretty time-consuming and also just boring) are quite minimal. I hope that’s understandable and not too much of an inconvenience for you.

To solve the problem at hand, you just need to use a more portable syntax that both Fabric, mc-publish, and basically any other tool can understand. Here are some possible solutions in the form of a YAML configuration. However, as always, the Minecraft version range can (and should) be specified within your mod metadata as a minecraft dependency.

  1. At this moment, you may use a simple >1.20.x:
    game-versions: >1.20.x
    game-version-filter: any
  2. If you want to future-proof it a bit, you may use >1.20.x <1.21:
    game-versions: >1.20.x <1.21
    game-version-filter: any
  3. Alternatively, you can use <1.21 with the game-version-filter property set to snapshots | max. This way, mc-publish will first select every version less than the full 1.21 release, then filter out everything but snapshots from that, and finally take the latest series of snapshots, which would be 1.21 snapshots in this case. However, this is a mc-publish-only solution, and it’s not advisable to specify such a range in your mod metadata.
    game-versions: <1.21
    game-version-filter: snapshots | max
  4. All the above solutions will result in the following version list being selected: [1.21-pre4, 1.21-pre3, 1.21-pre2, ...]. However, it may be a good idea to use something as simple as >=1.21-pre4, as one might do with a regular release:
    game-versions: >=1.21-pre4
    game-version-filter: any

I think that about covers it. You may choose any solution you like :)


By the way, just a few tips:

  1. Please check the README (or the wiki, when I'm finally done with it) to learn if a property can be specified in the mod metadata (and how it should be specified there). You cannot simply copy-paste your YAML config into fabric.mod.json, as mc-publish doesn't understand that, at least at the moment.

  2. Additionally, 1.20-Snapshot, 1.21-Snapshot, and other CurseForge nonsense are not valid Minecraft version identifiers. Please, use the official version names you see in your Minecraft launcher (i.e., the ones specified in the version manifest) or the ones used by Fabric, which normalizes snapshots like 24w21b into something more SemVer-friendly.