Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Faboslav committed Sep 19, 2024
2 parents 74d2693 + f5e03de commit e422283
Show file tree
Hide file tree
Showing 144 changed files with 657 additions and 492 deletions.
37 changes: 37 additions & 0 deletions .github/scripts/generate-publish-matrix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

allowed_mod_loaders=$1
curseforge_fabric_project_id=$2
curseforge_forge_project_id=$3
modrinth_fabric_project_id=$4
modrinth_forge_project_id=$5

IFS=',' read -r -a allowed_mod_loaders_array <<< "${allowed_mod_loaders//[\[\]\']/}"
matrix_content="{\"include\":["
enabled_platforms=$(awk -F= '/enabled_platforms/{print $2}' gradle.properties | tr -d ' ')
minecraft_version=$(awk -F= '/minecraft_version/{print $2; exit}' gradle.properties | tr -d ' ')

for platform in $(echo $enabled_platforms | tr ',' ' '); do
if [[ " ${allowed_mod_loaders_array[@]} " =~ " ${platform} " ]]; then
if [[ "$platform" == "fabric" ]]; then
supported_mod_loaders="\"fabric\",\"quilt\""
else
supported_mod_loaders="\"$platform\""
fi

if [[ "$platform" == "fabric" ]]; then
curseforge_project_id="$curseforge_fabric_project_id"
modrinth_project_id="$modrinth_fabric_project_id"
else
curseforge_project_id="$curseforge_forge_project_id"
modrinth_project_id="$modrinth_forge_project_id"
fi

matrix_entry="{\"mod_loader\":\"$platform\",\"minecraft_version\":\"$minecraft_version\",\"supported_mod_loaders\":[$supported_mod_loaders],\"curseforge_project_id\":\"$curseforge_project_id\",\"modrinth_project_id\":\"$modrinth_project_id\"},"
matrix_content+="$matrix_entry"
fi
done

matrix_content="${matrix_content%,}]}"
echo "Generated matrix: $matrix_content"
echo "::set-output name=matrix::$matrix_content"
10 changes: 7 additions & 3 deletions .github/scripts/generate-run-matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ enabled_platforms=$(awk -F= '/enabled_platforms/{print $2}' gradle.properties |
version=$(awk -F= '/minecraft_version/{print $2; exit}' gradle.properties | tr -d ' ')

for platform in $(echo $enabled_platforms | tr ',' ' '); do
matrix_entry="{\"mod_loader\":\"$platform\",\"version\":\"$version\",\"script\":\"client\"},"
matrix_content+="$matrix_entry"
matrix_entry="{\"mod_loader\":\"$platform\",\"version\":\"$version\",\"script\":\"server\"},"
if [[ "$platform" == "forge" ]]; then
mod_loader_alias="lexforge"
else
mod_loader_alias="$platform"
fi

matrix_entry="{\"mod_loader\":\"$platform\",\"mod_loader_alias\":\"$mod_loader_alias\",\"version\":\"$version\"},"
matrix_content+="$matrix_entry"
done

Expand Down
10 changes: 10 additions & 0 deletions .github/scripts/parse-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

tag=$1

changelog=$(cat CHANGELOG.md)

list=$(echo "$changelog" | sed -n "/^## $tag/,/^## [0-9]/p" | sed -e '1d;$d' -e '/^$/d')

echo "Parsed changelog:\n$list"
echo "$list" > RELEASE_CHANGELOG.md
28 changes: 28 additions & 0 deletions .github/scripts/parse-gradle-properties.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

parse_properties_file() {
local file=$1
while IFS='=' read -r key value; do
# Trim leading/trailing whitespace from key and value
key=$(echo "$key" | awk '{$1=$1;print}')
value=$(echo "$value" | awk '{$1=$1;print}')

# Skip comments, empty keys, and unwanted keys like "org.gradle.jvmargs"
if [[ -z "$key" || "$key" =~ ^# || "$key" == "org.gradle.jvmargs" ]]; then
continue
fi

# Convert key to uppercase and replace non-alphanumeric characters with underscores
key=$(echo "$key" | tr '[:lower:]' '[:upper:]' | tr -c '[:alnum:]' '_')

# Remove any trailing underscores
key=$(echo "$key" | sed 's/_$//')

# Output the key-value pair
echo "${key}=${value}"
echo "${key}=${value}" >> "$GITHUB_OUTPUT"
done < "$file"
}

# Parse the main gradle.properties file
parse_properties_file gradle.properties
33 changes: 0 additions & 33 deletions .github/scripts/run-client.sh

This file was deleted.

35 changes: 0 additions & 35 deletions .github/scripts/run-server.sh

This file was deleted.

78 changes: 33 additions & 45 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
name: "Build project"
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 10
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

Expand All @@ -25,26 +25,18 @@ jobs:

- name: "Parse gradle properties"
id: gradle-properties
run: |
while IFS='=' read -r key value; do
key=$(echo $key | awk '{$1=$1;print}')
value=$(echo $value | awk '{$1=$1;print}')
case "$key" in
mod_java_version) echo "JAVA_VERSION=$value" >> $GITHUB_OUTPUT ;;
minecraft_version) echo "MINECRAFT_VERSION=$value" >> $GITHUB_OUTPUT ;;
mod_name) echo "MOD_NAME=$value" >> $GITHUB_OUTPUT ;;
mod_version) echo "MOD_VERSION=$value" >> $GITHUB_OUTPUT ;;
enabled_platforms) echo "ENABLED_PLATFORMS=$value" >> $GITHUB_OUTPUT ;;
esac
done < gradle.properties
run: ./.github/scripts/parse-gradle-properties.sh

- name: "Set up JDK"
uses: actions/setup-java@v4
with:
java-version: ${{ steps.gradle-properties.outputs.JAVA_VERSION }}
java-version: ${{ steps.gradle-properties.outputs.MOD_JAVA_VERSION }}
distribution: temurin

- name: "Generate matrix for the run job"
id: set-matrix
run: ./.github/scripts/generate-run-matrix.sh

- name: "Run gradle build"
uses: gradle/actions/setup-gradle@v3
with:
Expand All @@ -53,9 +45,13 @@ jobs:
gradle-version: wrapper
arguments: build

- name: "Generate matrix for the run job"
id: set-matrix
run: ./.github/scripts/generate-run-matrix.sh
- name: "Upload Built JARs"
uses: actions/upload-artifact@v4
with:
name: built-jars
if-no-files-found: error
path: |
./**/build/libs/*[0-9].jar
run:
name: Run ${{ matrix.mod_loader }} ${{ matrix.script }}
Expand All @@ -72,35 +68,27 @@ jobs:
with:
fetch-depth: 0

- name: "Parse gradle properties"
id: gradle-properties
run: |
while IFS='=' read -r key value; do
key=$(echo $key | awk '{$1=$1;print}')
value=$(echo $value | awk '{$1=$1;print}')
case "$key" in
mod_java_version) echo "JAVA_VERSION=$value" >> $GITHUB_OUTPUT ;;
esac
done < gradle.properties
- name: "Set up JDK"
uses: actions/setup-java@v4
- name: "Download Built JARs"
uses: actions/download-artifact@v4
with:
java-version: ${{ steps.gradle-properties.outputs.JAVA_VERSION }}
distribution: temurin
name: built-jars

- name: "Setup Gradle"
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: true
gradle-version: wrapper
- name: "Parse gradle properties"
id: gradle-properties
run: ./.github/scripts/parse-gradle-properties.sh

- name: "Accept eula"
run: mkdir -p ${{ matrix.mod_loader }}/run && echo "eula=true" > ${{ matrix.mod_loader }}/run/eula.txt
- name: "Copy mod jar to run/mods"
run: mkdir -p run/mods && cp ${{ matrix.mod_loader }}/build/libs/* run/mods

- name: Run ${{ matrix.mod_loader }} ${{ matrix.script }}
uses: modmuss50/xvfb-action@v1
- name: Run ${{ matrix.version }} ${{ matrix.mod_loader }}
uses: 3arthqu4ke/[email protected]
with:
run: ./.github/scripts/run-${{ matrix.script }}.sh ${{ matrix.mod_loader }}
shell: bash
mc: ${{ matrix.version }}
modloader: ${{ matrix.mod_loader }}
regex: .*${{ matrix.mod_loader }}.*
mc-runtime-test: ${{ matrix.mod_loader_alias }}
java: ${{ steps.gradle-properties.outputs.MOD_JAVA_VERSION }}
java-distribution: temurin
fabric-api: ${{ steps.gradle-properties.outputs.FABRIC_API_VERSION }}
xvfb: false
headlessmc-command: -lwjgl --retries 3 --jvm -Djava.awt.headless=true
Loading

0 comments on commit e422283

Please sign in to comment.