Skip to main content

Overview

The GitHub platform integration allows you to automatically publish your Minecraft artifacts to GitHub Releases. This is useful for distributing your plugins, mods, or other artifacts directly through your GitHub repository. MCReleaser will create a new release with the specified tag, or update an existing release if it already exists. All files in your artifact bundle will be uploaded as release assets.

Required Credentials

To publish to GitHub, you need:
  1. GitHub Token: A personal access token or GitHub Actions token with contents: write permission
  2. Repository: The full repository name in the format owner/repo
  3. Git Ref: The tag reference to create the release for (e.g., refs/tags/v1.0.0)
When using GitHub Actions, the GITHUB_TOKEN is automatically available and the repository and ref are set via default environment variables.

Configuration Options

GITHUB_TOKEN
string
required
The GitHub token to authenticate API requests. This must have contents: write permission to create releases and upload assets.In GitHub Actions, use the built-in GITHUB_TOKEN secret:
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY
string
required
The full repository name in owner/repository format.Example: HSGamer/BetterEconomyIn GitHub Actions, this is automatically set to ${{ github.repository }}.
GITHUB_REF
string
required
The Git reference to create the release for. Typically a tag reference like refs/tags/v1.0.0.MCReleaser will automatically extract the version from the tag (removing the refs/tags/ prefix).In GitHub Actions, this is automatically set to ${{ github.ref }}.
GITHUB_DRAFT
boolean
default:"false"
Whether to create the release as a draft. Draft releases are not visible to the public until published.Set to true to create a draft release:
-e GITHUB_DRAFT="true"
GITHUB_PRERELEASE
boolean
default:"false"
Whether to mark the release as a pre-release. Pre-releases are typically used for beta or alpha versions.Set to true to mark as pre-release:
-e GITHUB_PRERELEASE="true"

Implementation Details

The GitHub platform implementation performs the following steps:
  1. Authentication: Creates a GitHub API client using the provided OAuth token
  2. Repository Access: Retrieves the specified repository
  3. Release Creation: Checks if a release with the specified tag exists:
    • If it exists, uses the existing release
    • If not, creates a new release with the specified draft/prerelease settings
  4. Asset Upload: Uploads all files from the artifact bundle as release assets
If the release already exists, MCReleaser will not update its properties (draft, prerelease, description). It will only upload new assets.

Complete Example

java \
  -Dname="BetterEconomy" \
  -Dversion="1.0.0" \
  -Ddescription="A major update with new features" \
  -DgithubToken="ghp_your_token_here" \
  -DgithubRepository="HSGamer/BetterEconomy" \
  -DgithubRef="refs/tags/v1.0.0" \
  -DgithubDraft="false" \
  -DgithubPrerelease="false" \
  -jar mcreleaser.jar

Source Code Reference

The GitHub platform implementation can be found in:
  • Platform logic: github/src/main/java/me/hsgamer/mcreleaser/github/GithubPlatform.java
  • Configuration keys: github/src/main/java/me/hsgamer/mcreleaser/github/GithubPropertyKey.java

Key Implementation Features

// Automatic version extraction from tag reference
String version = tagReference.replace("refs/tags/", "");

// Release creation with configuration
release = repository.createRelease(GithubPropertyKey.REF.getValue())
        .draft(GithubPropertyKey.DRAFT.asBoolean(false))
        .prerelease(GithubPropertyKey.PRERELEASE.asBoolean(false))
        .name(CommonPropertyKey.NAME.getValue())
        .body(CommonPropertyKey.DESCRIPTION.getValue())
        .create();

// Upload all artifacts
for (File file : fileBundle.allFiles()) {
    release.uploadAsset(file, "application/octet-stream");
}

Build docs developers (and LLMs) love