Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ indent_size = 2
indent_style = space

[*.java]
ij_java_imports_layout = $*,|,java.**,|,javax.**,|,*,|,net.fabricmc.**,|,net.minecraft.**,|,net.rotgruengelb.**,|,*
ij_java_use_single_class_imports = true
ij_continuation_indent_size = 8
ij_java_class_count_to_use_import_on_demand = 999
Expand Down
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MODRINTH_API_TOKEN=
CURSEFORGE_API_TOKEN=
TEST_PUBLISHING_WITH_MR_STAGING=true
ENABLE_PUBLISHING=false
11 changes: 5 additions & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
* text=auto eol=lf

# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.jpg binary
*.ogg binary
*.mp3 binary
*.mp4 binary
36 changes: 2 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.

name: build
on: [pull_request, push]
on: [ push, pull_request ]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [21]
# Use these os runners
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew buildAndCollect
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
uses: ./.github/workflows/build_reusable.yml
50 changes: 50 additions & 0 deletions .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: reusable-build
on:
workflow_call:
outputs:
artifact-name:
description: "Name of the uploaded build artifact"
value: ${{ jobs.build.outputs.artifact-name }}

jobs:
build:
name: Build Project
runs-on: ubuntu-latest
outputs:
artifact-name: ${{ steps.upload.outputs.artifact-name }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'microsoft'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Build with Gradle
run: ./gradlew buildAndCollect --no-daemon

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: build/libs/
193 changes: 193 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: release

on:
push:
tags:
- '*'

permissions:
contents: write

env:
MODRINTH_API_TOKEN: ${{ secrets.MODRINTH_API_TOKEN }}
CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }}
TEST_PUBLISHING_WITH_MR_STAGING: ${{ vars.TEST_PUBLISHING_WITH_MR_STAGING }}
ENABLE_PUBLISHING: ${{ vars.ENABLE_PUBLISHING }}

jobs:
build:
uses: ./.github/workflows/build_reusable.yml

prepare:
name: Prepare Release
runs-on: ubuntu-latest
needs: build
permissions:
contents: write

outputs:
publish_github: ${{ steps.read-props.outputs.publish_github }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Prepare git-cliff
run: |
REPO_URL="https://github.com/${{ github.repository }}"
sed -i "s|%%%repo_url%%%|${REPO_URL}|g" cliff.toml

- name: Generate changelog with git-cliff
id: cliff
uses: orhun/git-cliff-action@v4
with:
args: --latest --strip header --output CHANGELOG.md
version: 'v2.10.1'

- name: Read gradle.properties values
id: read-props
run: |
VERSION=$(grep '^mod.version=' gradle.properties | cut -d'=' -f2)
CHANNEL_TAG=$(grep '^mod.channel_tag=' gradle.properties | cut -d'=' -f2)
PUBLISH_GITHUB=$(grep '^publish.github=' gradle.properties | cut -d'=' -f2 || echo "false")
FULL_VERSION="${VERSION}${CHANNEL_TAG}"

echo "mod.version=$VERSION"
echo "mod.channel_tag=$CHANNEL_TAG"
echo "Combined version=$FULL_VERSION"

echo "publish_github=$PUBLISH_GITHUB" >> "$GITHUB_OUTPUT"
echo "full_version=$FULL_VERSION" >> "$GITHUB_OUTPUT"

- name: Validate tag matches version
run: |
TAG="${GITHUB_REF_NAME}"
FULL_VERSION="${{ steps.read-props.outputs.full_version }}"

echo "Validating tag '$TAG' against version '$FULL_VERSION'..."
if [[ "$TAG" != "$FULL_VERSION" ]]; then
echo "::error::Tag '$TAG' does not match version '$FULL_VERSION' in gradle.properties."
echo "Deleting tag and release..."

if gh release view "$TAG" &>/dev/null; then
echo "Deleting GitHub release for $TAG..."
gh release delete "$TAG" -y
fi

git push origin ":refs/tags/$TAG"
exit 1
fi
echo "✓ Tag matches version."

- name: Upload changelog
uses: actions/upload-artifact@v4
with:
name: changelog
path: CHANGELOG.md

github-release:
name: Release to GitHub
runs-on: ubuntu-latest
needs: prepare
if: needs.prepare.outputs.publish_github == 'true'
permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: build/libs/

- name: Download changelog
uses: actions/download-artifact@v4
with:
name: changelog
path: .

- name: Create or update GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
echo "Creating or updating release for $TAG"
# Try to create the release first
if ! gh release create "$TAG" \
--title "$TAG" \
--notes-file CHANGELOG.md \
--latest \
--verify-tag \
./build/libs/$TAG/*; then

echo "Release already exists. Updating existing release..."

# Update release notes and mark as latest
gh release edit "$TAG" \
--title "$TAG" \
--notes-file CHANGELOG.md \
--latest

# Re-upload artifacts (delete first to avoid duplicates)
for FILE in ./build/libs/$TAG/*; do
NAME=$(basename "$FILE")
gh release delete-asset "$TAG" "$NAME" -y || true
gh release upload "$TAG" "$FILE" --clobber
done
fi


platform-release:
name: Release to Platforms
runs-on: ubuntu-latest
needs: [ prepare ]
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: build/libs/

- name: Download changelog
uses: actions/download-artifact@v4
with:
name: changelog
path: .

- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'microsoft'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Publish to Platforms
run: |
./gradlew publishMods --stacktrace
Loading
Loading