Skip to content
This repository was archived by the owner on May 10, 2026. It is now read-only.

Delete .github/scripts/validate_load_order.py #222

Delete .github/scripts/validate_load_order.py

Delete .github/scripts/validate_load_order.py #222

Workflow file for this run

name: Datapack Multi-Version Build
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# Base format + overlay pairs — each row is a target MC version
- label: "1_20_3"
pack_format: 26
overlays: "1_20_3"
- label: "1_20_5"
pack_format: 41
overlays: "1_20_5"
- label: "pre_1_21_4"
pack_format: 48
overlays: "_pre_1_21_4 compat_1_21_4"
- label: "1_21_5"
pack_format: 71
overlays: "1_21_5"
- label: "1_21_6"
pack_format: 80
overlays: "1_21_6"
- label: "full"
pack_format: 101
overlays: ""
steps:
- uses: actions/checkout@v6
# 🔒 Repo lock — prevent running from wrong fork
- name: Repo lock
run: |
if [ "$GITHUB_REPOSITORY" != "runtoolkit/macroEngine-dp" ]; then
echo "::error::This workflow may only run in runtoolkit/macroEngine-dp."
exit 1
fi
# 📁 Prepare build directory
- name: Prepare build directory
run: mkdir -p build
# 📂 Copy base layer (excluding overlay directories)
- name: Copy base layer
run: |
OVERLAY_DIRS="1_20_3 1_20_5 _pre_1_21_4 compat_1_21_4 1_21_5 1_21_6 26_1"
EXCLUDES=""
for d in $OVERLAY_DIRS; do
EXCLUDES="$EXCLUDES --exclude=$d"
done
rsync -a $EXCLUDES \
--exclude='.git' \
--exclude='.github' \
--exclude='.gitattributes' \
--exclude='.gitignore' \
--exclude='LICENSE' \
--exclude='README.md' \
./ build/
# 📂 Copy overlays
- name: Copy target overlays
run: |
ALL_OVERLAYS="1_20_3 1_20_5 _pre_1_21_4 compat_1_21_4 1_21_5 1_21_6 26_1"
TARGET="${{ matrix.overlays }}"
if [ -z "$TARGET" ]; then
# Full build: copy all overlay directories
for d in $ALL_OVERLAYS; do
[ -d "$d" ] && cp -r "$d" build/ || echo "::warning::Overlay '$d' not found, skipping."
done
else
# Targeted build: copy only the relevant overlay(s)
for overlay in $TARGET; do
if [ -d "$overlay" ]; then
cp -r "$overlay" build/
else
echo "::warning::Overlay '$overlay' not found, skipping."
fi
done
fi
# 🧩 pack.mcmeta — update pack_format, keep only relevant overlay entries
- name: Patch pack.mcmeta
run: |
LABEL="${{ matrix.label }}"
FORMAT="${{ matrix.pack_format }}"
OVERLAYS="${{ matrix.overlays }}"
# Convert overlay list to jq array (may be empty for full build)
JQ_ARRAY="[]"
for ov in $OVERLAYS; do
JQ_ARRAY=$(echo "$JQ_ARRAY" | jq --arg d "$ov" '. + [$d]')
done
jq \
--argjson fmt "$FORMAT" \
--argjson keep "$JQ_ARRAY" \
--arg label "$LABEL" \
'
.pack.pack_format = $fmt |
if .overlays.entries and $label != "full" then
.overlays.entries = [
.overlays.entries[] |
select(.directory as $d | $keep | index($d) != null)
]
else . end
' \
build/pack.mcmeta > build/pack.mcmeta.tmp
mv build/pack.mcmeta.tmp build/pack.mcmeta
# 🔍 Sanity check — is pack.mcmeta valid JSON?
- name: Validate pack.mcmeta
run: |
jq empty build/pack.mcmeta && echo "pack.mcmeta is valid JSON." \
|| { echo "::error::pack.mcmeta is malformed!"; exit 1; }
# 📦 Zip
- name: Package datapack
run: |
cd build
zip -r ../macroEngine-${{ matrix.label }}.zip .
echo "Archive size: $(du -sh ../macroEngine-${{ matrix.label }}.zip | cut -f1)"
# 🚀 Upload as artifact
- uses: actions/upload-artifact@v6
with:
name: macroEngine-${{ matrix.label }}
path: macroEngine-${{ matrix.label }}.zip
retention-days: 14
if-no-files-found: error
# ───────────────────────────────────────────────
# Release — only on main pushes, with full ZIP
# ───────────────────────────────────────────────
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- uses: actions/checkout@v6
# 🔒 Repo lock
- name: Repo lock
run: |
if [ "$GITHUB_REPOSITORY" != "runtoolkit/macroEngine-dp" ]; then
echo "::error::This workflow may only run in runtoolkit/macroEngine-dp."
exit 1
fi
# 📥 Download full ZIP from artifact
- uses: actions/download-artifact@v7
with:
name: macroEngine-full
path: dist/
# 🏷️ Read version number from pack.mcmeta
- name: Read version
id: ver
run: |
# Extract version like "v4.0.2" from the description array in pack.mcmeta
VERSION=$(jq -r '
.pack.description |
if type == "array" then
.[] | select(type == "object") |
.text // empty
else . end |
select(test("^\\s*\\|\\s*v[0-9]")) |
gsub("^\\s*\\|\\s*"; "") | ltrimstr(" ")
' pack.mcmeta | head -1)
# Fallback: if description is a plain string, extract directly
if [ -z "$VERSION" ]; then
VERSION=$(jq -r '.pack.description' pack.mcmeta | grep -oP 'v[\d.]+' | head -1)
fi
echo "version=${VERSION:-latest}" >> "$GITHUB_OUTPUT"
# 🚀 Create or update GitHub Release
- name: Create or update release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ steps.ver.outputs.version }}"
ZIP="dist/macroEngine-full.zip"
# Delete existing tag if it exists, otherwise continue
gh release delete "$TAG" --yes 2>/dev/null || true
git push origin ":refs/tags/$TAG" 2>/dev/null || true
gh release create "$TAG" \
--title "macroEngine-dp $TAG" \
--notes "**Full multi-version datapack build** (pack_format 101.1, all overlays included)." \
--latest \
"$ZIP#macroEngine-full.zip"