From b1c9934869f578ee1b48fd78c2a79647ddeb7891 Mon Sep 17 00:00:00 2001 From: Arlind Date: Wed, 18 Jun 2025 19:48:47 +0200 Subject: [PATCH] Update .gitea/workflows/ci.yml --- .gitea/workflows/ci.yml | 76 ++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index d640a22..5aa5194 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -626,8 +626,7 @@ jobs: sanitize_filename() { echo "$1" | \ tr -d '\000-\037' | \ - sed -e 's#[\\/:\*\?"<>|]#-#g' | \ - sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' + sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' } url_encode_path() { @@ -643,6 +642,7 @@ jobs: SKINS_JSON_FILE="${{ github.workspace }}/.gitea/workflows/skins.json" DESC_FILE=$(mktemp) + echo "---" > "$README_PATH" echo "gitea: none" >> "$README_PATH" echo "include_toc: true" >> "$README_PATH" @@ -663,7 +663,7 @@ jobs: jq -r '.order[]?' "$SKINS_JSON_FILE" > order.txt 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 @@ -671,17 +671,21 @@ jobs: ordered["$skin"]=1 dir="$DANSER_SKINS_DIR/$skin" [ ! -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" + if [ -f "$ini_file" ]; then - line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1) - if [ -n "$line" ]; then - val="${line#*:}" + name_line=$(grep -a -i '^Name[[:space:]]*:' "$ini_file" | head -n1 || true) + if [ -n "$name_line" ]; then + val="${name_line#*:}" val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" - if [ -n "$val" ]; then - skin_header=$(sanitize_filename "$val") - fi + [ -n "$val" ] && skin_header=$(sanitize_filename "$val") + else + skin_header=$(sanitize_filename "$skin") fi + else + continue fi raw_path="$(printf "%s/%s" "$skin" "$skin_header" | sed 's/^ *//;s/ *$//')" @@ -693,28 +697,37 @@ jobs: desc=$(get_desc "$skin") [ -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 "" >> "$README_PATH" done < order.txt - echo "Adding extra skins not in order.json..." - for dir in "$DANSER_SKINS_DIR"/*; do [ -d "$dir" ] || continue - skin=$(basename "$dir") + skin="$(basename "$dir")" [[ -n "${ordered[$skin]}" ]] && continue ini_file=$(find "$dir" -maxdepth 1 -iname "skin.ini" | head -n1 || true) skin_header="$skin" + if [ -f "$ini_file" ]; then - line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1 || true) - if [ -n "$line" ]; then - val="${line#*:}" + name_line=$(grep -a -i '^Name[[:space:]]*:' "$ini_file" | head -n1 || true) + if [ -n "$name_line" ]; then + val="${name_line#*:}" val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" - if [ -n "$val" ]; then - skin_header=$(sanitize_filename "$val") - fi + [ -n "$val" ] && skin_header=$(sanitize_filename "$val") + else + skin_header=$(sanitize_filename "$skin") fi + else + continue fi 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 "" >> "$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 "" >> "$README_PATH" done @@ -797,14 +819,30 @@ jobs: 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 "" + [ -n "$author" ] && echo "**Author:** $author" + [ -n "$author" ] && echo "" + + echo "## Hitsounds" echo "" echo "" + + echo "## Ranking Panel" echo "![](/media/panel/${base_path}.webp)" echo "" + + echo "## Mod Icons" echo "![](/media/icons/${base_path}-mod-icons.webp)" } > "$md_file_path"