Skip to content

Use semver to expand version ranges for game-versions#115

Merged
zefir-git merged 5 commits into
mainfrom
113-allow-version-ranges-for-the-game-versions
May 20, 2026
Merged

Use semver to expand version ranges for game-versions#115
zefir-git merged 5 commits into
mainfrom
113-allow-version-ranges-for-the-game-versions

Conversation

@zefir-git
Copy link
Copy Markdown
Member

Adds interpretation for more complex version ranges using >=, ||, <, -, etc., using semver’s functionality for interpreting ranges.

Since Mojang versions are not SemVer but still similar to it, some additional checks are done:

  • Versions like 1.21 and 26.1 are treated as equivalents in semver to 1.21.0 and 26.1.0 (Mojang elides the .0).
  • Snapshots and pre-releases are not expanded in ranges (which is consistent with the existing behaviour of the action). The action still allows arbitrary inputs for gameVersions, which means you can manually specify snapshots/pre-releases, but crucially, anything that's not a range, also falls under this category, such as exact versions like 1.21.11, 26.1.2, etc. However, the semver library is happy to treat 1.21.11 as a range (of a single version), so an additional check (coerced === v) discriminates them as non-ranges.

Backwards-compatible with the 1.21.x format used previously, as the semver library interprets it correctly.

@zefir-git zefir-git self-assigned this May 15, 2026
@zefir-git zefir-git added the feature A request, idea, or new functionality label May 15, 2026
@zefir-git zefir-git linked an issue May 15, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@Wolf2323 Wolf2323 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me.

But while using it in my workflow I get this error:

Error: {
  "error": "invalid_input",
  "description": "Error with multipart data: Provided value '>=1.18' is not a valid variant for game_versions"
}

Workflow run: https://github.com/BetonQuest/BetonQuest/actions/runs/25989476104/job/76393518447

From my understanding it should work fine however.

@zefir-git
Copy link
Copy Markdown
Member Author

Thanks. The PR branch was targeted in your workflow, however, the action.yaml pins the docker image to the current latest image version 2.3.4. (there is no image for this PR built)

image: docker://ghcr.io/cloudnode-pro/modrinth-publish:2.3.4

I haven’t yet tested this PR, but I will do that in the coming days, make any modifications if needed, I’ll also of course update the docs, then undraft and look into merging this.

@zefir-git
Copy link
Copy Markdown
Member Author

Tested and works OK. Added docs, but I’m not 100% sure I’m happy with them
https://github.com/cloudnode-pro/modrinth-publish/blob/113-allow-version-ranges-for-the-game-versions/README.md#game-versions-required

@zefir-git zefir-git marked this pull request as ready for review May 20, 2026 19:30
@zefir-git zefir-git requested a review from a team as a code owner May 20, 2026 19:30
@zefir-git zefir-git changed the title Use semver to expand version ranges for gameVersions Use semver to expand version ranges for game-versions May 20, 2026
@zefir-git zefir-git merged commit 2b1a700 into main May 20, 2026
3 checks passed
@zefir-git zefir-git deleted the 113-allow-version-ranges-for-the-game-versions branch May 20, 2026 19:34
@Wolf2323
Copy link
Copy Markdown

Hey, is there now a way to already use this? If I am right, I need to wait for a release?

@zefir-git
Copy link
Copy Markdown
Member Author

Yeah, need to make a release. Will do #116 now and make a release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A request, idea, or new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow version ranges for the game-versions

2 participants