Skip to content

GitHub Action that helps you publish your Minecraft plugins everywhere

License

Notifications You must be signed in to change notification settings

BrycensRanch/plugin-publish

Β 
Β 

Repository files navigation

Publish Minecraft Plugins & Mods - GitHub Action

This action is a fork mod-publish, which should use more radical methods of uploading plugins automatically, with the use of puppeteer when necessary to upload your plugins to their specified place. However, we do not plan on merging back into upstream due to the nature of our changes - which are opinionated. However, the plugin functionality is currently not implemented yet. Also, as we use mc-plugin as a upstream, we will continue to support mods along as it's convenient.

GitHub tag GitHub build status GitHub license CodeCov

This action helps you upload assets of your Minecraft mods & plugins to GitHub Releases, Modrinth, CurseForge, Polymart, and hopefully Hangar soon. This is a fork of mc-publish, with it losing it's cross platform functionality and adding the ability to automatically publish plugins to their respective platorms and it converts your Markdown to BBCode when necessary. (Spigot & MCM support is not planned due to scraping or automations being a violation of their stupid tos and their REST APIs don't support it)

Keep in mind, I couldn't find any example of uploading a resource update to MCM when I looked through the source code of their various API wrappers, so.

Some plugin platforms do not have functionatlity to upload assets/updates to their platform. So, we act like a regular user and upload it ourselves. Websites don't like robots, so, we'll sometimes have to use captcha services such as 2captcha, Captcha AI, TrueCaptcha

πŸ“– Usage

Most of the values are automatically resolved (read further for more info). Therefore, here's all you really need to publish your mod:

jobs:
  build:
    # ...
    steps:
      - uses: BrycensRanch/[email protected]
        with:
          # You don't need this section if you don't want to publish
          # your assets to Modrinth
          modrinth-id: AANobbMI
          modrinth-token: ${{ secrets.MODRINTH_TOKEN }}

          # You don't need this section if you don't want to publish
          # your assets to CurseForge
          curseforge-id: 394468
          curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

          # You don't need this section if you don't want to publish
          # your assets to GitHub
          github-token: ${{ secrets.GITHUB_TOKEN }}

🦜 Unnecessary Verbose Example

Please, do not consider the following example as something you should use. mc-publish was made to be as zero-configy as possible, you just do not need all this. It's here to show you most of the available inputs in the form of an actual configuration. It not only hurts me on a spiritual level to see configurations with hardcoded values that could be automatically resolved, but sometimes people copy-paste inputs that will break their workflows, e.g., I saw someone trying to use github-discussion: Announcements in repo that had neither "Announcements" discussion category, nor discussions in general. Occam's Razor in action - if you don't see a reason to use an input, just don't use it. With all that said, let's get back to our unnecessary verbose example:

jobs:
  build:
    # ...
    steps:
      - uses: BrycensRanch/[email protected]
        with:
          modrinth-id: AANobbMI
          modrinth-featured: true
          modrinth-unfeature-mode: subset
          modrinth-token: ${{ secrets.MODRINTH_TOKEN }}

          curseforge-id: 394468
          curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

          github-tag: mc1.17.1-0.3.2
          github-generate-changelog: true
          github-draft: false
          github-prerelease: false
          github-commitish: dev
          github-discussion: Announcements
          github-token: ${{ secrets.GITHUB_TOKEN }}

          files-primary: build/libs/!(*-@(dev|sources|javadoc)).jar
          files-secondary: build/libs/*-@(dev|sources|javadoc).jar

          name: Sodium 0.3.2 for Minecraft 1.17.1
          version: mc1.17.1-0.3.2
          version-type: release
          changelog-file: CHANGELOG.md

          loaders: |
            fabric
            forge
            quilt
          game-versions: |
            1.18.2
            1.19
            21w37a
          dependencies: |
            required-dependency | depends | *
            optional-dependency | recommends | 0.1.0
            suggested-dependency | suggests | 0.2.0
            included-dependency | includes | 0.3.0
            conflicting-dependency | conflicts | *
            incompatible-dependency | breaks | *
          java: |
            8
            17

          retry-attempts: 2
          retry-delay: 10000
          fail-mode: fail

πŸ“ Inputs

Name Description Default value Examples
modrinth-id The ID of the Modrinth project to upload to A value specified in the config file AANobbMI
modrinth-token A valid token for the Modrinth API ❌ ${{ secrets.MODRINTH_TOKEN }}
modrinth-featured Indicates whether the version should be featured on Modrinth or not true true
false
modrinth-unfeature-mode Determines the way automatic unfeaturing of older Modrinth versions works If modrinth-featured is set to true, subset; otherwise, none none
subset
intersection
any
curseforge-id The ID of the CurseForge project to upload to A value specified in the config file 394468
curseforge-token A valid token for the CurseForge API ❌ ${{ secrets.CURSEFORGE_TOKEN }}
github-tag The tag name of the release to upload assets to A tag of the release that triggered the action, if any; otherwise it will be inferred from the GITHUB_REF environment variable mc1.17.1-0.3.2
github-generate-changelog Indicates whether to automatically generate the changelog for this release. If changelog is specified, it will be pre-pended to the automatically generated notes. Unused if the GitHub Release already exists πŸ›ˆ true, if changelog and changelog-file are not provided; otherwise, false false
true
github-draft true to create a draft (unpublished) release, false to create a published one. Unused if the GitHub Release already exists πŸ›ˆ false false
true
github-prerelease true to identify the release as a prerelease, false to identify the release as a full release. Unused if the GitHub Release already exists πŸ›ˆ false, if version-type is release; otherwise, true false
true
github-commitish Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists πŸ›ˆ The repository's default branch dev
feature/86
github-discussion If specified, a discussion of the specified category is created and linked to the release. Unused if the GitHub Release already exists πŸ›ˆ ❌ Announcements
github-token A valid token for the GitHub API ❌ ${{ secrets.GITHUB_TOKEN }}
files A glob of the file(s) to upload ❌ build/libs/*.jar
files-primary A glob of the primary files to upload build/libs/!(*-@(dev|sources|javadoc)).jar build/libs/!(*-@(dev|sources|javadoc)).jar
files-secondary A glob of the secondary files to upload build/libs/*-@(dev|sources|javadoc).jar build/libs/*-@(dev|sources|javadoc).jar
name The name of the version A title of the release that triggered the action Sodium 0.3.2 for Minecraft 1.17.1
version The version number A tag of the release that triggered the action mc1.17.1-0.3.2
version-type The type of the release Will be parsed from the version value alpha
beta
release
changelog The changelog for this version A body of the release that triggered the action This release fixes a few more issues in Sodium 0.3 for Minecraft 1.17.1.
changelog-file A glob of the changelog file ❌ CHANGELOG.md
loaders A list of supported mod loaders fabric for Fabric mods
forge for Forge mods
quilt for Quilt mods
fabric
forge
quilt
rift
game-versions A list of supported Minecraft versions A value specified in the config file, if any; otherwise, it will be parsed from the version value 21w37a
1.17
version-resolver Determines the way automatic game-versions resolvement works releasesIfAny exact
latest
all
releases
releasesIfAny
dependencies A list of dependencies A dependency list specified in the config file fabric | depends | 0.40.0
fabric-api
java A list of supported Java versions empty string Java 8
Java 1.8
8
retry-attempts The maximum number of attempts to publish assets 2 2
10
-1
retry-delay Time delay between attempts to publish assets (in milliseconds) 10000 10000
60000
0
fail-mode Determines how errors that occur during mod publishing process are handled fail fail
warn
skip

Note, that you can use any top-level property (name, version, dependencies, files, etc.) as a target-specific one. This can help you fine-tune mc-publish to suit your tastes and needs. For example, consider the following configuration:

# It is a good idea to share the same primary file among different targets
files-primary: build/libs/!(*-@(dev\|sources\|javadoc)).jar

modrinth-id: aaaAAAaa
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
# Modrinth-specific name for your mod
modrinth-name: Modrinth Mod
# Modrinth-specific secondary files
modrinth-files-secondary: build/libs/*-@(dev\|sources\|javadoc).jar
# Modrinth-specific dependencies
# It is possible to use project ids instead of slugs
modrinth-dependencies: |
  AANobbMI | depends | *
  sodium

curseforge-id: 0
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
# CurseForge-specific name for your mod
curseforge-name: CurseForge Mod
# CurseForge-specific secondary files
curseforge-files-secondary: ""
# CurseForge-specific dependencies
# It is not possible to use project ids instead of slugs
curseforge-dependencies: |
  sodium | depends | *

modrinth-id

The ID of the Modrinth project to upload to.

modrinth-id: AANobbMI

Can be automatically retrieved from the config file of your mod:

  • fabric.mod.json (Fabric)

    • Custom mc-publish field (recommended):

      {
        // ...
        "custom": {
          "mc-publish": {
            "modrinth": "AANobbMI"
          }
        },
      }
    • Custom modmanager field (recommended):

      {
        // ...
        "custom": {
          "modmanager": {
            "modrinth": "AANobbMI"
          }
        },
      }
    • Custom projects field:

      {
        // ...
        "custom": {
          "projects": {
            "modrinth": "AANobbMI"
          }
        },
      }
    • projects field:

      {
        // ...
        "projects": {
          "modrinth": "AANobbMI"
        },
      }
  • mods.toml (Forge)

    • Custom mc-publish field (recommended):

      [custom.mc-publish]
          modrinth="AANobbMI"
    • Custom projects field:

      [custom.projects]
          modrinth="AANobbMI"
    • projects field:

      [projects]
          modrinth="AANobbMI"
  • quilt.mod.json (Quilt)

    • mc-publish field (recommended):

      {
        // ...
        "mc-publish": {
          "modrinth": "AANobbMI"
        },
      }
    • projects field:

      {
        // ...
        "projects": {
          "modrinth": "AANobbMI"
        },
      }

modrinth-token

A valid token for the Modrinth API. It's required if you want to publish your assets to Modrinth.

modrinth-token: ${{ secrets.MODRINTH_TOKEN }}

modrinth-featured

Indicates whether the version should be featured on Modrinth or not.

modrinth-featured: true

modrinth-unfeature-mode

Determines the way automatic unfeaturing of older Modrinth versions works. Default value is subset, if modrinth-featured is set to true; otherwise, none.

modrinth-unfeature-mode: version-intersection | loader-subset

Available presets:

  • none - no Modrinth versions will be unfeatured
  • subset - only those Modrinth versions which are considered a subset of the new one (i.e., new release suports all of the version's mod loaders and game versions) will be unfeatured
  • intersection - only those Modrinth versions which intersects with the new one (i.e., support at least one of the mod loaders and one of the game versions supported by the new release) will be unfeatured
  • any - all Modrinth versions will be unfeatured

If none of the given presets suits your needs, you can construct a new one from the following values via bitwise OR, like so - version-intersection | loaders-subset:

  • version-subset
  • version-intersection
  • version-any
  • loader-subset
  • loader-intersection
  • loader-any

curseforge-id

The ID of the CurseForge project to upload to.

curseforge-id: 394468

Can be automatically retrieved from the config file of your mod:

  • fabric.mod.json (Fabric)

    • Custom mc-publish field (recommended):

      {
        // ...
        "custom": {
          "mc-publish": {
            "curseforge": 394468
          }
        },
      }
    • Custom modmanager field (recommended):

      {
        // ...
        "custom": {
          "modmanager": {
            "curseforge": 394468
          }
        },
      }
    • Custom projects field:

      {
        // ...
        "custom": {
          "projects": {
            "curseforge": 394468
          }
        },
      }
    • projects field:

      {
        // ...
        "projects": {
          "curseforge": 394468
        },
      }
  • mods.toml (Forge)

    • Custom mc-publish field (recommended):

      [custom.mc-publish]
          curseforge=394468
    • Custom projects field:

      [custom.projects]
          curseforge=394468
    • projects field:

      [projects]
          curseforge=394468
  • quilt.mod.json (Quilt)

    • mc-publish field (recommended):

      {
        // ...
        "mc-publish": {
          "curseforge": 394468
        },
      }
    • projects field:

      {
        // ...
        "projects": {
          "curseforge": 394468
        },
      }

curseforge-token

A valid token for the CurseForge API. It's required if you want to publish your assets to CurseForge.

curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

github-tag

The tag name of the release to upload assets to. If no value is provided, a tag of the release that triggered the action will be used, if any; otherwise it will be inferred from the GITHUB_REF environment variable.

github-tag: mc1.17.1-0.3.2

github-generate-changelog

Indicates whether to automatically generate the changelog for this release. If changelog is specified, it will be pre-pended to the automatically generated notes. Unused if the GitHub Release already exists. Default value is true, if changelog and changelog-file are not provided; otherwise, false. πŸ›ˆ

github-generate-changelog: false

github-draft

true to create a draft (unpublished) release, false to create a published one. Unused if the GitHub Release already exists. Default value is false. πŸ›ˆ

github-draft: false

github-prerelease

true to identify the release as a prerelease, false to identify the release as a full release. Unused if the GitHub Release already exists. Default value is false, if version-type is release; otherwise, true. πŸ›ˆ

github-prerelease: true

github-commitish

Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default value is the repository's default branch. πŸ›ˆ

github-commitish: 347040cd637363613e56a6b333f09eaa5be3a196

github-discussion

If specified, a discussion of the specified category is created and linked to the release. Unused if the GitHub Release already exists. πŸ›ˆ

github-discussion: Announcements

github-token

A valid token for the GitHub API. It's required if you want to publish your assets to GitHub.

github-token: ${{ secrets.GITHUB_TOKEN }}

files

A glob of the file(s) to upload. If you want to publish multiple files, it's recommended to use files-primary and files-secondary instead.

files: build/libs/*.jar

files-primary

A glob of the primary files to upload. Default value is build/libs/!(*-@(dev|sources|javadoc)).jar.

files-primary: build/libs/!(*-@(dev|sources|javadoc)).jar

files-secondary

A glob of the secondary files to upload. Default value is build/libs/*-@(dev|sources|javadocs).jar.

files-secondary: build/libs/*-@(dev|sources|javadoc).jar

name

The name of the version. If no value is provided, a title of the release that triggered the action will be used. If you want Modrinth and CurseForge to determine the version name themselves, omit the field with an empty string ("").

name: Sodium 0.3.2 for Minecraft 1.17.1

version

The version number. If no value is provided, a tag of the release that triggered the action is used.

version: mc1.17.1-0.3.2

version-type

The type of the release. If no value is provided, it will be parsed from the version value (e.g., 0.40.0+1.17-alpha results in alpha).

version-type: release

changelog

The changelog for this version. If no value is provided, a body of the release that triggered the action will be used.

changelog: This release fixes a few more issues in Sodium 0.3 for Minecraft 1.17.1.

changelog-file

A glob of the changelog file.

changelog-file: CHANGELOG.md

loaders

A list of supported mod loaders. If no value is provided, fabric will be used for valid Fabric mods, forge will be used for valid Forge mods, quilt will be used for valid Quilt mods, and fabric, quilt will be used for Fabric mods that were marked as Quilt-compatible.

Fabric mods can be marked as Quilt-compatible like so:

  • fabric.mod.json

    {
      // ...
      "custom": {
        "mc-publish": {
          "quilt": true
        }
      },
    }

loaders: |
  fabric
  forge
  quilt

game-versions

A list of supported Minecraft versions. If no value is provided, the minimum supported version will be retrieved from the configuration file of your mod, if any, otherwise it will be parsed from the version value (e.g., 0.40.0+1.17 results in 1.17), and then it will be expanded using the specified version-resolver.

game-versions: |
  1.16.5
  1.17
  1.17.1
  21w37a

version-resolver

Determines the way automatic game-versions resolvement works. Default value is releasesIfAny.

version-resolver: latest

Available values:

  • exact - exact game version (1.16 -> 1.16)
  • latest - the latest release of the given minor (1.16 -> 1.16.5)
  • all - all versions of the given minor starting with the specified build (1.16.5 -> [20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 1.16.5-rc1, 1.16.5])
  • releases - all releases of the given minor starting with the specified build (1.16.3 -> [1.16.3, 1.16.4, 1.16.5])
  • releasesIfAny - all releases of the given minor starting with the specified build, if any; otherwise, all versions

dependencies

A list of dependencies.

dependencies: |
  required-dependency | depends | *
  required-dependency | depends
  required-dependency
  optional-dependency | recommends | 0.1.0
  suggested-dependency | suggests | 0.2.0
  included-dependency | includes | 0.3.0
  conflicting-dependency | conflicts | *
  incompatible-dependency | breaks | *

As you can see, each dependency should be written on a new line using the following format - {id} | {kind=depends} | {version=*}.

Available dependency kinds:

  • depends - for dependencies required to run. Without them a game will crash.
  • recommends - for dependencies not required to run. Without them a game will log a warning.
  • suggests - for dependencies not required to run. Can be used as a kind of metadata.
  • includes - for dependencies embedded into the mod. Can be used as a kind of metadata.
  • conflicts - for mods whose together with yours cause some kind of bugs, etc. With them a game will log a warning.
  • breaks - for mods whose together with yours might cause a game crash. With them a game will crash.

Can be automatically retrieved from the config file of your mod:

  • fabric.mod.json (Fabric)

    "depends": {
      "required-dependency": "*"
    },
    "recommends": {
      "optional-dependency": "0.1.0"
    },
    "suggests": {
      "suggested-dependency": "0.2.0"
    },
    "includes": {
      // Check if your version of the Fabric loader supports objects in dependency declarations.
      "included-dependency": {
        "version": "0.3.0",
        "custom": {
          "mc-publish": {
            "ignore": false, // `mc-publish` will ignore this dependency, if `ignore` is set to true
            "modrinth": "included-dependency-fabric", // Modrinth's project slug
            "curseforge": "included-dependency-fabric" // CurseForge's project slug
          }
        }
      }
    },
    "conflicts": {
      "conflicting-dependency": "*"
    },
    "breaks": {
      "incompatible-dependency": "*"
    },
  • mods.toml (Forge)

    [[dependencies.mod-id]]
      modId="required-dependency"
      mandatory=true
      versionRange="*"
      ordering="NONE"
      side="BOTH"
    
    [[dependencies.mod-id]]
      modId="optional-dependency"
      mandatory=false
      versionRange="0.1.0"
      ordering="NONE"
      side="BOTH"
    
    [[dependencies.mod-id]]
      modId="included-dependency"
      mandatory=false
      embedded=true
      versionRange="0.3.0"
      ordering="NONE"
      side="BOTH"
      [dependencies.mod-id.custom.mc-publish]
          ignore=false # `mc-publish` will ignore this dependency, if `ignore` is set to true
          modrinth="included-dependency-forge" # Modrinth's project slug
          curseforge="included-dependency-forge" # CurseForge's project slug
    
    [[dependencies.mod-id]]
      modId="incompatible-dependency"
      mandatory=false
      incompatible=true
      versionRange="*"
      ordering="NONE"
      side="BOTH"
  • quilt.mod.json (Quilt)

    "depends": [
      "required-dependency",
      {
        "id": "optional-dependency",
        "version": "0.1.0",
        "optional": true
      }
    ],
    "provides": [
      {
        "id": "included-dependency",
        "version": "0.3.0",
        "mc-publish": {
          "ignore": false, // `mc-publish` will ignore this dependency, if `ignore` is set to true
          "modrinth": "included-dependency-fabric", // Modrinth's project slug
          "curseforge": "included-dependency-fabric" // CurseForge's project slug
        }
      }
    ],
    "breaks": [
      {
        "id": "incompatible-dependency",
        "version": "*"
      },
      {
        "id": "conflicting-dependency",
        "version": "*",
        "unless": "some-mod-that-fixes-conflict"
      }
    ],

java

A list of supported Java versions. It's omitted by default.

java: |
  8
  16
  Java 17

retry-attempts

The maximum number of attempts to publish assets.

retry-attempts: 2

retry-delay

Time delay between attempts to publish assets (in milliseconds).

retry-delay: 10000

fail-mode

Determines how errors that occur during mod publishing process are handled. Default value is fail.

fail-mode: fail

Available values:

  • fail - immediately sets the action status to failed and terminates its execution
  • warn - warns about errors. The action won't be terminated, nor its status will be set to failed
  • skip - warns about errors. The action won't be terminated, but its status will be set to failed after all specified targets have been processed

About

GitHub Action that helps you publish your Minecraft plugins everywhere

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

  • TypeScript 100.0%