Update .gitea/workflows/ci.yml

This commit is contained in:
Arlind
2025-06-13 14:37:18 +02:00
parent 8e5d6c85e5
commit 67ed94d4dc

View File

@@ -637,13 +637,12 @@ jobs:
echo "" >> "$README_PATH" echo "" >> "$README_PATH"
get_desc() { get_desc() {
grep -- "^$1=" "$DESC_FILE" 2>/dev/null | cut -d '=' -f2- grep -F -m1 -- "$1=" "$DESC_FILE" 2>/dev/null | cut -d '=' -f2-
} }
ORDER_FILE=$(mktemp) ORDER_FILE=$(mktemp)
echo "Step 3: Extracting order from skins.json..." echo "Step 3: Extracting order from skins.json..."
jq -r '.order[]' "$SKINS_JSON_FILE" > "$ORDER_FILE" jq -r '.order[]?' "$SKINS_JSON_FILE" > "$ORDER_FILE"
echo "Step 4: Processing ordered skins..." echo "Step 4: Processing ordered skins..."
while IFS= read -r skin; do while IFS= read -r skin; do
@@ -654,82 +653,83 @@ jobs:
ini_file=$(find "$dir" -maxdepth 1 -iname "skin.ini" | head -n1) ini_file=$(find "$dir" -maxdepth 1 -iname "skin.ini" | head -n1)
skin_header="$skin" skin_header="$skin"
if [ -f "$ini_file" ]; then if [ -f "$ini_file" ]; then
name_line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1) line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1 2>/dev/null || true)
if [ -n "$name_line" ]; then [ -n "$line" ] && {
new_name=$(echo "${name_line#*:}" | sed 's/^[[:space:]]*//') val="${line#*:}"
new_name=$(sanitize_filename "$new_name") skin_header=$(sanitize_filename "$val")
[ -n "$new_name" ] && skin_header="$new_name" }
fi
fi fi
skin_header=$(printf '%s' "$skin_header" | tr -d '\r\n')
base_path=$(printf "%s/%s" "$skin" "$skin_header" | sed 's/ /%20/g') base_path=$(printf "%s/%s" "$skin" "$skin_header" | sed 's/ /%20/g')
escaped_img="${base_path}.gif" echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/$new_tag/export/${base_path}.osk)" >> "$README_PATH"
escaped_panel="${base_path}.png"
escaped_osk="${base_path}.osk"
escaped_mod="${base_path}-mod-icons.png"
echo " Writing skin: $skin_header"
echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/$new_tag/export/$escaped_osk)" >> "$README_PATH"
echo "" >> "$README_PATH" echo "" >> "$README_PATH"
desc=$(get_desc "$skin") desc=$(get_desc "$skin")
[ -n "$desc" ] && { echo "$desc" >> "$README_PATH"; echo "" >> "$README_PATH"; } [ -n "$desc" ] && { echo "$desc" >> "$README_PATH"; echo "" >> "$README_PATH"; }
author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 2>/dev/null) if [ -f "$ini_file" ]; then
if [ -n "$author_line" ]; then author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 2>/dev/null || true)
author=$(echo "${author_line#*:}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') if [ -n "$author_line" ]; then
[ -n "$author" ] && { echo "**Author:** $author" >> "$README_PATH"; echo "" >> "$README_PATH"; } author="${author_line#*:}"
author="$(echo "$author" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
[ -n "$author" ] && { echo "**Author:** $author" >> "$README_PATH"; echo "" >> "$README_PATH"; }
fi
fi fi
echo "![$skin_header Gameplay](media/gameplay/$escaped_img)" >> "$README_PATH" echo "![$skin_header Gameplay](media/gameplay/${base_path}.gif)" >> "$README_PATH"
echo "" >> "$README_PATH" echo "" >> "$README_PATH"
echo "![$skin_header Ranking Panel](media/panel/$escaped_panel)" >> "$README_PATH" echo "![$skin_header Ranking Panel](media/panel/${base_path}.png)" >> "$README_PATH"
echo "" >> "$README_PATH" echo "" >> "$README_PATH"
echo "![$skin_header Mods](media/icons/$escaped_mod)" >> "$README_PATH" echo "![$skin_header Mods](media/icons/${base_path}-mod-icons.png)" >> "$README_PATH"
echo "" >> "$README_PATH" echo "" >> "$README_PATH"
done < "$ORDER_FILE" done < "$ORDER_FILE"
declare -A ordered
while IFS= read -r skin; do
ordered["$skin"]=1
done < "$ORDER_FILE"
echo "Step 5: Processing extra skins..." echo "Step 5: Processing extra skins..."
find "$DANSER_SKINS_DIR" -mindepth 1 -maxdepth 1 -type d | while IFS= read -r dir; do if [ ! -s "$ORDER_FILE" ]; then
skin=$(basename "$dir") echo "→ No \`order\` defined in skins.json; skipping extra-skins loop."
grep -F -x -q -- "$skin" "$ORDER_FILE" && continue else
for dir in "$DANSER_SKINS_DIR"/*; do
[ -d "$dir" ] || continue
skin=$(basename "$dir")
[[ -n "${ordered[$skin]}" ]] && continue
ini_file=$(find "$dir" -maxdepth 1 -iname "skin.ini" | head -n1) echo " Writing extra skin: $skin"
skin_header="$skin" ini_file=$(find "$dir" -maxdepth 1 -iname "skin.ini" | head -n1)
if [ -f "$ini_file" ]; then skin_header="$skin"
name_line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1) if [ -f "$ini_file" ]; then
if [ -n "$name_line" ]; then line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1 2>/dev/null || true)
new_name=$(echo "${name_line#*:}" | sed 's/^[[:space:]]*//') [ -n "$line" ] && {
new_name=$(sanitize_filename "$new_name") val="${line#*:}"
[ -n "$new_name" ] && skin_header="$new_name" skin_header=$(sanitize_filename "$val")
}
fi fi
fi
skin_header=$(printf '%s' "$skin_header" | tr -d '\r\n')
base_path=$(printf "%s/%s" "$skin" "$skin_header" | sed 's/ /%20/g') base_path=$(printf "%s/%s" "$skin" "$skin_header" | sed 's/ /%20/g')
escaped_img="${base_path}.gif" echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/$new_tag/export/${base_path}.osk)" >> "$README_PATH"
escaped_panel="${base_path}.png" echo "" >> "$README_PATH"
escaped_osk="${base_path}.osk"
escaped_mod="${base_path}-mod-icons.png"
echo " Writing extra skin: $skin_header" if [ -f "$ini_file" ]; then
echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/$new_tag/export/$escaped_osk)" >> "$README_PATH" author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 2>/dev/null || true)
echo "" >> "$README_PATH" if [ -n "$author_line" ]; then
author="${author_line#*:}"
author="$(echo "$author" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
[ -n "$author" ] && { echo "**Author:** $author" >> "$README_PATH"; echo "" >> "$README_PATH"; }
fi
fi
author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 2>/dev/null) echo "![$skin_header Gameplay](media/gameplay/${base_path}.gif)" >> "$README_PATH"
if [ -n "$author_line" ]; then echo "" >> "$README_PATH"
author=$(echo "${author_line#*:}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') echo "![$skin_header Ranking Panel](media/panel/${base_path}.png)" >> "$README_PATH"
[ -n "$author" ] && { echo "**Author:** $author" >> "$README_PATH"; echo "" >> "$README_PATH"; } echo "" >> "$README_PATH"
fi echo "![$skin_header Mods](media/icons/${base_path}-mod-icons.png)" >> "$README_PATH"
echo "" >> "$README_PATH"
echo "![$skin_header Gameplay](media/gameplay/$escaped_img)" >> "$README_PATH" done
echo "" >> "$README_PATH" fi
echo "![$skin_header Ranking Panel](media/panel/$escaped_panel)" >> "$README_PATH"
echo "" >> "$README_PATH"
echo "![$skin_header Mods](media/icons/$escaped_mod)" >> "$README_PATH"
echo "" >> "$README_PATH"
done
echo "Step 7: Writing Build History section..." echo "Step 7: Writing Build History section..."
echo "# Build History" >> "$README_PATH" echo "# Build History" >> "$README_PATH"
@@ -757,50 +757,62 @@ jobs:
set -euo pipefail set -euo pipefail
echo "[Migration of flat assets started]" echo "[Migration of flat assets started]"
# helper to sanitize header
sanitize() { sanitize() {
echo "$1" \ echo "$1" | tr -d $'\r\n\t' | \
| tr -d '\r\n' \ sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' | \
| sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' \ tr -s ' ' | \
| tr -s ' ' \ sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
| sed 's/^ *//;s/ *$//'
} }
readarray -t skins <<< "$ALL_SKINS_DIR" readarray -t skins <<< "$ALL_SKINS_DIR"
declare -A hdr2fld declare -A hdr2fld
for skin in "${skins[@]}"; do for skin in "${skins[@]}"; do
header=$(sanitize "$skin") [[ -z "${skin// }" ]] && continue
ini=$(find "$DANSER_SKINS_DIR/$skin" -maxdepth 1 -type f -iname "skin.ini" | head -n1 || true) dir_key=$(sanitize "$skin")
if [ -n "$ini" ]; then hdr2fld["$dir_key"]="$skin"
raw=$(grep -i '^[[:space:]]*Name:' "$ini" | head -n1 || true) ini=$(find "$DANSER_SKINS_DIR/$skin" -maxdepth 1 -iname skin.ini -print -quit || true)
if [[ -f "$ini" ]]; then
raw=$(grep -i '^\s*Name:' "$ini" | head -n1 || true)
raw="${raw#*:}" raw="${raw#*:}"
raw="${raw#"${raw%%[![:space:]]*}"}" ini_key=$(sanitize "$raw")
header=$(sanitize "$raw") [[ -n "$ini_key" ]] && hdr2fld["$ini_key"]="$skin"
fi fi
hdr2fld["$header"]="$skin" done
echo "DEBUG: header→folder map"
for key in "${!hdr2fld[@]}"; do
echo " '$key' → '${hdr2fld[$key]}'"
done done
migrate() { migrate() {
root=$1; ext=$2 local root=$1 ext=$2
echo " → Migrating *.$ext files in $root" echo " → Migrating *.$ext in $root"
shopt -s nullglob set +e
for f in "$root"/*."$ext"; do find "$root" -maxdepth 2 -type f -name "*.$ext" | while read -r f; do
base="$(basename "$f" ."$ext")" filename=$(basename "$f")
if [[ "$root" == *icons ]]; then base="${filename%.*}"
base="${base%-mod-icons}" [[ "$root" == *icons ]] && base="${base%-mod-icons}"
fi key=$(sanitize "$base")
target="${hdr2fld[$base]:-}" target="${hdr2fld[$key]:-}"
if [ -n "$target" ]; then if [[ -n "$target" ]]; then
dst="$root/$target" dst="$root/$target"
mkdir -p "$dst" mkdir -p "$dst"
echo " • Moving $f → $dst/" srcdir=$(dirname "$f")
mv "$f" "$dst/" if [[ "$srcdir" == "$dst" ]]; then
echo " → $filename already in $target/, skipping"
else
echo " • Moving $filename → $target/"
mv "$f" "$dst/$filename"
fi
else else
echo " ✖ No matching skin for '$base'; leaving $f" echo " ✖ No mapping for '$base' leaving $f"
fi fi
done done
shopt -u nullglob set -euo pipefail
find "$root" -mindepth 1 -maxdepth 1 -type d | while read -r d; do
[ -z "$(ls -A "$d")" ] && { echo " • Removing empty dir $d"; rmdir "$d"; }
done
} }
migrate "$REPO_SCREENSHOT_DIR" gif migrate "$REPO_SCREENSHOT_DIR" gif
@@ -820,24 +832,35 @@ jobs:
[ -d src/docs ] && rm -rf src/docs [ -d src/docs ] && rm -rf src/docs
[ -f how-to-use.md ] && rm -f how-to-use.md [ -f how-to-use.md ] && rm -f how-to-use.md
# Read the current list of skins
readarray -t skins <<< "$ALL_SKINS_DIR"
# Helper to sanitize header (for pruning inside)
sanitize() { sanitize() {
echo "$1" \ echo "$1" \
| tr -d '\r\n' \ | tr -d '\r\n' \
| sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' \ | sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' \
| tr -s ' ' \ | tr -s ' ' \
| sed 's/^ *//;s/ *$//' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
} }
readarray -t skins <<< "$ALL_SKINS_DIR" for root in "$REPO_SCREENSHOT_DIR" "$REPO_RANKING_PANEL_DIR" "$REPO_MOD_ICONS_DIR" "$OSK_PATH"; do
for dir in "$root"/*; do
[ -d "$dir" ] || continue
name="$(basename "$dir")"
if ! printf '%s\n' "${skins[@]}" | grep -Fxq -- "$name"; then
echo " → Skin '$name' deleted—removing directory $dir"
rm -rf "$dir"
fi
done
done
for skin in "${skins[@]}"; do for skin in "${skins[@]}"; do
header=$(sanitize "$skin") header=$(sanitize "$skin")
ini=$(find "$DANSER_SKINS_DIR/$skin" -maxdepth 1 -type f -iname "skin.ini" -print -quit || true)
ini=$(find "$DANSER_SKINS_DIR/$skin" -maxdepth 1 -type f -iname "skin.ini" | head -n1 || true) if [[ -f "$ini" ]]; then
if [ -n "$ini" ]; then raw=$(grep -i '^[[:space:]]*Name:' "$ini" | head -n1 || true)
raw_line=$(grep -i '^[[:space:]]*Name:' "$ini" | head -n1 || true) raw="${raw#*:}"
raw="${raw_line#*:}"
raw="${raw#"${raw%%[![:space:]]*}"}"
header=$(sanitize "$raw") header=$(sanitize "$raw")
fi fi
@@ -846,23 +869,23 @@ jobs:
expect_icon="$header-mod-icons.png" expect_icon="$header-mod-icons.png"
expect_osk="$header.osk" expect_osk="$header.osk"
prune() { prune_dir() {
root=$1; expected=$2 root=$1; expected=$2
dir="$root/$skin" dir="$root/$skin"
[ -d "$dir" ] || return [ ! -d "$dir" ] && return
for f in "$dir"/*; do for f in "$dir"/*; do
[ -e "$f" ] || continue [ -e "$f" ] || continue
if [ "$(basename "$f")" != "$expected" ]; then if [[ "$(basename "$f")" != "$expected" ]]; then
echo " → Removing unexpected file: $f" echo " → Removing unexpected file: $f"
rm -f "$f" rm -f "$f"
fi fi
done done
} }
prune "$REPO_SCREENSHOT_DIR" "$expect_gif" prune_dir "$REPO_SCREENSHOT_DIR" "$expect_gif"
prune "$REPO_RANKING_PANEL_DIR" "$expect_png" prune_dir "$REPO_RANKING_PANEL_DIR" "$expect_png"
prune "$REPO_MOD_ICONS_DIR" "$expect_icon" prune_dir "$REPO_MOD_ICONS_DIR" "$expect_icon"
prune "$OSK_PATH" "$expect_osk" prune_dir "$OSK_PATH" "$expect_osk"
done done
echo "[Cleanup Extra Files Complete]" echo "[Cleanup Extra Files Complete]"