Update .gitea/workflows/ci.yml

This commit is contained in:
Arlind
2025-06-18 19:48:47 +02:00
parent fa0a96d44d
commit b1c9934869

View File

@@ -626,8 +626,7 @@ jobs:
sanitize_filename() { sanitize_filename() {
echo "$1" | \ echo "$1" | \
tr -d '\000-\037' | \ tr -d '\000-\037' | \
sed -e 's#[\\/:\*\?"<>|]#-#g' | \ sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
} }
url_encode_path() { url_encode_path() {
@@ -643,6 +642,7 @@ jobs:
SKINS_JSON_FILE="${{ github.workspace }}/.gitea/workflows/skins.json" SKINS_JSON_FILE="${{ github.workspace }}/.gitea/workflows/skins.json"
DESC_FILE=$(mktemp) DESC_FILE=$(mktemp)
echo "---" > "$README_PATH" echo "---" > "$README_PATH"
echo "gitea: none" >> "$README_PATH" echo "gitea: none" >> "$README_PATH"
echo "include_toc: true" >> "$README_PATH" echo "include_toc: true" >> "$README_PATH"
@@ -663,7 +663,7 @@ jobs:
jq -r '.order[]?' "$SKINS_JSON_FILE" > order.txt jq -r '.order[]?' "$SKINS_JSON_FILE" > order.txt
get_desc() { get_desc() {
grep -F -m1 -- "$1=" "$DESC_FILE" 2>/dev/null | cut -d '=' -f2- grep -F -m1 -- "$1=" "$DESC_FILE" 2>/dev/null | cut -d '=' -f2- || true
} }
declare -A ordered declare -A ordered
@@ -671,17 +671,21 @@ jobs:
ordered["$skin"]=1 ordered["$skin"]=1
dir="$DANSER_SKINS_DIR/$skin" dir="$DANSER_SKINS_DIR/$skin"
[ ! -d "$dir" ] && continue [ ! -d "$dir" ] && continue
ini_file=$(find "$dir" -maxdepth 1 -iname "skin.ini" | head -n1)
ini_file=$(find "$dir" -maxdepth 1 -iname "skin.ini" | head -n1 || true)
skin_header="$skin" skin_header="$skin"
if [ -f "$ini_file" ]; then if [ -f "$ini_file" ]; then
line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1) name_line=$(grep -a -i '^Name[[:space:]]*:' "$ini_file" | head -n1 || true)
if [ -n "$line" ]; then if [ -n "$name_line" ]; then
val="${line#*:}" val="${name_line#*:}"
val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
if [ -n "$val" ]; then [ -n "$val" ] && skin_header=$(sanitize_filename "$val")
skin_header=$(sanitize_filename "$val") else
fi skin_header=$(sanitize_filename "$skin")
fi fi
else
continue
fi fi
raw_path="$(printf "%s/%s" "$skin" "$skin_header" | sed 's/^ *//;s/ *$//')" raw_path="$(printf "%s/%s" "$skin" "$skin_header" | sed 's/^ *//;s/ *$//')"
@@ -693,28 +697,37 @@ jobs:
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"; }
if [ -f "$ini_file" ]; then
author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 || true)
if [ -n "$author_line" ]; then
author=$(echo "$author_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
[ -n "$author" ] && { echo "**Author:** $author" >> "$README_PATH"; echo "" >> "$README_PATH"; }
fi
fi
echo "[![$skin_header Thumbnail](media/thumbnail/${base_path}.webp)](/docs/${base_path}.md)" >> "$README_PATH" echo "[![$skin_header Thumbnail](media/thumbnail/${base_path}.webp)](/docs/${base_path}.md)" >> "$README_PATH"
echo "" >> "$README_PATH" echo "" >> "$README_PATH"
done < order.txt done < order.txt
echo "Adding extra skins not in order.json..."
for dir in "$DANSER_SKINS_DIR"/*; do for dir in "$DANSER_SKINS_DIR"/*; do
[ -d "$dir" ] || continue [ -d "$dir" ] || continue
skin=$(basename "$dir") skin="$(basename "$dir")"
[[ -n "${ordered[$skin]}" ]] && continue [[ -n "${ordered[$skin]}" ]] && continue
ini_file=$(find "$dir" -maxdepth 1 -iname "skin.ini" | head -n1 || true) ini_file=$(find "$dir" -maxdepth 1 -iname "skin.ini" | head -n1 || true)
skin_header="$skin" skin_header="$skin"
if [ -f "$ini_file" ]; then if [ -f "$ini_file" ]; then
line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1 || true) name_line=$(grep -a -i '^Name[[:space:]]*:' "$ini_file" | head -n1 || true)
if [ -n "$line" ]; then if [ -n "$name_line" ]; then
val="${line#*:}" val="${name_line#*:}"
val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
if [ -n "$val" ]; then [ -n "$val" ] && skin_header=$(sanitize_filename "$val")
skin_header=$(sanitize_filename "$val") else
fi skin_header=$(sanitize_filename "$skin")
fi fi
else
continue
fi fi
raw_path="$(printf "%s/%s" "$skin" "$skin_header" | sed 's/^ *//;s/ *$//')" raw_path="$(printf "%s/%s" "$skin" "$skin_header" | sed 's/^ *//;s/ *$//')"
@@ -722,6 +735,15 @@ jobs:
echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/$new_tag/export/${base_path}.osk)" >> "$README_PATH" echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/$new_tag/export/${base_path}.osk)" >> "$README_PATH"
echo "" >> "$README_PATH" echo "" >> "$README_PATH"
if [ -f "$ini_file" ]; then
author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 || true)
if [ -n "$author_line" ]; then
author=$(echo "$author_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
[ -n "$author" ] && { echo "**Author:** $author" >> "$README_PATH"; echo "" >> "$README_PATH"; }
fi
fi
echo "[![$skin_header Thumbnail](media/thumbnail/${base_path}.webp)](/docs/${base_path}.md)" >> "$README_PATH" echo "[![$skin_header Thumbnail](media/thumbnail/${base_path}.webp)](/docs/${base_path}.md)" >> "$README_PATH"
echo "" >> "$README_PATH" echo "" >> "$README_PATH"
done done
@@ -797,14 +819,30 @@ jobs:
video_url="$REGISTRY_URL/$USER_REPOSITORY/raw/tag/$new_tag/media/gameplay/${base_path}.mp4" video_url="$REGISTRY_URL/$USER_REPOSITORY/raw/tag/$new_tag/media/gameplay/${base_path}.mp4"
author=""
if [ -f "$ini_file" ]; then
author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 || true)
if [ -n "$author_line" ]; then
author=$(echo "$author_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
fi
fi
{ {
echo "# [$skin_header]($osk_url)" echo "# [$skin_header]($osk_url)"
echo "" echo ""
[ -n "$author" ] && echo "**Author:** $author"
[ -n "$author" ] && echo ""
echo "## Hitsounds"
echo "<video controls autoplay loop muted playsinline src=\"$video_url\" type=\"video/mp4\">" echo "<video controls autoplay loop muted playsinline src=\"$video_url\" type=\"video/mp4\">"
echo "</video>" echo "</video>"
echo "" echo ""
echo "## Ranking Panel"
echo "![](/media/panel/${base_path}.webp)" echo "![](/media/panel/${base_path}.webp)"
echo "" echo ""
echo "## Mod Icons"
echo "![](/media/icons/${base_path}-mod-icons.webp)" echo "![](/media/icons/${base_path}-mod-icons.webp)"
} > "$md_file_path" } > "$md_file_path"