From fccdd8c514d923b1e6176295ea0ea40836879df9 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 16 May 2026 10:42:21 -0700 Subject: [PATCH] Add Modrinth publish workflow Mirrors the Level addon workflow: builds with the master profile to produce a non-SNAPSHOT jar named StrangerRealms-{version}.jar, then uploads to Modrinth via cloudnode-pro/modrinth-publish@v2. Triggers on GitHub Release publish, plus a manual workflow_dispatch for re-runs. Requires repo secrets MODRINTH_TOKEN (PAT with "Create versions" scope) and MODRINTH_PROJECT_ID. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/modrinth-publish.yml | 99 ++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .github/workflows/modrinth-publish.yml diff --git a/.github/workflows/modrinth-publish.yml b/.github/workflows/modrinth-publish.yml new file mode 100644 index 0000000..f14a789 --- /dev/null +++ b/.github/workflows/modrinth-publish.yml @@ -0,0 +1,99 @@ +name: Publish to Modrinth + +# Triggers when you publish a GitHub Release +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: 'Release tag to publish (e.g. 1.0.4)' + required: true + type: string + changelog: + description: 'Changelog / release notes (markdown)' + required: false + type: string + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + # 1. Check out the repository at the release tag + - name: Checkout repository + uses: actions/checkout@v4 + + # 2. Set up Java 21 (required by StrangerRealms' build) + - name: Set up Java 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + # 3. Cache Maven dependencies to speed up builds + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + # 4. Build the JAR + # GIT_BRANCH=origin/master activates the master profile in pom.xml, + # which sets revision=${build.version} (no -SNAPSHOT suffix) and + # clears build.number, producing StrangerRealms-{version}.jar. + - name: Build with Maven + run: mvn -B package --no-transfer-progress + env: + GIT_BRANCH: origin/master + + # 5. Upload the JAR to Modrinth + # + # Prerequisites — add these secrets in your GitHub repo settings + # (Settings → Secrets and variables → Actions): + # + # MODRINTH_TOKEN — personal access token from https://modrinth.com/settings/pats + # (scope: "Create versions") + # MODRINTH_PROJECT_ID — your Modrinth project ID, visible on your project page + # under the three-dot menu ("Copy ID") + # + - name: Publish to Modrinth + uses: cloudnode-pro/modrinth-publish@v2 + with: + token: ${{ secrets.MODRINTH_TOKEN }} + project: ${{ secrets.MODRINTH_PROJECT_ID }} + + # Use the release tag, or the manually supplied tag when triggered via workflow_dispatch + version: ${{ github.event.release.tag_name || inputs.tag }} + + # Use the GitHub release body, or the manually supplied changelog for workflow_dispatch + changelog: ${{ github.event.release.body || inputs.changelog }} + + # Release channel — auto-detected from version string: + # *-alpha → alpha, *-beta → beta, anything else → release + # Override here if needed: release | beta | alpha + # channel: release + + # StrangerRealms is a BentoBox game mode add-on running on Paper/Purpur + loaders: |- + paper + purpur + + # Minecraft versions this release supports. + # Update this list when you start supporting newer or older MC versions. + game-versions: |- + 1.21.5 + 1.21.6 + 1.21.7 + 1.21.8 + 1.21.9 + 1.21.10 + 1.21.11 + 26.1 + 26.1.1 + + # Path to the built JAR — Maven produces StrangerRealms-{version}.jar in target/ + files: target/StrangerRealms-${{ github.event.release.tag_name || inputs.tag }}.jar