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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 18 additions & 68 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,28 @@
name: Gradle CI (new)
name: Build Mod Without Local JDK

on:
push:
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
- '.editorconfig'
- 'changelog.md'
- 'docs'
pull_request:
on: [push, workflow_dispatch]

jobs:
generate-build-matrix:
runs-on: ubuntu-latest
name: Generate build matrix

outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get potential versions
id: generate-matrix
run: |
MATRIX=$(jq -c '{include: (.branches[""] | map({target: ., experimental: (test("exp"))}))}' ./versions/versions.json)
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT

build:
needs: generate-build-matrix
runs-on: ubuntu-latest
name: Build with gradle

strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-build-matrix.outputs.matrix) }}

continue-on-error: ${{ matrix.experimental == 'true' }}

steps:
- uses: actions/checkout@v4
- name: Set up JDK
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 25
distribution: temurin
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Overwrite current version
run: printf "%s" "${{ matrix.target }}" | cut -d':' -f1 | tr -d '\n' > ./versions/current
- name: Build ${{ matrix.target }}
run: |
./gradlew "Refresh active project"
./gradlew buildAndCollectActive --stacktrace
env:
CI_SINGLE_BUILD: ${{ matrix.target }}
distribution: 'temurin'
java-version: '21' # Change to 17 or 8 depending on the Minecraft version

- name: Sanitize artifact name
run: |
raw="${{ matrix.target }}"
clean="${raw%%:*}"
echo "ARTIFACT_NAME=$clean" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
path: build/finalJars/*.jar
name: ${{ env.ARTIFACT_NAME }}
- name: Make Gradle Executable
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build

# run:
# needs: build
# runs-on: ubuntu-latest
# name: Run Minecraft
#
# strategy:
# matrix:
# target: ${{ fromJson(needs.retrieve-targets.outputs.targets) }}
- name: Upload Mod Jar
uses: actions/upload-artifact@v4
with:
name: compiled-mod
path: build/libs/*.jar
44 changes: 44 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Package

on:
release:
types: [created]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Build with Gradle
run: ./gradlew build

# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
run: ./gradlew publish
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path

name: Maven Package

on:
release:
types: [created]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}