Skip to content

Build Plugin and Mod #115

Build Plugin and Mod

Build Plugin and Mod #115

Workflow file for this run

name: Build Plugin and Mod
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
JAVA_8_LIST: '["forge-1.16.5","fabric-1.16.5"]'
JAVA_17_LIST: '["fabric-1.18.2","fabric-1.19.2","fabric-1.20.1","forge-1.18.2","forge-1.19.2","forge-1.20.1"]'
JAVA_21_LIST: '["fabric-1.20.4","fabric-1.21","fabric-1.21.1","forge-1.21","neoforge-1.21.1"]'
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Generate Matrix
id: set-matrix
run: chmod 777 matrix.sh && ./matrix.sh -path "fabric","forge","spigot","velocity","minecraft","neoforge"
build:
runs-on: ubuntu-latest
needs:
- generate-matrix
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Chose JDK 8
uses: actions/setup-java@v4
if: contains(env.JAVA_8_LIST, format('{0}-{1}', matrix.config.mc-loader,matrix.config.mc-version))
with:
java-version: '8'
distribution: 'temurin'
- name: Chose JDK 17
uses: actions/setup-java@v4
if: contains(env.JAVA_17_LIST, format('{0}-{1}', matrix.config.mc-loader,matrix.config.mc-version))
with:
java-version: '17'
distribution: 'temurin'
- name: Chose JDK 21
uses: actions/setup-java@v4
if: contains(env.JAVA_21_LIST, format('{0}-{1}', matrix.config.mc-loader,matrix.config.mc-version))
with:
java-version: '21'
distribution: 'temurin'
- name: Read version.txt and save to variable
run: |
mod_version=$(cat version.txt)
echo "Version: $mod_version"
echo "MOD_VERSION=$mod_version" >> "$GITHUB_ENV"
- name: Init Files
run: chmod 777 init.sh && ./init.sh
- name: Build Mod
env:
USERNAME: ${{ github.actor }}
PACKAGE_READ_ONLY_TOKEN: ${{ secrets.PACKAGE_READ_ONLY_TOKEN }}
run: |
cd ${{ matrix.config.mc-loader }}/${{ matrix.config.mc-loader }}-${{ matrix.config.mc-version }}
chmod 777 gradlew
./gradlew clean build
cd ../..
- name: Set Version Type
id: set-version-type
run: |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
echo "VERSION_TYPE=release" >> $GITHUB_ENV
else
echo "VERSION_TYPE=beta" >> $GITHUB_ENV
fi
- name: Set Game Version
id: set-game-version
run: |
if [ "${{ matrix.config.mc-loader }}" == "velocity" ]; then
echo "game_version=1.20.1" >> $GITHUB_ENV
else
echo "game_version=${{ matrix.config.mc-version }}" >> $GITHUB_ENV
fi
- uses: actions/upload-artifact@v4
with:
name: QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}.jar
path: QueQiao-jar/${{ env.MOD_VERSION }}/QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}.jar
- uses: Kir-Antipov/[email protected]
if: ${{ github.event_name == 'push' && matrix.config.mc-loader != 'minecraft' }}
with:
modrinth-id: rVJvtYoX
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: 1084495
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
name: QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}
version: ${{ env.MOD_VERSION }}
version-type: ${{ env.VERSION_TYPE }}
loaders: ${{ matrix.config.mc-loader }}
game-versions: ${{ env.game_version }}
files: QueQiao-jar/${{ env.MOD_VERSION }}/QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}.jar
- name: Upload to Release
if: ${{ github.event_name == 'push' && matrix.config.mc-loader == 'minecraft' }}
run: gh release upload v${{ env.MOD_VERSION }} QueQiao-jar/${{ env.MOD_VERSION }}/QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}.jar