https://github.com/cloudnode-pro/modrinth-publish
A GitHub Action for publishing plugin versions to Modrinth
https://github.com/cloudnode-pro/modrinth-publish
modrinth modrinth-api
Last synced: about 2 months ago
JSON representation
A GitHub Action for publishing plugin versions to Modrinth
- Host: GitHub
- URL: https://github.com/cloudnode-pro/modrinth-publish
- Owner: cloudnode-pro
- License: gpl-3.0
- Created: 2024-01-13T12:01:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-11T22:10:18.000Z (7 months ago)
- Last Synced: 2024-11-11T23:19:35.053Z (7 months ago)
- Topics: modrinth, modrinth-api
- Language: TypeScript
- Homepage:
- Size: 1.22 MB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - cloudnode-pro/modrinth-publish - ([GitHub Marketplace](https://github.com/marketplace/actions/modrinth-publish)) - A GitHub Action for publishing versions on Modrinth. Works for all Modrinth project types. (Project/version management tools / In-game)
README
# modrinth-publish
Publish a version on Modrinth. Works for all Modrinth project types.
## Usage
```yaml
# …
steps:
- uses: cloudnode-pro/modrinth-publish@v2
with:
token: ${{ secrets.MODRINTH_TOKEN }}
# … configure the action using inputs here
```## Inputs
### ~~`api-domain`~~ (deprecated)
The Modrinth API domain.
> [!WARNING]
> The Modrinth Staging API is no longer recommended for testing or as a sandbox. Instead, consider creating a ‘draft’
> project on the production API and deleting it after testing.
> This input is scheduled for removal in `v3.0.0`.
- Default
api.modrinth.com
***
### `token` (required)
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](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions).
Personal access tokens (PATs) can be generated from [the user settings](https://modrinth.com/settings/pats).
***
### `project` (required)
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.
***
### `name`
The name of this version.
- Default
- copied from
version
***
### `version` (required)
The version number. Ideally will follow [semantic versioning](https://semver.org/).
***
### `channel`
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
***
### `featured`
Whether the version is featured or not.
- Allowed values
-
true
,false
- Default
-
true
if the release channel isrelease
, otherwisefalse
.
***
### `changelog`
The changelog for this version.
***
### `loaders` (required)
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
-
```yaml
loaders: |-
paper
fabric
``````yaml
loaders: '["paper", "fabric"]'
```
***
### `game-versions`
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
-
```yaml
game-versions: |-
1.21.x
1.20.x
1.19.4
``````yaml
game-versions: '["1.21.x", "1.20.x", "1.19.4"]'
```
***
### `files` (required)
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
-
```yaml
files: |-
target/YourProject-1.2.3.jar
path/to/file.zip
``````yaml
files: '["target/YourProject-1.2.3.jar", "path/to/file.zip"]'
```
***
### `primary-file`
The name (not path) from `files` to be set as the primary file.
- Example
YourProject-1.2.3.jar
***
### `dependencies`
A list of specific versions of projects that this version depends on.
Formatted as JSON array.
See [Create Version - Modrinth API docs](https://docs.modrinth.com/api/operations/createversion/#request-body).
- Example
-
```yaml
dependencies: |-
[{
"project_id": "AABBCCDD",
"dependency_type": "optional"
}]
```
***
### `status`
- Allowed values
-
listed
,archived
,draft
,unlisted
,scheduled
,unknown
- Default
listed
***
### `requested-status`
- Allowed values
-
listed
,archived
,draft
,unlisted
***
## Example Maven workflow
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
```yaml
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@v2
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
```