Skip to content

Instantly share code, notes, and snippets.

@ybw0014
Last active June 9, 2024 19:27
Show Gist options
  • Save ybw0014/55fb2fb2ef39a906255d35ceeff4662b to your computer and use it in GitHub Desktop.
Save ybw0014/55fb2fb2ef39a906255d35ceeff4662b to your computer and use it in GitHub Desktop.
How to compile a Slimefun addon on GitHub

This guide introduces how you compile a Slimefun addon on GitHub, without the need to install anything extra on your computer.

You will need to have:

  • A modern browser.
  • A good internet connection.
  • A GitHub account (click here to sign up if you don't have one yet)

Introduction

Most open-source Slimefun addons are hosted on GitHub.
With GitHub Actions, you can compile the addon online, and download the build artifacts.

In this guide, we will use SlimeTinker as example.

Step 1. Find and fork the repository

  1. In the official wiki's addon list (link), you can find the "Source code" column.
    Find the addon you want to compile, and click on the corresponding "Source code" to open the addon's github repository.
    For SlimeTinker, you should be at this page:
https://github.com/Sefiraat/SlimeTinker
  1. Next, click on image. You will be redirected to "Create a new fork" page.
    Just keep everything default, and click on the green "Create fork" button.

Step 2. Create a github action file

  1. Before doing this step, you need to identify the project type of the addon.

If you can see a pom.xml in the root of the project, it is a maven project.
If you can see a build.gradle or build.gradle.kts in the root of the project, it is a gradle project.

  1. Now, click on "Add file" then "Create new file".
image

In "Name your file...", copy and paste .github/workflows/custom-fork-build.yml

Then, according to project type, find "maven.yml" or "gradle.yml" in this gist, copy and paste the content.

  1. When you finish all the things above, click on image.
    Keep everything default, click on image to finish this step.

Step 3. Run the action

  1. Navigate to image tab, you may see the following page:
image

Click on the green button to enable actions on your fork.

image
  1. You should be able to find an action called "Custom Fork Build". Click on it, and you will see the following page.
image
  1. Click on "Run workflow", make sure the branch is either master or main, then click on the green "Run workflow".
image

Wait for a few seconds, and refresh the page. You should see a new workflow run.

  1. Click on the workflow run, you can see it is still running. Be patient and wait for compile to finish.
image

Important

If the compile fails, you may need to have some extra efforts on fixing the build.

Ask in Slimefun discord and provide the fork repository link. DO NOT just say I am having issues compiling the addon and not providing anything useful.

  1. When the compiling is finished, you will be able to see the artifacts. Click on the artifact name to download.
image

Note that, the downloaded file is a zip, and the addon jar should be within the zip file.

If it is a Maven project, there will be usually a file named "-UNOFFICIAL.jar" or "-MODIFIED.jar", this is the jar file you need. The other files, that their name may start with "original-" or ends with "sources", "javadocs", should be ignored.

If it is a Gradle project, according to different build script setup, you may see 1-2 files. Usually, if there are 2 files, the one ends with "-all" is what you need.

Anyways, if you get confused within this part, ask for help in discord, and BE PATIENT.

Note

You may get help about how to get a custom build.
But if you have issues with the content of custom build, DO NOT report them, as you are using a not supported version.

name: Custom Fork Build
on:
workflow_dispatch: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Build with Gradle
uses: gradle/gradle-build-action@v3
with:
arguments: build shadowJar
- name: Get build artifact ready
run: mkdir staging && cp build/libs/*.jar staging
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: Custom Fork Build
path: staging
name: Custom Fork Build
on:
workflow_dispatch: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Build
run: mvn package --file pom.xml
- name: Get build artifact ready
run: mkdir staging && cp target/*.jar staging
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: Custom Fork Build
path: staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment