Update .gitea/workflows/ci.yml
This commit is contained in:
@@ -260,28 +260,20 @@ jobs:
|
|||||||
- name: Rename Generated Assets Based on skin.ini
|
- name: Rename Generated Assets Based on skin.ini
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
echo "[Asset Renaming Job Started]"
|
||||||
|
|
||||||
echo "[Asset Renaming Started]"
|
if [ -z "${CHANGED_SKINS_FILE:-}" ] || [ ! -s "$CHANGED_SKINS_FILE" ]; then
|
||||||
|
echo "No skins changed. Skipping asset renaming."
|
||||||
skin_dirs=()
|
exit 0
|
||||||
|
|
||||||
if [ -n "${CHANGED_SKINS_FILE:-}" ] && [ -s "$CHANGED_SKINS_FILE" ]; then
|
|
||||||
echo "→ Using changed skins only."
|
|
||||||
while IFS= read -r skin || [[ -n "$skin" ]]; do
|
|
||||||
skin="$(echo "$skin" | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
|
|
||||||
[ -z "$skin" ] && continue
|
|
||||||
dir="$DANSER_SKINS_DIR/$skin"
|
|
||||||
[ -d "$dir" ] && skin_dirs+=("$dir")
|
|
||||||
done < "$CHANGED_SKINS_FILE"
|
|
||||||
else
|
|
||||||
echo "→ No changed skins file or empty file, using all skin directories."
|
|
||||||
while IFS= read -r dir; do
|
|
||||||
[ -d "$dir" ] && skin_dirs+=("$dir")
|
|
||||||
done < <(find "$DANSER_SKINS_DIR" -mindepth 1 -maxdepth 1 -type d | sort)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SKIN_COUNT=${#skin_dirs[@]}
|
mapfile -t skins < "$CHANGED_SKINS_FILE"
|
||||||
|
if [ "${#skins[@]}" -eq 0 ]; then
|
||||||
|
echo "No skins changed after reading file. Skipping asset renaming."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
SKIN_COUNT=${#skins[@]}
|
||||||
INDEX=1
|
INDEX=1
|
||||||
|
|
||||||
sanitize_filename() {
|
sanitize_filename() {
|
||||||
@@ -291,14 +283,15 @@ jobs:
|
|||||||
| sed 's/^ *//;s/ *$//'
|
| sed 's/^ *//;s/ *$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
for skin_path in "${skin_dirs[@]}"; do
|
for skin_path in "${skins[@]}"; do
|
||||||
[ -d "$skin_path" ] || continue
|
[ -z "$skin_path" ] && continue
|
||||||
SKIN_NAME=$(basename "$skin_path" \
|
SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
|
||||||
| tr -d '\r\n' \
|
[ ! -d "$SKIN_DIR" ] && { echo "Skipping missing skin directory: $SKIN_DIR"; continue; }
|
||||||
| sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
|
||||||
|
SKIN_NAME=$(basename "$skin_path" | tr -d '\r\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
echo "Processing skin $INDEX/$SKIN_COUNT: $SKIN_NAME"
|
echo "Processing skin $INDEX/$SKIN_COUNT: $SKIN_NAME"
|
||||||
|
|
||||||
ini_file=$(find "$skin_path" -maxdepth 1 -iname "skin.ini" | head -n1 || true)
|
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n1 || true)
|
||||||
skin_header="$SKIN_NAME"
|
skin_header="$SKIN_NAME"
|
||||||
if [ -f "$ini_file" ]; then
|
if [ -f "$ini_file" ]; then
|
||||||
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n1 || true)
|
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n1 || true)
|
||||||
@@ -310,15 +303,13 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$REPO_SCREENSHOT_DIR/$SKIN_NAME.gif" ] \
|
if [ -f "$REPO_SCREENSHOT_DIR/$SKIN_NAME.gif" ] && [ "$SKIN_NAME" != "$skin_header" ]; then
|
||||||
&& [ "$SKIN_NAME" != "$skin_header" ]; then
|
|
||||||
mv -f "$REPO_SCREENSHOT_DIR/$SKIN_NAME.gif" \
|
mv -f "$REPO_SCREENSHOT_DIR/$SKIN_NAME.gif" \
|
||||||
"$REPO_SCREENSHOT_DIR/$skin_header.gif" || true
|
"$REPO_SCREENSHOT_DIR/$skin_header.gif" || true
|
||||||
echo " ✓ Renamed GIF"
|
echo " ✓ Renamed GIF"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$REPO_RANKING_PANEL_DIR/$SKIN_NAME.png" ] \
|
if [ -f "$REPO_RANKING_PANEL_DIR/$SKIN_NAME.png" ] && [ "$SKIN_NAME" != "$skin_header" ]; then
|
||||||
&& [ "$SKIN_NAME" != "$skin_header" ]; then
|
|
||||||
mv -f "$REPO_RANKING_PANEL_DIR/$SKIN_NAME.png" \
|
mv -f "$REPO_RANKING_PANEL_DIR/$SKIN_NAME.png" \
|
||||||
"$REPO_RANKING_PANEL_DIR/$skin_header.png" || true
|
"$REPO_RANKING_PANEL_DIR/$skin_header.png" || true
|
||||||
echo " ✓ Renamed PNG"
|
echo " ✓ Renamed PNG"
|
||||||
@@ -333,9 +324,18 @@ jobs:
|
|||||||
- name: Generate Mod Icons
|
- name: Generate Mod Icons
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
echo "[Mod Icon Generation Job Started]"
|
||||||
|
|
||||||
echo "[Mod Icon Generation Started]"
|
if [ -z "${CHANGED_SKINS_FILE:-}" ] || [ ! -s "$CHANGED_SKINS_FILE" ]; then
|
||||||
|
echo "No skins changed. Skipping mod icon generation."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
mapfile -t skin_dirs < "$CHANGED_SKINS_FILE"
|
||||||
|
if [ "${#skin_dirs[@]}" -eq 0 ]; then
|
||||||
|
echo "No skins changed after reading file. Skipping mod icon generation."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
sanitize_filename() {
|
sanitize_filename() {
|
||||||
echo "$1" \
|
echo "$1" \
|
||||||
@@ -344,23 +344,6 @@ jobs:
|
|||||||
| sed 's/^ *//;s/ *$//'
|
| sed 's/^ *//;s/ *$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
skin_dirs=()
|
|
||||||
|
|
||||||
if [ -n "${CHANGED_SKINS_FILE:-}" ] && [ -s "$CHANGED_SKINS_FILE" ]; then
|
|
||||||
echo "→ Using changed skins only."
|
|
||||||
while IFS= read -r skin || [[ -n "$skin" ]]; do
|
|
||||||
skin="$(echo "$skin" | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
|
|
||||||
[ -z "$skin" ] && continue
|
|
||||||
dir="$DANSER_SKINS_DIR/$skin"
|
|
||||||
[ -d "$dir" ] && skin_dirs+=("$dir")
|
|
||||||
done < "$CHANGED_SKINS_FILE"
|
|
||||||
else
|
|
||||||
echo "→ No changed skins file or empty file, using all skin directories."
|
|
||||||
while IFS= read -r dir; do
|
|
||||||
[ -d "$dir" ] && skin_dirs+=("$dir")
|
|
||||||
done < <(find "$DANSER_SKINS_DIR" -mindepth 1 -maxdepth 1 -type d | sort)
|
|
||||||
fi
|
|
||||||
|
|
||||||
ICONS_JSON_FILE="${{ github.workspace }}/.gitea/workflows/icons.json"
|
ICONS_JSON_FILE="${{ github.workspace }}/.gitea/workflows/icons.json"
|
||||||
group1_icons=$(jq -r '.group1 | join(" ")' "$ICONS_JSON_FILE")
|
group1_icons=$(jq -r '.group1 | join(" ")' "$ICONS_JSON_FILE")
|
||||||
group2_icons=$(jq -r '.group2 | join(" ")' "$ICONS_JSON_FILE")
|
group2_icons=$(jq -r '.group2 | join(" ")' "$ICONS_JSON_FILE")
|
||||||
@@ -372,15 +355,17 @@ jobs:
|
|||||||
SKIN_COUNT=${#skin_dirs[@]}
|
SKIN_COUNT=${#skin_dirs[@]}
|
||||||
INDEX=1
|
INDEX=1
|
||||||
|
|
||||||
for SKIN_DIR in "${skin_dirs[@]}"; do
|
for skin_path in "${skin_dirs[@]}"; do
|
||||||
[ -d "$SKIN_DIR" ] || continue
|
SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
|
||||||
skin_header=$(basename "$SKIN_DIR" | tr -d '\r\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
[ ! -d "$SKIN_DIR" ] && { echo "Skipping missing skin directory: $SKIN_DIR"; continue; }
|
||||||
|
skin_header=$(basename "$skin_path" | tr -d '\r\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
|
|
||||||
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n 1 || true)
|
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n1 || true)
|
||||||
if [ -f "$ini_file" ]; then
|
if [ -f "$ini_file" ]; then
|
||||||
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n 1 || true)
|
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n1 || true)
|
||||||
if [ -n "$name_line" ]; then
|
if [ -n "$name_line" ]; then
|
||||||
new_name=$(echo "$name_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
new_name=$(echo "$name_line" | cut -d ':' -f2- \
|
||||||
|
| sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
new_name=$(sanitize_filename "$new_name")
|
new_name=$(sanitize_filename "$new_name")
|
||||||
[ -n "$new_name" ] && skin_header="$new_name"
|
[ -n "$new_name" ] && skin_header="$new_name"
|
||||||
fi
|
fi
|
||||||
@@ -404,11 +389,9 @@ jobs:
|
|||||||
montage_files+=("${DEFAULT_SKIN_DIR}/selection-mod-${icon}@2x.png")
|
montage_files+=("${DEFAULT_SKIN_DIR}/selection-mod-${icon}@2x.png")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
while [ "${#montage_files[@]}" -lt 7 ]; do
|
while [ "${#montage_files[@]}" -lt 7 ]; do
|
||||||
montage_files+=("$BLANK_IMAGE")
|
montage_files+=("$BLANK_IMAGE")
|
||||||
done
|
done
|
||||||
|
|
||||||
magick montage "${montage_files[@]}" -tile "7x1" -geometry "160x160+10+10" -background none "row_${row_index}.png"
|
magick montage "${montage_files[@]}" -tile "7x1" -geometry "160x160+10+10" -background none "row_${row_index}.png"
|
||||||
row_images+=("row_${row_index}.png")
|
row_images+=("row_${row_index}.png")
|
||||||
row_index=$((row_index + 1))
|
row_index=$((row_index + 1))
|
||||||
@@ -426,13 +409,22 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
echo "[Mod Icon Generation Finished — $SKIN_COUNT skins processed]"
|
echo "[Mod Icon Generation Finished — $SKIN_COUNT skins processed]"
|
||||||
|
|
||||||
- name: Create OSK files
|
- name: Create OSK Files
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
echo "[OSK Creation Job Started]"
|
echo "[OSK Creation Job Started]"
|
||||||
|
|
||||||
|
if [ -z "${CHANGED_SKINS_FILE:-}" ] || [ ! -s "$CHANGED_SKINS_FILE" ]; then
|
||||||
|
echo "No skins changed. Skipping OSK creation."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
mapfile -t skin_dirs < "$CHANGED_SKINS_FILE"
|
||||||
|
if [ "${#skin_dirs[@]}" -eq 0 ]; then
|
||||||
|
echo "No skins changed after reading file. Skipping OSK creation."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
sanitize_filename() {
|
sanitize_filename() {
|
||||||
echo "$1" \
|
echo "$1" \
|
||||||
| sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' \
|
| sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' \
|
||||||
@@ -440,37 +432,21 @@ jobs:
|
|||||||
| sed 's/^ *//;s/ *$//'
|
| sed 's/^ *//;s/ *$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
skin_dirs=()
|
|
||||||
|
|
||||||
if [ -n "${CHANGED_SKINS_FILE:-}" ] && [ -s "$CHANGED_SKINS_FILE" ]; then
|
|
||||||
echo "→ Using changed skins only."
|
|
||||||
while IFS= read -r skin || [[ -n "$skin" ]]; do
|
|
||||||
skin="$(echo "$skin" | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
|
|
||||||
[ -z "$skin" ] && continue
|
|
||||||
dir="$DANSER_SKINS_DIR/$skin"
|
|
||||||
[ -d "$dir" ] && skin_dirs+=("$dir")
|
|
||||||
done < "$CHANGED_SKINS_FILE"
|
|
||||||
else
|
|
||||||
echo "→ No changed skins file or empty file, using all skin directories."
|
|
||||||
while IFS= read -r dir; do
|
|
||||||
[ -d "$dir" ] && skin_dirs+=("$dir")
|
|
||||||
done < <(find "$DANSER_SKINS_DIR" -mindepth 1 -maxdepth 1 -type d | sort)
|
|
||||||
fi
|
|
||||||
|
|
||||||
FIXED_TIMESTAMP="2025-01-01 00:00:00"
|
FIXED_TIMESTAMP="2025-01-01 00:00:00"
|
||||||
SKIN_COUNT=${#skin_dirs[@]}
|
SKIN_COUNT=${#skin_dirs[@]}
|
||||||
INDEX=1
|
INDEX=1
|
||||||
|
|
||||||
for SKIN_DIR in "${skin_dirs[@]}"; do
|
for skin_path in "${skin_dirs[@]}"; do
|
||||||
[ -d "$SKIN_DIR" ] || continue
|
SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
|
||||||
|
[ ! -d "$SKIN_DIR" ] && { echo "Skipping missing skin directory: $SKIN_DIR"; continue; }
|
||||||
|
|
||||||
skin_header=$(basename "$SKIN_DIR" | tr -d '\r\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
skin_header=$(basename "$skin_path" | tr -d '\r\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
|
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n1 || true)
|
||||||
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n 1 || true)
|
|
||||||
if [ -f "$ini_file" ]; then
|
if [ -f "$ini_file" ]; then
|
||||||
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n 1 || true)
|
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n1 || true)
|
||||||
if [ -n "$name_line" ]; then
|
if [ -n "$name_line" ]; then
|
||||||
new_name=$(echo "$name_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
new_name=$(echo "$name_line" | cut -d ':' -f2- \
|
||||||
|
| sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
new_name=$(sanitize_filename "$new_name")
|
new_name=$(sanitize_filename "$new_name")
|
||||||
[ -n "$new_name" ] && skin_header="$new_name"
|
[ -n "$new_name" ] && skin_header="$new_name"
|
||||||
fi
|
fi
|
||||||
@@ -697,6 +673,50 @@ jobs:
|
|||||||
|
|
||||||
echo "README generation completed successfully."
|
echo "README generation completed successfully."
|
||||||
|
|
||||||
|
- name: Cleanup Extraneous Files
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
rm -rf src/docs || true
|
||||||
|
rm -f how-to-use.md || true
|
||||||
|
sanitize_filename() { echo "$1" | sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' | tr -s ' ' | sed 's/^ *//;s/ *$//'; }
|
||||||
|
expected_basenames=()
|
||||||
|
for dir in "$DANSER_SKINS_DIR"/*; do
|
||||||
|
[ -d "$dir" ] || continue
|
||||||
|
raw=$(basename "$dir" | tr -d '\r\n')
|
||||||
|
header=$(sanitize_filename "$raw")
|
||||||
|
expected_basenames+=("$header")
|
||||||
|
ini=$(find "$dir" -maxdepth 1 -iname skin.ini | head -n1 || true)
|
||||||
|
if [ -f "$ini" ]; then
|
||||||
|
name_line=$(grep -i '^[[:space:]]*name:' "$ini" | head -n1)
|
||||||
|
if [ -n "$name_line" ]; then
|
||||||
|
val="${name_line#*:}"
|
||||||
|
val=$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
|
header=$(sanitize_filename "$val")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
expected_basenames+=("$header")
|
||||||
|
done
|
||||||
|
readarray -t expected_basenames < <(printf "%s\n" "${expected_basenames[@]}" | sort -u)
|
||||||
|
for b in "${expected_basenames[@]}"; do expected_basenames+=("${b}-mod-icons"); done
|
||||||
|
readarray -t expected_basenames < <(printf "%s\n" "${expected_basenames[@]}" | sort -u)
|
||||||
|
prune_dir() {
|
||||||
|
for f in "$1"/*; do
|
||||||
|
[ -e "$f" ] || continue
|
||||||
|
fn=$(basename "$f")
|
||||||
|
base="${fn%.*}"
|
||||||
|
keep=false
|
||||||
|
for kb in "${expected_basenames[@]}"; do
|
||||||
|
[ "$base" = "$kb" ] && { keep=true; break; }
|
||||||
|
done
|
||||||
|
$keep || rm -rf "$f"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
prune_dir "$REPO_SCREENSHOT_DIR"
|
||||||
|
prune_dir "$REPO_RANKING_PANEL_DIR"
|
||||||
|
prune_dir "$REPO_MOD_ICONS_DIR"
|
||||||
|
prune_dir "$OSK_PATH"
|
||||||
|
|
||||||
- name: Configure Git
|
- name: Configure Git
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -708,7 +728,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
git config advice.addIgnoredFile false
|
git config advice.addIgnoredFile false
|
||||||
git add README.md media/gameplay/* media/panel/* media/icons/* export/*
|
git add -A media/gameplay media/panel media/icons export README.md
|
||||||
git commit -m "[ci skip] push back from pipeline" -q || echo "No changes to commit"
|
git commit -m "[ci skip] push back from pipeline" -q || echo "No changes to commit"
|
||||||
|
|
||||||
- name: Push changes and create tag
|
- name: Push changes and create tag
|
||||||
|
|||||||
Reference in New Issue
Block a user