Skip to content

Build

Build #100

Workflow file for this run

name: Build
on: [ push, pull_request ]
jobs:
build:
strategy:
matrix:
loader: [ 'forge', 'neoforge', 'fabric' ]
java: [ 21 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: ${{ matrix.java }}
- name: Set up swap space
if: runner.os == 'Linux'
uses: pierotofy/[email protected]
with:
swap-size-gb: 10
- name: Build with ${{ matrix.loader }}
run: |
cd ${{ matrix.loader }}
chmod +x ./gradlew
./gradlew build
- name: Upload ${{ matrix.loader }} build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.loader }}-artifact
path: ${{ matrix.loader }}/build/libs
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download forge artifact
uses: actions/download-artifact@v4
with:
name: forge-artifact
- name: Download fabric artifact
uses: actions/download-artifact@v4
with:
name: fabric-artifact
- name: Download neoforge artifact
uses: actions/download-artifact@v4
with:
name: neoforge-artifact
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
*.jar
publish:
runs-on: ubuntu-latest
needs: release
permissions:
contents: write
strategy:
matrix:
loader: [ 'forge', 'neoforge', 'fabric' ]
steps:
- name: checkout repository for data
uses: actions/checkout@v4
with:
path: 'repo'
- name: Set variables that required to publish
id: variables
uses: actions/github-script@v7
with:
script: |
const fs = require("fs");
const loader = '${{ matrix.loader }}';
const propFile = fs.readFileSync("repo/config.properties", { encoding: "UTF-8", flag: "r" });
const prop = propFile
.split(/\r|\n/)
.map((s) => { s = s.trim(); return s.startsWith("#") ? "" : s; })
.filter(s => s !== '')
.reduce((a, c) => { let [k, v] = c.split("=").map(s => s.trim()); return { ...a, [k]: v }; }, {});
core.setOutput('capital_loader', loader.charAt(0).toUpperCase() + loader.slice(1));
core.setOutput('full_version', `${prop.mod_version}+${loader}-${prop.minecraft_version}`);
for (const [key, value] of Object.entries(prop)) {
core.setOutput(`prop_${key}`, value);
}
- name: Download ${{ matrix.loader }} artifact
uses: actions/download-artifact@v4
with:
path: ${{ matrix.loader }}
name: ${{ matrix.loader }}-artifact
- name: Upload ${{ matrix.loader }} version to CurseForge and Modrinth
uses: Kir-Antipov/mc-publish@995edadc13559a8b28d0b7e6571229f067ec7659
with:
modrinth-id: vAYtksKy
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: 644324
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
files: ${{ matrix.loader }}/!(*-@(dev|sources|javadoc)).jar
name: '[${{ steps.variables.outputs.capital_loader }} ${{ steps.variables.outputs.prop_minecraft_version }}] ${{ steps.variables.outputs.prop_mod_version }}'
version: ${{ steps.variables.outputs.full_version }}
game-versions: ${{ steps.variables.outputs.prop_minecraft_version }}
loaders: ${{ matrix.loader }}