Publish a version on Modrinth. Works for all Modrinth project types.
# …
steps:
- uses: cloudnode-pro/modrinth-publish@2.0.0
with:
token: ${{ secrets.MODRINTH_TOKEN }}
# … configure the action using inputs here
Modrinth API domain. For testing purposes you can set this to staging-api.modrinth.com
.
See Modrinth Staging Server.
- Default
api.modrinth.com
Modrinth API token. The token must have the ‘Create versions’ scope. This token is secret, and it’s recommended to set it inside a GitHub Repository Secret.
Personal access tokens (PATs) can be generated from the user settings.
The ID of the project this version is for.
You can obtain the ID by opening your project on Modrinth, then opening the ⋮ menu, and selecting Copy ID.
The name of this version.
- Default
- copied from
version
The version number. Ideally will follow semantic versioning.
The release channel for this version.
- Allowed values
release
,beta
,alpha
- Default
- Inferred from the version.
- If version includes
alpha
, will be set toalpha
. - If version includes
beta
,rc
, orpre
, will be set tobeta
. - Otherwise, will be set to
release
.
- If version includes
Whether the version is featured or not.
- Allowed values
true
,false
- Default
true
if the release channel isrelease
, otherwisefalse
.
The changelog for this version.
The mod loaders that this version supports. In case of resource packs, use minecraft
.
Format each loader on a new line, or use a JSON string array.
- Example
-
loaders: |- paper fabric
loaders: '["paper", "fabric"]'
A list of versions of Minecraft that this version supports. You can use a pattern like 1.21.x
to include all patch
versions (the last number in the version).
Format each version on a new line, or use a JSON string array.
- Example
-
game-versions: |- 1.21.x 1.20.x 1.19.4
game-versions: '["1.21.x", "1.20.x", "1.19.4"]'
A list of file paths to upload. There must be at least one file, unless the new version’s status is draft
. The allowed
file extensions are .mrpack
, .jar
, .zip
, and .litemod
.
Format each file on a new line, or use a JSON string array.
- Example
-
files: |- target/YourProject-1.2.3.jar path/to/file.zip
files: '["target/YourProject-1.2.3.jar", "path/to/file.zip"]'
The name (not path) from files
to be set as the primary file.
- Example
YourProject-1.2.3.jar
A list of specific versions of projects that this version depends on.
Formatted as JSON array. See Create Version - Modrinth API docs.
- Example
-
dependencies: |- [{ "project_id": "AABBCCDD", "dependency_type": "optional" }]
- Allowed values
listed
,archived
,draft
,unlisted
,scheduled
,unknown
- Default
listed
- Allowed values
listed
,archived
,draft
,unlisted
You can use the following example workflow to publish a version on Modrinth by creating a release on GitHub.
This example workflow will let you automatically build and upload a version on Modrinth whenever you publish a new release via GitHub. This enables you to choose the version tag and write release notes via the GitHub interface.
As the version will be taken from the release tag, in your pom.xml
you can set a version like 0.0.0-SNAPSHOT
and it
will always be replaced with the correct version for builds via the workflow. This means you won‘t need to update the
version in multiple places.
Maven
name: Publish
on:
release:
types: [published]
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# !!! Make sure to select the correct Java version for your project !!!
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: maven
# This step will take the version tag from the release and replace it in `pom.xml` before building.
- name: Set version from release tag
run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false
- name: Build and package with Maven
run: mvn -B clean package --file pom.xml
- name: Upload to Modrinth
uses: cloudnode-pro/modrinth-publish@2.0.0
with:
# Configure the action as needed. The following is an example.
token: ${{ secrets.MODRINTH_TOKEN }}
project: AABBCCDD
name: ${{ github.event.release.name }}
version: ${{ github.event.release.tag_name }}
changelog: ${{ github.event.release.body }}
loaders: |-
paper
spigot
bukkit
game-versions: |-
1.20.x
1.21.x
files: target/YourProject-${{ github.event.release.tag_name }}.jar