add cleanup fix danser video renaming

This commit is contained in:
2025-10-01 15:00:24 +02:00
parent 8a96bcfd2b
commit 9b3ec01d41
10 changed files with 998 additions and 876 deletions

View File

@@ -0,0 +1,88 @@
name: "Cleanup Extra Files"
description: "Remove leftover or outdated assets from repository"
inputs:
all_skins:
description: "Newline-delimited list of all skins"
required: true
runs:
using: "composite"
steps:
- name: Cleanup Extra Files
shell: bash
run: |
set -euo pipefail
echo "[Cleanup Extra Files Started]"
readarray -t skins <<< "${{ inputs.all_skins }}"
[ -f how-to-use.md ] && rm -f how-to-use.md
[ -f src/replay.osr ] && rm -f src/replay.osr
[ -d src/default-skin ] && rm -rf src/default-skin
sanitize_filename() {
echo "$1" | \
tr -d '\000-\037' | \
sed -e 's#[\\/:\*\?"<>|]#-#g' | \
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
}
prune_dir() {
local root="$1"
local skin="$2"
local expected="$3"
for f in "$root"/*; do
[ -f "$f" ] || continue
name="$(basename "$f")"
if printf '%s\n' "${skins[@]}" | grep -Fxq -- "$name"; then
continue
fi
echo " → Removing unexpected root file: $f"
rm -f "$f"
done
dir="$root/$skin"
[ -d "$dir" ] || return
for f in "$dir"/*; do
[ -e "$f" ] || continue
if [[ "$(basename "$f")" != "$expected" ]]; then
echo " → Removing unexpected file: $f"
rm -f "$f"
fi
done
}
for root in "$REPO_SCREENSHOT_DIR" "$REPO_RANKING_PANEL_DIR" "$REPO_MOD_ICONS_DIR" "$REPO_THUMBNAIL_DIR" "$OSK_PATH" "$DOC_DIR"; do
[ -d "$root" ] || continue
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
header=$(sanitize_filename "$skin")
ini=$(find "$DANSER_SKINS_DIR/$skin" -maxdepth 1 -type f -iname "skin.ini" -print -quit || true)
if [[ -f "$ini" ]]; then
raw=$(grep -i '^[[:space:]]*Name:' "$ini" | head -n1 || true)
raw="${raw#*:}"
raw="$(echo "$raw" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
tmp_header=$(sanitize_filename "$raw")
[[ -n "$tmp_header" ]] && header="$tmp_header"
fi
prune_dir "$REPO_SCREENSHOT_DIR" "$skin" "$header.mp4"
prune_dir "$REPO_RANKING_PANEL_DIR" "$skin" "$header.webp"
prune_dir "$REPO_MOD_ICONS_DIR" "$skin" "$header-mod-icons.webp"
prune_dir "$REPO_THUMBNAIL_DIR" "$skin" "$header.webp"
prune_dir "$OSK_PATH" "$skin" "$header.osk"
prune_dir "$DOC_DIR" "$skin" "$header.md"
done
echo "[Cleanup Extra Files Complete]"

View File

@@ -1,27 +1,27 @@
name: "Create New Tag" name: "Create New Tag"
description: "Compute the next semantic version tag based on existing tags" description: "Compute the next semantic version tag based on existing tags"
outputs: outputs:
new_tag: new_tag:
description: "The new tag computed for this build" description: "The new tag computed for this build"
value: ${{ steps.tag.outputs.new_tag }} value: ${{ steps.tag.outputs.new_tag }}
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Create New Tag - name: Create New Tag
id: tag id: tag
shell: bash shell: bash
run: | run: |
echo "Computing new tag..." echo "Computing new tag..."
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "") latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "")
if [ -z "$latest_tag" ]; then if [ -z "$latest_tag" ]; then
new_tag="v1.0.0" new_tag="v1.0.0"
else else
IFS='.' read -r major minor patch <<< "${latest_tag#v}" IFS='.' read -r major minor patch <<< "${latest_tag#v}"
minor=$((minor + 1)) minor=$((minor + 1))
patch=0 patch=0
new_tag="v${major}.${minor}.${patch}" new_tag="v${major}.${minor}.${patch}"
fi fi
echo "new_tag=$new_tag" >> $GITHUB_OUTPUT echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
echo "Computed new tag: $new_tag" echo "Computed new tag: $new_tag"

View File

@@ -1,145 +1,145 @@
name: "Discover and Detect Skins" name: "Discover and Detect Skins"
description: "Find all skins and detect which ones changed since last tag or based on inputs" description: "Find all skins and detect which ones changed since last tag or based on inputs"
inputs: inputs:
force_rebuild: force_rebuild:
description: "Force rebuild all skins" description: "Force rebuild all skins"
required: false required: false
default: "false" default: "false"
target_skins: target_skins:
description: "Comma-separated list of skins to rebuild" description: "Comma-separated list of skins to rebuild"
required: false required: false
default: "" default: ""
outputs: outputs:
changed_skins_file: changed_skins_file:
description: "Path to file containing changed skins" description: "Path to file containing changed skins"
value: ${{ steps.detect.outputs.changed_skins_file }} value: ${{ steps.detect.outputs.changed_skins_file }}
all_skins: all_skins:
description: "All discovered skins (JSON array)" description: "All discovered skins (JSON array)"
value: ${{ steps.discover_all.outputs.all_skins }} value: ${{ steps.discover_all.outputs.all_skins }}
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Discover all skins - name: Discover all skins
id: discover_all id: discover_all
shell: bash shell: bash
run: | run: |
echo "Discovering all skins in $SKINS_DIR…" echo "Discovering all skins in $SKINS_DIR…"
mapfile -t skins < <( mapfile -t skins < <(
find "$SKINS_DIR" -mindepth 1 -maxdepth 1 -type d \ find "$SKINS_DIR" -mindepth 1 -maxdepth 1 -type d \
| sed 's|'"$SKINS_DIR"'/||' | sed 's|'"$SKINS_DIR"'/||'
) )
# Convert to compact JSON # Convert to compact JSON
json=$(printf '%s\n' "${skins[@]}" | jq -R . | jq -cs .) json=$(printf '%s\n' "${skins[@]}" | jq -R . | jq -cs .)
{ {
echo "all_skins<<EOF" echo "all_skins<<EOF"
echo "$json" echo "$json"
echo "EOF" echo "EOF"
} >> "$GITHUB_OUTPUT" } >> "$GITHUB_OUTPUT"
- name: Detect Changed Skin Directories - name: Detect Changed Skin Directories
id: detect id: detect
shell: bash shell: bash
run: | run: |
echo "[Detect Changed Skin Directories Started]" echo "[Detect Changed Skin Directories Started]"
# Parse JSON back into Bash array # Parse JSON back into Bash array
readarray -t all_skins < <(echo '${{ steps.discover_all.outputs.all_skins }}' | jq -r '.[]') readarray -t all_skins < <(echo '${{ steps.discover_all.outputs.all_skins }}' | jq -r '.[]')
force_rebuild="${{ inputs.force_rebuild }}" force_rebuild="${{ inputs.force_rebuild }}"
target_skins="${{ inputs.target_skins }}" target_skins="${{ inputs.target_skins }}"
skins=() skins=()
deleted_skins=() deleted_skins=()
echo "→ Force rebuild flag: $force_rebuild" echo "→ Force rebuild flag: $force_rebuild"
echo "→ Target skins input: $target_skins" echo "→ Target skins input: $target_skins"
if [[ "$force_rebuild" == "true" ]]; then if [[ "$force_rebuild" == "true" ]]; then
echo "→ Force rebuild is enabled. Using ALL_SKINS_DIR for full list…" echo "→ Force rebuild is enabled. Using ALL_SKINS_DIR for full list…"
skins=("${all_skins[@]}") skins=("${all_skins[@]}")
echo " ✓ Found ${#skins[@]} skin directories (from ALL_SKINS_DIR)" echo " ✓ Found ${#skins[@]} skin directories (from ALL_SKINS_DIR)"
elif [[ -n "$target_skins" ]]; then elif [[ -n "$target_skins" ]]; then
echo "→ Target skins specified. Using target_skins input…" echo "→ Target skins specified. Using target_skins input…"
IFS=',' read -r -a input_skins <<< "$target_skins" IFS=',' read -r -a input_skins <<< "$target_skins"
for s in "${input_skins[@]}"; do for s in "${input_skins[@]}"; do
s="${s#"${s%%[![:space:]]*}"}" s="${s#"${s%%[![:space:]]*}"}"
s="${s%"${s##*[![:space:]]}"}" s="${s%"${s##*[![:space:]]}"}"
[[ -n "$s" ]] && skins+=("$s") [[ -n "$s" ]] && skins+=("$s")
done done
echo " ✓ Found ${#skins[@]} skin(s) from target_skins input" echo " ✓ Found ${#skins[@]} skin(s) from target_skins input"
else else
echo "→ No rebuild flags set. Finding latest git tag..." echo "→ No rebuild flags set. Finding latest git tag..."
latest_tag=$(git tag --sort=-creatordate | head -n 1 || true) latest_tag=$(git tag --sort=-creatordate | head -n 1 || true)
if [[ -n "$latest_tag" ]]; then if [[ -n "$latest_tag" ]]; then
echo "→ Latest tag found: $latest_tag" echo "→ Latest tag found: $latest_tag"
echo "→ Finding added/modified skins since $latest_tag…" echo "→ Finding added/modified skins since $latest_tag…"
mapfile -t skins < <( mapfile -t skins < <(
git diff --name-only -z --diff-filter=AM "$latest_tag" HEAD \ git diff --name-only -z --diff-filter=AM "$latest_tag" HEAD \
| while IFS= read -r -d '' file; do | while IFS= read -r -d '' file; do
[[ $file == Skins/* ]] && echo "${file#Skins/}" | cut -d/ -f1 [[ $file == Skins/* ]] && echo "${file#Skins/}" | cut -d/ -f1
done | sort -u done | sort -u
) )
echo " ✓ Found ${#skins[@]} added/modified skins" echo " ✓ Found ${#skins[@]} added/modified skins"
echo "→ Finding deleted skins since $latest_tag…" echo "→ Finding deleted skins since $latest_tag…"
mapfile -t deleted_skins < <( mapfile -t deleted_skins < <(
git diff --name-only -z --diff-filter=D "$latest_tag" HEAD \ git diff --name-only -z --diff-filter=D "$latest_tag" HEAD \
| while IFS= read -r -d '' file; do | while IFS= read -r -d '' file; do
[[ $file == Skins/* ]] && echo "${file#Skins/}" | cut -d/ -f1 [[ $file == Skins/* ]] && echo "${file#Skins/}" | cut -d/ -f1
done | sort -u done | sort -u
) )
if [ "${#deleted_skins[@]}" -gt 0 ]; then if [ "${#deleted_skins[@]}" -gt 0 ]; then
for d in "${deleted_skins[@]}"; do for d in "${deleted_skins[@]}"; do
echo "→ Skin '$d' was deleted" echo "→ Skin '$d' was deleted"
done done
else else
echo " ✓ No skins deleted" echo " ✓ No skins deleted"
fi fi
else else
echo "→ No tag found. Falling back to ALL_SKINS_DIR for full list…" echo "→ No tag found. Falling back to ALL_SKINS_DIR for full list…"
skins=("${all_skins[@]}") skins=("${all_skins[@]}")
echo " ✓ Found ${#skins[@]} skin directories (from ALL_SKINS_DIR)" echo " ✓ Found ${#skins[@]} skin directories (from ALL_SKINS_DIR)"
fi fi
fi fi
echo "" echo ""
echo "[Cleaning Skin Names]" echo "[Cleaning Skin Names]"
uniq_skins=() uniq_skins=()
for skin in "${skins[@]}"; do for skin in "${skins[@]}"; do
skin="${skin#"${skin%%[![:space:]]*}"}" skin="${skin#"${skin%%[![:space:]]*}"}"
skin="${skin%"${skin##*[![:space:]]}"}" skin="${skin%"${skin##*[![:space:]]}"}"
[[ -n "$skin" ]] && uniq_skins+=("$skin") [[ -n "$skin" ]] && uniq_skins+=("$skin")
done done
echo " ✓ ${#uniq_skins[@]} valid skin names after cleaning" echo " ✓ ${#uniq_skins[@]} valid skin names after cleaning"
echo "" echo ""
if [ "${#uniq_skins[@]}" -eq 0 ]; then if [ "${#uniq_skins[@]}" -eq 0 ]; then
echo "→ No added/modified skins detected." echo "→ No added/modified skins detected."
{ {
echo "changed_skins_file<<EOF" echo "changed_skins_file<<EOF"
echo "" echo ""
echo "EOF" echo "EOF"
} >> "$GITHUB_OUTPUT" } >> "$GITHUB_OUTPUT"
else else
echo "[Writing Changed Skins to File]" echo "[Writing Changed Skins to File]"
changed_skins_file=$(mktemp) changed_skins_file=$(mktemp)
printf "%s\n" "${uniq_skins[@]}" > "$changed_skins_file" printf "%s\n" "${uniq_skins[@]}" > "$changed_skins_file"
echo " ✓ Skins written to $changed_skins_file" echo " ✓ Skins written to $changed_skins_file"
{ {
echo "changed_skins_file<<EOF" echo "changed_skins_file<<EOF"
echo "$changed_skins_file" echo "$changed_skins_file"
echo "EOF" echo "EOF"
} >> "$GITHUB_OUTPUT" } >> "$GITHUB_OUTPUT"
fi fi
echo "" echo ""
echo "[Detect Changed Skin Directories Complete — ${#uniq_skins[@]} skins processed, ${#deleted_skins[@]} skins deleted]" echo "[Detect Changed Skin Directories Complete — ${#uniq_skins[@]} skins processed, ${#deleted_skins[@]} skins deleted]"

View File

@@ -1,271 +1,271 @@
name: "Generate Documentation" name: "Generate Documentation"
description: "Generate README index and per-skin markdown pages" description: "Generate README index and per-skin markdown pages"
inputs: inputs:
new_tag: new_tag:
description: "The new tag for this build" description: "The new tag for this build"
required: true required: true
readme_path: readme_path:
description: "Path to write README.md" description: "Path to write README.md"
required: true required: true
doc_dir: doc_dir:
description: "Directory to write per-skin markdown pages" description: "Directory to write per-skin markdown pages"
required: true required: true
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Generate README - name: Generate README
shell: bash shell: bash
run: | run: |
echo "Generating README index…" echo "Generating README index…"
sanitize_filename() { sanitize_filename() {
echo "$1" | \ echo "$1" | \
tr -d '\000-\037' | \ tr -d '\000-\037' | \
sed -e 's#[\\/:\*\?"<>|]#-#g' | \ sed -e 's#[\\/:\*\?"<>|]#-#g' | \
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
} }
url_encode_path() { url_encode_path() {
local IFS='/' local IFS='/'
local parts=($1) local parts=($1)
local encoded="" local encoded=""
for part in "${parts[@]}"; do for part in "${parts[@]}"; do
[ -n "$encoded" ] && encoded+="/" [ -n "$encoded" ] && encoded+="/"
encoded+=$(printf '%s' "$part" | jq -sRr @uri) encoded+=$(printf '%s' "$part" | jq -sRr @uri)
done done
echo "$encoded" echo "$encoded"
} }
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 "---" > "${{ inputs.readme_path }}" echo "---" > "${{ inputs.readme_path }}"
echo "gitea: none" >> "${{ inputs.readme_path }}" echo "gitea: none" >> "${{ inputs.readme_path }}"
echo "include_toc: true" >> "${{ inputs.readme_path }}" echo "include_toc: true" >> "${{ inputs.readme_path }}"
echo "---" >> "${{ inputs.readme_path }}" echo "---" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
echo "# Skins" >> "${{ inputs.readme_path }}" echo "# Skins" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
echo "<!--" >> "${{ inputs.readme_path }}" echo "<!--" >> "${{ inputs.readme_path }}"
echo "osuid: $OSU_ID" >> "${{ inputs.readme_path }}" echo "osuid: $OSU_ID" >> "${{ inputs.readme_path }}"
echo "-->" >> "${{ inputs.readme_path }}" echo "-->" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
echo "**Go back to [osc/skins]($REGISTRY_URL/osc/skins)**" >> "${{ inputs.readme_path }}" echo "**Go back to [osc/skins]($REGISTRY_URL/osc/skins)**" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
echo "**Click on the Skin name to download it, or click on the thumbnail to see more about the skin, including a video preview, screenshots, and mod icons.**" >> "${{ inputs.readme_path }}" echo "**Click on the Skin name to download it, or click on the thumbnail to see more about the skin, including a video preview, screenshots, and mod icons.**" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
jq -r '.descriptions | to_entries[] | "\(.key)=\(.value)"' "$SKINS_JSON_FILE" > "$DESC_FILE" jq -r '.descriptions | to_entries[] | "\(.key)=\(.value)"' "$SKINS_JSON_FILE" > "$DESC_FILE"
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- || true grep -F -m1 -- "$1=" "$DESC_FILE" 2>/dev/null | cut -d '=' -f2- || true
} }
declare -A ordered declare -A ordered
while IFS= read -r skin; do while IFS= read -r skin; do
[ "$skin" = "default-skin" ] && continue [ "$skin" = "default-skin" ] && continue
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 || 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
name_line=$(grep -a -i -m1 'Name[[:space:]]*:' "$ini_file" || true) name_line=$(grep -a -i -m1 'Name[[:space:]]*:' "$ini_file" || true)
if [ -n "$name_line" ]; then if [ -n "$name_line" ]; then
val="${name_line#*:}" val="${name_line#*:}"
val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
[ -n "$val" ] && skin_header=$(sanitize_filename "$val") [ -n "$val" ] && skin_header=$(sanitize_filename "$val")
fi fi
else else
continue 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/ *$//')"
base_path=$(url_encode_path "$raw_path") base_path=$(url_encode_path "$raw_path")
echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/${{ inputs.new_tag }}/export/${base_path}.osk)" >> "${{ inputs.readme_path }}" echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/${{ inputs.new_tag }}/export/${base_path}.osk)" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
desc=$(get_desc "$skin") desc=$(get_desc "$skin")
[ -n "$desc" ] && { echo "$desc" >> "${{ inputs.readme_path }}"; echo "" >> "${{ inputs.readme_path }}"; } [ -n "$desc" ] && { echo "$desc" >> "${{ inputs.readme_path }}"; echo "" >> "${{ inputs.readme_path }}"; }
if [ -f "$ini_file" ]; then if [ -f "$ini_file" ]; then
author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 || true) author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 || true)
if [ -n "$author_line" ]; then if [ -n "$author_line" ]; then
author=$(echo "$author_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') author=$(echo "$author_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
[ -n "$author" ] && { echo "**Author:** $author" >> "${{ inputs.readme_path }}"; echo "" >> "${{ inputs.readme_path }}"; } [ -n "$author" ] && { echo "**Author:** $author" >> "${{ inputs.readme_path }}"; echo "" >> "${{ inputs.readme_path }}"; }
fi fi
fi fi
echo "[![$skin_header Thumbnail](media/thumbnail/${base_path}.webp)](/docs/${base_path}.md)" >> "${{ inputs.readme_path }}" echo "[![$skin_header Thumbnail](media/thumbnail/${base_path}.webp)](/docs/${base_path}.md)" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
done < order.txt done < order.txt
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")"
[ "$skin" = "default-skin" ] && continue [ "$skin" = "default-skin" ] && continue
[[ -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
name_line=$(grep -a -i -m1 'Name[[:space:]]*:' "$ini_file" || true) name_line=$(grep -a -i -m1 'Name[[:space:]]*:' "$ini_file" || true)
if [ -n "$name_line" ]; then if [ -n "$name_line" ]; then
val="${name_line#*:}" val="${name_line#*:}"
val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
[ -n "$val" ] && skin_header=$(sanitize_filename "$val") [ -n "$val" ] && skin_header=$(sanitize_filename "$val")
fi fi
else else
continue 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/ *$//')"
base_path=$(url_encode_path "$raw_path") base_path=$(url_encode_path "$raw_path")
echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/${{ inputs.new_tag }}/export/${base_path}.osk)" >> "${{ inputs.readme_path }}" echo "## [$skin_header]($REGISTRY_URL/$USER_REPOSITORY/media/tag/${{ inputs.new_tag }}/export/${base_path}.osk)" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
if [ -f "$ini_file" ]; then if [ -f "$ini_file" ]; then
author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 || true) author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 || true)
if [ -n "$author_line" ]; then if [ -n "$author_line" ]; then
author=$(echo "$author_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') author=$(echo "$author_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
[ -n "$author" ] && { echo "**Author:** $author" >> "${{ inputs.readme_path }}"; echo "" >> "${{ inputs.readme_path }}"; } [ -n "$author" ] && { echo "**Author:** $author" >> "${{ inputs.readme_path }}"; echo "" >> "${{ inputs.readme_path }}"; }
fi fi
fi fi
echo "[![$skin_header Thumbnail](media/thumbnail/${base_path}.webp)](/docs/${base_path}.md)" >> "${{ inputs.readme_path }}" echo "[![$skin_header Thumbnail](media/thumbnail/${base_path}.webp)](/docs/${base_path}.md)" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
done done
echo "# Build History" >> "${{ inputs.readme_path }}" echo "# Build History" >> "${{ inputs.readme_path }}"
echo "" >> "${{ inputs.readme_path }}" echo "" >> "${{ inputs.readme_path }}"
echo "| Version | Date |" >> "${{ inputs.readme_path }}" echo "| Version | Date |" >> "${{ inputs.readme_path }}"
echo "| ------- | ---- |" >> "${{ inputs.readme_path }}" echo "| ------- | ---- |" >> "${{ inputs.readme_path }}"
current_commit_date=$(TZ="Europe/Zurich" date -d "$(git log -1 --format=%cI)" "+%d.%m.%Y %H:%M:%S") current_commit_date=$(TZ="Europe/Zurich" date -d "$(git log -1 --format=%cI)" "+%d.%m.%Y %H:%M:%S")
echo "| [\`${{ inputs.new_tag }} (Current)\`]($REGISTRY_URL/$USER_REPOSITORY/src/tag/${{ inputs.new_tag }}/README.md) | $current_commit_date |" >> "${{ inputs.readme_path }}" echo "| [\`${{ inputs.new_tag }} (Current)\`]($REGISTRY_URL/$USER_REPOSITORY/src/tag/${{ inputs.new_tag }}/README.md) | $current_commit_date |" >> "${{ inputs.readme_path }}"
old_tags=$(git tag --sort=-v:refname | grep -v "^${{ inputs.new_tag }}$" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true) old_tags=$(git tag --sort=-v:refname | grep -v "^${{ inputs.new_tag }}$" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true)
if [ -n "$old_tags" ]; then if [ -n "$old_tags" ]; then
echo "$old_tags" | while read -r tag; do echo "$old_tags" | while read -r tag; do
tag_date=$(git log -1 --format=%ci "$tag") tag_date=$(git log -1 --format=%ci "$tag")
formatted_date=$(TZ="Europe/Zurich" date -d "$tag_date" "+%d.%m.%Y %H:%M:%S") formatted_date=$(TZ="Europe/Zurich" date -d "$tag_date" "+%d.%m.%Y %H:%M:%S")
echo "| [\`$tag\`]($REGISTRY_URL/$USER_REPOSITORY/src/tag/$tag/README.md) | $formatted_date |" >> "${{ inputs.readme_path }}" echo "| [\`$tag\`]($REGISTRY_URL/$USER_REPOSITORY/src/tag/$tag/README.md) | $formatted_date |" >> "${{ inputs.readme_path }}"
done done
fi fi
echo "README index generated successfully." echo "README index generated successfully."
- name: Generate Per-Skin Pages - name: Generate Per-Skin Pages
shell: bash shell: bash
run: | run: |
echo "Generating detailed per-skin markdown pages…" echo "Generating detailed per-skin markdown pages…"
sanitize_filename() { sanitize_filename() {
echo "$1" | \ echo "$1" | \
tr -d '\000-\037' | \ tr -d '\000-\037' | \
sed -e 's#[\\/:\*\?"<>|]#-#g' | \ sed -e 's#[\\/:\*\?"<>|]#-#g' | \
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
} }
url_encode_path() { url_encode_path() {
local IFS='/' local IFS='/'
local parts=($1) local parts=($1)
local encoded="" local encoded=""
for part in "${parts[@]}"; do for part in "${parts[@]}"; do
[ -n "$encoded" ] && encoded+="/" [ -n "$encoded" ] && encoded+="/"
encoded+=$(printf '%s' "$part" | jq -sRr @uri) encoded+=$(printf '%s' "$part" | jq -sRr @uri)
done done
echo "$encoded" echo "$encoded"
} }
mkdir -p "${{ inputs.doc_dir }}" mkdir -p "${{ inputs.doc_dir }}"
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")
[ "$skin" = "default-skin" ] && continue [ "$skin" = "default-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) line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1 || true)
if [ -n "$line" ]; then if [ -n "$line" ]; then
val="${line#*:}" val="${line#*:}"
val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
if [ -n "$val" ]; then if [ -n "$val" ]; then
skin_header=$(sanitize_filename "$val") skin_header=$(sanitize_filename "$val")
fi fi
fi fi
fi fi
raw_path="${skin}/${skin_header}" raw_path="${skin}/${skin_header}"
base_path=$(url_encode_path "$raw_path") base_path=$(url_encode_path "$raw_path")
osk_url="$REGISTRY_URL/$USER_REPOSITORY/media/tag/${{ inputs.new_tag }}/export/${base_path}.osk" osk_url="$REGISTRY_URL/$USER_REPOSITORY/media/tag/${{ inputs.new_tag }}/export/${base_path}.osk"
md_file_path="${{ inputs.doc_dir }}/${raw_path}.md" md_file_path="${{ inputs.doc_dir }}/${raw_path}.md"
mkdir -p "$(dirname "$md_file_path")" mkdir -p "$(dirname "$md_file_path")"
video_url="$REGISTRY_URL/$USER_REPOSITORY/media/tag/${{ inputs.new_tag }}/media/gameplay/${base_path}.mp4" video_url="$REGISTRY_URL/$USER_REPOSITORY/media/tag/${{ inputs.new_tag }}/media/gameplay/${base_path}.mp4"
author="" author=""
if [ -f "$ini_file" ]; then if [ -f "$ini_file" ]; then
author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 || true) author_line=$(grep -i '^[[:space:]]*Author:' "$ini_file" | head -n1 || true)
if [ -n "$author_line" ]; then if [ -n "$author_line" ]; then
author=$(echo "$author_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') author=$(echo "$author_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
fi fi
fi fi
{ {
echo "# [$skin_header]($osk_url)" echo "# [$skin_header]($osk_url)"
echo "" echo ""
[ -n "$author" ] && echo "**Author:** $author" [ -n "$author" ] && echo "**Author:** $author"
[ -n "$author" ] && echo "" [ -n "$author" ] && echo ""
echo "## Hitsounds" 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 "## Ranking Panel"
echo "![](/media/panel/${base_path}.webp)" echo "![](/media/panel/${base_path}.webp)"
echo "" echo ""
echo "## Mod Icons" echo "## Mod Icons"
echo "![](/media/icons/${base_path}-mod-icons.webp)" echo "![](/media/icons/${base_path}-mod-icons.webp)"
echo "" echo ""
echo "## Build History" echo "## Build History"
echo "" echo ""
echo "| Version | Date |" echo "| Version | Date |"
echo "| ------- | ---- |" echo "| ------- | ---- |"
current_commit_date=$(TZ="Europe/Zurich" date -d "$(git log -1 --format=%cI)" "+%d.%m.%Y %H:%M:%S") current_commit_date=$(TZ="Europe/Zurich" date -d "$(git log -1 --format=%cI)" "+%d.%m.%Y %H:%M:%S")
echo "| [\`${{ inputs.new_tag }} (Current)\`]($REGISTRY_URL/$USER_REPOSITORY/src/tag/${{ inputs.new_tag }}/docs/${base_path}.md) | $current_commit_date |" echo "| [\`${{ inputs.new_tag }} (Current)\`]($REGISTRY_URL/$USER_REPOSITORY/src/tag/${{ inputs.new_tag }}/docs/${base_path}.md) | $current_commit_date |"
old_tags=$(git tag --sort=-v:refname | grep -v "^${{ inputs.new_tag }}$" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true) old_tags=$(git tag --sort=-v:refname | grep -v "^${{ inputs.new_tag }}$" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true)
if [ -n "$old_tags" ]; then if [ -n "$old_tags" ]; then
echo "$old_tags" | while read -r tag; do echo "$old_tags" | while read -r tag; do
raw_osk_path="export/${skin}/${skin_header}.osk" raw_osk_path="export/${skin}/${skin_header}.osk"
if git ls-tree -r --name-only "$tag" | grep -Fx -- "$raw_osk_path" >/dev/null; then if git ls-tree -r --name-only "$tag" | grep -Fx -- "$raw_osk_path" >/dev/null; then
tag_date=$(git log -1 --format=%ci "$tag") tag_date=$(git log -1 --format=%ci "$tag")
formatted_date=$(TZ="Europe/Zurich" date -d "$tag_date" "+%d.%m.%Y %H:%M:%S") formatted_date=$(TZ="Europe/Zurich" date -d "$tag_date" "+%d.%m.%Y %H:%M:%S")
echo "| [\`$tag\`]($REGISTRY_URL/$USER_REPOSITORY/src/tag/$tag/docs/${base_path}.md) | $formatted_date |" echo "| [\`$tag\`]($REGISTRY_URL/$USER_REPOSITORY/src/tag/$tag/docs/${base_path}.md) | $formatted_date |"
fi fi
done done
fi fi
} > "$md_file_path" } > "$md_file_path"
echo " → Wrote $md_file_path" echo " → Wrote $md_file_path"
done done
echo "Per-skin markdown pages complete." echo "Per-skin markdown pages complete."

View File

@@ -1,146 +1,146 @@
name: "Generate Mod Icons and Convert Images" name: "Generate Mod Icons and Convert Images"
description: "Generate WEBP mod icons from skins and convert panel/thumbnail PNGs to WEBPs" description: "Generate WEBP mod icons from skins and convert panel/thumbnail PNGs to WEBPs"
inputs: inputs:
changed_skins_file: changed_skins_file:
description: "Path to file with changed skins" description: "Path to file with changed skins"
required: true required: true
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Generate Mod Icons (WEBP) - name: Generate Mod Icons (WEBP)
shell: bash shell: bash
run: | run: |
echo "[Mod Icon Generation Job Started]" echo "[Mod Icon Generation Job Started]"
if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then
echo "No skins changed. Skipping mod icon generation." echo "No skins changed. Skipping mod icon generation."
exit 0 exit 0
fi fi
mapfile -t skin_dirs < "${{ inputs.changed_skins_file }}" mapfile -t skin_dirs < "${{ inputs.changed_skins_file }}"
[ "${#skin_dirs[@]}" -eq 0 ] && { echo "No skins to process. Exiting."; exit 0; } [ "${#skin_dirs[@]}" -eq 0 ] && { echo "No skins to process. Exiting."; exit 0; }
sanitize_filename() { sanitize_filename() {
echo "$1" | \ echo "$1" | \
tr -d '\000-\037' | \ tr -d '\000-\037' | \
sed -e 's#[\\/:\*\?"<>|]#-#g' | \ sed -e 's#[\\/:\*\?"<>|]#-#g' | \
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
} }
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")
group3_icons=$(jq -r '.group3 | join(" ")' "$ICONS_JSON_FILE") group3_icons=$(jq -r '.group3 | join(" ")' "$ICONS_JSON_FILE")
BLANK_IMAGE="blank.png" BLANK_IMAGE="blank.png"
magick -size "160x160" xc:none "$BLANK_IMAGE" magick -size "160x160" xc:none "$BLANK_IMAGE"
SKIN_COUNT=${#skin_dirs[@]} SKIN_COUNT=${#skin_dirs[@]}
INDEX=1 INDEX=1
for skin_path in "${skin_dirs[@]}"; do for skin_path in "${skin_dirs[@]}"; do
SKIN_DIR="$DANSER_SKINS_DIR/$skin_path" SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
[ ! -d "$SKIN_DIR" ] && { echo "Skipping missing skin directory: $SKIN_DIR"; ((INDEX++)); continue; } [ ! -d "$SKIN_DIR" ] && { echo "Skipping missing skin directory: $SKIN_DIR"; ((INDEX++)); continue; }
skin_header="$skin_path" skin_header="$skin_path"
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n1 || 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 -n1 || true) name_line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1 || true)
if [ -n "$name_line" ]; then if [ -n "$name_line" ]; then
val="${name_line#*:}" val="${name_line#*:}"
val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
if [ -n "$val" ]; then if [ -n "$val" ]; then
sanitized="$(sanitize_filename "$val")" sanitized="$(sanitize_filename "$val")"
[ -n "$sanitized" ] && skin_header="$sanitized" [ -n "$sanitized" ] && skin_header="$sanitized"
fi fi
fi fi
fi fi
echo "" echo ""
echo "[$INDEX/$SKIN_COUNT] Skin: $skin_header" echo "[$INDEX/$SKIN_COUNT] Skin: $skin_header"
ICON_FOLDER="$SKIN_DIR" ICON_FOLDER="$SKIN_DIR"
OUTPUT_DIR="$REPO_MOD_ICONS_DIR/$skin_path" OUTPUT_DIR="$REPO_MOD_ICONS_DIR/$skin_path"
mkdir -p "$OUTPUT_DIR" mkdir -p "$OUTPUT_DIR"
OUTPUT="$OUTPUT_DIR/${skin_header}-mod-icons.webp" OUTPUT="$OUTPUT_DIR/${skin_header}-mod-icons.webp"
row_images=() row_images=()
row_index=1 row_index=1
for group_list in "$group1_icons" "$group2_icons" "$group3_icons"; do for group_list in "$group1_icons" "$group2_icons" "$group3_icons"; do
montage_files=() montage_files=()
for icon in $group_list; do for icon in $group_list; do
file="" file=""
if [ -f "${ICON_FOLDER}/selection-mod-${icon}@2x.png" ]; then if [ -f "${ICON_FOLDER}/selection-mod-${icon}@2x.png" ]; then
file="${ICON_FOLDER}/selection-mod-${icon}@2x.png" file="${ICON_FOLDER}/selection-mod-${icon}@2x.png"
elif [ -f "${ICON_FOLDER}/selection-mod-${icon}.png" ]; then elif [ -f "${ICON_FOLDER}/selection-mod-${icon}.png" ]; then
file="${ICON_FOLDER}/selection-mod-${icon}.png" file="${ICON_FOLDER}/selection-mod-${icon}.png"
elif [ -f "${DEFAULT_SKIN_DIR}/selection-mod-${icon}@2x.png" ]; then elif [ -f "${DEFAULT_SKIN_DIR}/selection-mod-${icon}@2x.png" ]; then
file="${DEFAULT_SKIN_DIR}/selection-mod-${icon}@2x.png" file="${DEFAULT_SKIN_DIR}/selection-mod-${icon}@2x.png"
fi fi
[ -n "$file" ] && montage_files+=("$file") [ -n "$file" ] && montage_files+=("$file")
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[@]}" \ magick montage "${montage_files[@]}" \
-tile "7x1" -geometry "160x160+10+10" -background none \ -tile "7x1" -geometry "160x160+10+10" -background none \
"row_${row_index}.png" "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))
done done
magick montage "${row_images[@]}" \ magick montage "${row_images[@]}" \
-tile "1x${#row_images[@]}" -geometry "+10+10" -background none \ -tile "1x${#row_images[@]}" -geometry "+10+10" -background none \
"temp_combined.png" "temp_combined.png"
magick "temp_combined.png" -define webp:lossless=true "$OUTPUT" magick "temp_combined.png" -define webp:lossless=true "$OUTPUT"
rm temp_combined.png row_*.png rm temp_combined.png row_*.png
echo " ✓ Mod Icons Generated at $OUTPUT" echo " ✓ Mod Icons Generated at $OUTPUT"
INDEX=$((INDEX + 1)) INDEX=$((INDEX + 1))
done done
rm "$BLANK_IMAGE" rm "$BLANK_IMAGE"
echo "" echo ""
echo "[Mod Icon Generation Finished — processed $SKIN_COUNT skins]" echo "[Mod Icon Generation Finished — processed $SKIN_COUNT skins]"
- name: Convert PNGs to WEBPs - name: Convert PNGs to WEBPs
shell: bash shell: bash
run: | run: |
echo "[Convert PNG → WEBP Started]" echo "[Convert PNG → WEBP Started]"
if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then
echo "No skins changed. Skipping conversion." echo "No skins changed. Skipping conversion."
exit 0 exit 0
fi fi
mapfile -t skins < "${{ inputs.changed_skins_file }}" mapfile -t skins < "${{ inputs.changed_skins_file }}"
[ "${#skins[@]}" -eq 0 ] && { echo "No skins to process. Exiting."; exit 0; } [ "${#skins[@]}" -eq 0 ] && { echo "No skins to process. Exiting."; exit 0; }
convert_pngs_to_webp() { convert_pngs_to_webp() {
local base_dir="$1" local base_dir="$1"
local skin_path="$2" local skin_path="$2"
local dir="$base_dir/$skin_path" local dir="$base_dir/$skin_path"
echo " → Processing: $dir" echo " → Processing: $dir"
[ ! -d "$dir" ] && { echo " ✖ Directory does not exist: $dir"; return; } [ ! -d "$dir" ] && { echo " ✖ Directory does not exist: $dir"; return; }
find "$dir" -type f -iname "*.png" | while read -r png; do find "$dir" -type f -iname "*.png" | while read -r png; do
webp="${png%.png}.webp" webp="${png%.png}.webp"
echo " ↳ Converting: $png → $webp" echo " ↳ Converting: $png → $webp"
magick "$png" -define webp:lossless=false -quality 90 "$webp" && rm -f "$png" magick "$png" -define webp:lossless=false -quality 90 "$webp" && rm -f "$png"
done done
} }
for skin_path in "${skins[@]}"; do for skin_path in "${skins[@]}"; do
[ -z "$skin_path" ] && continue [ -z "$skin_path" ] && continue
convert_pngs_to_webp "$REPO_RANKING_PANEL_DIR" "$skin_path" convert_pngs_to_webp "$REPO_RANKING_PANEL_DIR" "$skin_path"
convert_pngs_to_webp "$REPO_THUMBNAIL_DIR" "$skin_path" convert_pngs_to_webp "$REPO_THUMBNAIL_DIR" "$skin_path"
done done
echo "[Convert PNG → WEBP Finished]" echo "[Convert PNG → WEBP Finished]"

View File

@@ -1,149 +1,183 @@
name: "Generate Previews" name: "Generate Previews"
description: "Generate Danser videos, screenshots, thumbnails, and rename them based on skin.ini" description: "Generate Danser videos, screenshots, thumbnails, and rename them based on skin.ini"
inputs: inputs:
changed_skins_file: changed_skins_file:
description: "Path to file with changed skins" description: "Path to JSON file containing changed skins"
required: true required: true
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Generate Danser videos and screenshots - name: Generate Danser videos and screenshots
shell: bash shell: bash
run: | run: |
echo "[Danser Job Started]" echo "[Danser Job Started]"
if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then
echo "No skins changed. Skipping generation." echo "No skins changed. Skipping generation."
exit 0 exit 0
fi fi
mapfile -t skins < "${{ inputs.changed_skins_file }}" mapfile -t skins < <(jq -r '.[]' "${{ inputs.changed_skins_file }}")
[ "${#skins[@]}" -eq 0 ] && { echo "No skins to process. Exiting."; exit 0; } [ "${#skins[@]}" -eq 0 ] && { echo "No skins to process. Exiting."; exit 0; }
SKIN_COUNT=${#skins[@]} SKIN_COUNT=${#skins[@]}
INDEX=1 INDEX=1
sanitize_filename() { for skin_path in "${skins[@]}"; do
echo "$1" | \ [ -z "$skin_path" ] && continue
tr -d '\000-\037' | \ SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
sed -e 's#[\\/:\*\?"<>|]#-#g' | \ [ ! -d "$SKIN_DIR" ] && { echo "Skipping missing skin: $skin_path"; continue; }
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
} SKIN_NAME="$skin_path"
OUT_VIDEO_DIR="$REPO_SCREENSHOT_DIR/$SKIN_NAME"
for skin_path in "${skins[@]}"; do OUT_PNG_DIR="$REPO_RANKING_PANEL_DIR/$SKIN_NAME"
[ -z "$skin_path" ] && continue OUT_THUMBNAIL_DIR="$REPO_THUMBNAIL_DIR/$SKIN_NAME"
SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
[ ! -d "$SKIN_DIR" ] && { echo "Skipping missing skin: $skin_path"; continue; } echo ""
echo "[$INDEX/$SKIN_COUNT] Generating for skin: $SKIN_NAME"
SKIN_NAME="$skin_path"
OUT_VIDEO_DIR="$REPO_SCREENSHOT_DIR/$SKIN_NAME" LOGFILE="/tmp/danser_log_$INDEX.txt"
OUT_PNG_DIR="$REPO_RANKING_PANEL_DIR/$SKIN_NAME"
OUT_THUMBNAIL_DIR="$REPO_THUMBNAIL_DIR/$SKIN_NAME" echo " → Generating video..."
if ! xvfb-run -a "$DANSER_DIR/danser-cli" \
echo "" -replay "$GAMEPLAY_REPLAY_PATH" -record -skip -start=300 -end=307 -noupdatecheck \
echo "[$INDEX/$SKIN_COUNT] Generating for skin: $SKIN_NAME" -out="$SKIN_NAME" -skin="$SKIN_NAME" -settings="skinhub" >"$LOGFILE" 2>&1; then
echo " ✖ Video failed for $SKIN_NAME"; cat "$LOGFILE"; INDEX=$((INDEX+1)); continue
LOGFILE="/tmp/danser_log_$INDEX.txt" fi
echo " → Generating video..." if [ -f "$DANSER_VIDEO_DIR/$SKIN_NAME.mp4" ]; then
if ! xvfb-run -a "$DANSER_DIR/danser-cli" \ echo " → Trimming MP4 with ffmpeg..."
-replay "$GAMEPLAY_REPLAY_PATH" -record -skip -start=300 -end=307 -noupdatecheck \ ffmpeg -hide_banner -loglevel error \
-out="$SKIN_NAME" -skin="$SKIN_NAME" -settings="skinhub" >"$LOGFILE" 2>&1; then -ss 5 -t 6.5 \
echo " ✖ Video failed for $SKIN_NAME"; cat "$LOGFILE"; INDEX=$((INDEX+1)); continue -i "$DANSER_VIDEO_DIR/$SKIN_NAME.mp4" \
fi -c:v h264_nvenc -preset fast \
-c:a aac -b:a 128k \
if [ -f "$DANSER_VIDEO_DIR/$SKIN_NAME.mp4" ]; then "$DANSER_VIDEO_DIR/${SKIN_NAME}_trimmed.mp4"
echo " → Trimming MP4 with ffmpeg..."
ffmpeg -hide_banner -loglevel error \ if [ -f "$DANSER_VIDEO_DIR/${SKIN_NAME}_trimmed.mp4" ]; then
-ss 5 -t 6.5 \ mv "$DANSER_VIDEO_DIR/${SKIN_NAME}_trimmed.mp4" "$DANSER_VIDEO_DIR/$SKIN_NAME.mp4"
-i "$DANSER_VIDEO_DIR/$SKIN_NAME.mp4" \ mkdir -p "$OUT_VIDEO_DIR"
-c:v h264_nvenc -preset fast \ mv "$DANSER_VIDEO_DIR/$SKIN_NAME.mp4" "$OUT_VIDEO_DIR/$SKIN_NAME.mp4"
-c:a aac -b:a 128k \ echo " ✓ Trimmed MP4 moved to $OUT_VIDEO_DIR/"
"$DANSER_VIDEO_DIR/${SKIN_NAME}_trimmed.mp4" else
echo " ✖ ffmpeg trimming failed for $SKIN_NAME"
if [ -f "$DANSER_VIDEO_DIR/${SKIN_NAME}_trimmed.mp4" ]; then fi
mv "$DANSER_VIDEO_DIR/${SKIN_NAME}_trimmed.mp4" "$DANSER_VIDEO_DIR/$SKIN_NAME.mp4" else
mkdir -p "$OUT_VIDEO_DIR" echo " ✖ No MP4 found for $SKIN_NAME"
mv "$DANSER_VIDEO_DIR/$SKIN_NAME.mp4" "$OUT_VIDEO_DIR/$SKIN_NAME.mp4" fi
echo " ✓ Trimmed MP4 moved to $OUT_VIDEO_DIR/"
else echo " → Taking screenshot..."
echo " ✖ ffmpeg trimming failed for $SKIN_NAME" if ! xvfb-run -a "$DANSER_DIR/danser-cli" \
fi -replay "$PANEL_REPLAY_PATH" -skip -settings="skinhub" -noupdatecheck -ss 28 \
else -out="$SKIN_NAME" -skin="$SKIN_NAME" >>"$LOGFILE" 2>&1; then
echo " ✖ No MP4 found for $SKIN_NAME" echo " ✖ Screenshot failed for $SKIN_NAME"; cat "$LOGFILE"; INDEX=$((INDEX+1)); continue
fi fi
echo " → Taking screenshot..." if [ -f "$DANSER_SCREENSHOT_DIR/$SKIN_NAME.png" ]; then
if ! xvfb-run -a "$DANSER_DIR/danser-cli" \ mkdir -p "$OUT_PNG_DIR"
-replay "$PANEL_REPLAY_PATH" -skip -settings="skinhub" -noupdatecheck -ss 28 \ mv "$DANSER_SCREENSHOT_DIR/$SKIN_NAME.png" "$OUT_PNG_DIR/$SKIN_NAME.png"
-out="$SKIN_NAME" -skin="$SKIN_NAME" >>"$LOGFILE" 2>&1; then echo " ✓ PNG moved to $OUT_PNG_DIR/"
echo " ✖ Screenshot failed for $SKIN_NAME"; cat "$LOGFILE"; INDEX=$((INDEX+1)); continue else
fi echo " ✖ No PNG found for $SKIN_NAME"
fi
if [ -f "$DANSER_SCREENSHOT_DIR/$SKIN_NAME.png" ]; then
mkdir -p "$OUT_PNG_DIR" echo " → Taking thumbnail screenshot..."
mv "$DANSER_SCREENSHOT_DIR/$SKIN_NAME.png" "$OUT_PNG_DIR/$SKIN_NAME.png" if ! xvfb-run -a "$DANSER_DIR/danser-cli" \
echo " ✓ PNG moved to $OUT_PNG_DIR/" -replay "$THUMBNAIL_REPLAY_PATH" -skip -settings="skinhub" -noupdatecheck -ss 1.3 \
else -out="${SKIN_NAME}_thumb" -skin="$SKIN_NAME" >>"$LOGFILE" 2>&1; then
echo " ✖ No PNG found for $SKIN_NAME" echo " ✖ Thumbnail screenshot failed for $SKIN_NAME"; cat "$LOGFILE"; INDEX=$((INDEX+1)); continue
fi fi
echo " → Taking thumbnail screenshot..." if [ -f "$DANSER_SCREENSHOT_DIR/${SKIN_NAME}_thumb.png" ]; then
if ! xvfb-run -a "$DANSER_DIR/danser-cli" \ mkdir -p "$OUT_THUMBNAIL_DIR"
-replay "$THUMBNAIL_REPLAY_PATH" -skip -settings="skinhub" -noupdatecheck -ss 1.3 \ mv "$DANSER_SCREENSHOT_DIR/${SKIN_NAME}_thumb.png" "$OUT_THUMBNAIL_DIR/$SKIN_NAME.png"
-out="${SKIN_NAME}_thumb" -skin="$SKIN_NAME" >>"$LOGFILE" 2>&1; then echo " ✓ Thumbnail PNG moved to $OUT_THUMBNAIL_DIR/"
echo " ✖ Thumbnail screenshot failed for $SKIN_NAME"; cat "$LOGFILE"; INDEX=$((INDEX+1)); continue else
fi echo " ✖ No thumbnail PNG found for $SKIN_NAME"
fi
if [ -f "$DANSER_SCREENSHOT_DIR/${SKIN_NAME}_thumb.png" ]; then
mkdir -p "$OUT_THUMBNAIL_DIR" INDEX=$((INDEX + 1))
mv "$DANSER_SCREENSHOT_DIR/${SKIN_NAME}_thumb.png" "$OUT_THUMBNAIL_DIR/$SKIN_NAME.png" done
echo " ✓ Thumbnail PNG moved to $OUT_THUMBNAIL_DIR/"
else echo ""
echo " ✖ No thumbnail PNG found for $SKIN_NAME" echo "[Danser Job Finished — processed $SKIN_COUNT skins]"
fi
- name: Rename Generated Assets Based on skin.ini
# --- Renaming Section --- shell: bash
skin_header="$SKIN_NAME" run: |
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n1 || true) echo "[Asset Renaming Job Started]"
if [ -f "$ini_file" ]; then
name_line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1 || true) if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then
if [ -n "$name_line" ]; then echo "No skins changed. Skipping asset renaming."
val="${name_line#*:}" exit 0
val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" fi
if [ -n "$val" ]; then
sanitized="$(sanitize_filename "$val")" # Load skins from JSON
[ -n "$sanitized" ] && skin_header="$sanitized" mapfile -t skins < <(jq -r '.[]' "${{ inputs.changed_skins_file }}")
fi [ "${#skins[@]}" -eq 0 ] && { echo "No skins to rename. Exiting."; exit 0; }
fi
fi SKIN_COUNT=${#skins[@]}
INDEX=1
VIDEO_DIR="$REPO_SCREENSHOT_DIR/$SKIN_DIR_NAME"
PNG_DIR="$REPO_RANKING_PANEL_DIR/$SKIN_DIR_NAME" sanitize_filename() {
THUMBNAIL_DIR="$REPO_THUMBNAIL_DIR/$SKIN_DIR_NAME" echo "$1" | \
tr -d '\000-\037' | \
if [ -f "$VIDEO_DIR/$SKIN_DIR_NAME.mp4" ] && [ "$SKIN_DIR_NAME" != "$skin_header" ]; then sed -e 's#[\\/:\*\?"<>|]#-#g' | \
mv -f "$VIDEO_DIR/$SKIN_DIR_NAME.mp4" \ sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
"$VIDEO_DIR/$skin_header.mp4" || true }
echo " ✓ Renamed MP4 to $VIDEO_DIR/$skin_header.mp4"
fi for skin_path in "${skins[@]}"; do
[ -z "$skin_path" ] && continue
if [ -f "$PNG_DIR/$SKIN_DIR_NAME.png" ] && [ "$SKIN_DIR_NAME" != "$skin_header" ]; then SKIN_DIR_NAME="$skin_path"
mv -f "$PNG_DIR/$SKIN_DIR_NAME.png" \ SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
"$PNG_DIR/$skin_header.png" || true
echo " ✓ Renamed PNG to $PNG_DIR/$skin_header.png" if [ ! -d "$SKIN_DIR" ]; then
fi echo "Skipping missing skin directory: $SKIN_DIR"
continue
if [ -f "$THUMBNAIL_DIR/$SKIN_DIR_NAME.png" ] && [ "$SKIN_DIR_NAME" != "$skin_header" ]; then fi
mv -f "$THUMBNAIL_DIR/$SKIN_DIR_NAME.png" \
"$THUMBNAIL_DIR/$skin_header.png" || true echo "Processing skin $INDEX/$SKIN_COUNT: $SKIN_DIR_NAME"
echo " ✓ Renamed thumbnail to $THUMBNAIL_DIR/$skin_header.png"
fi skin_header="$SKIN_DIR_NAME"
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n1 || true)
INDEX=$((INDEX + 1)) if [ -f "$ini_file" ]; then
done name_line=$(grep -i '^[[:space:]]*Name:' "$ini_file" | head -n1 || true)
if [ -n "$name_line" ]; then
echo "" val="${name_line#*:}"
echo "[Danser Job Finished — processed $SKIN_COUNT skins]" val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
if [ -n "$val" ]; then
sanitized="$(sanitize_filename "$val")"
[ -n "$sanitized" ] && skin_header="$sanitized"
fi
fi
fi
VIDEO_DIR="$REPO_SCREENSHOT_DIR/$SKIN_DIR_NAME"
PNG_DIR="$REPO_RANKING_PANEL_DIR/$SKIN_DIR_NAME"
THUMBNAIL_DIR="$REPO_THUMBNAIL_DIR/$SKIN_DIR_NAME"
if [ -f "$VIDEO_DIR/$SKIN_DIR_NAME.mp4" ] && [ "$SKIN_DIR_NAME" != "$skin_header" ]; then
mv -f "$VIDEO_DIR/$SKIN_DIR_NAME.mp4" \
"$VIDEO_DIR/$skin_header.mp4" || true
echo " ✓ Renamed MP4 to $VIDEO_DIR/$skin_header.mp4"
fi
if [ -f "$PNG_DIR/$SKIN_DIR_NAME.png" ] && [ "$SKIN_DIR_NAME" != "$skin_header" ]; then
mv -f "$PNG_DIR/$SKIN_DIR_NAME.png" \
"$PNG_DIR/$skin_header.png" || true
echo " ✓ Renamed PNG to $PNG_DIR/$skin_header.png"
fi
if [ -f "$THUMBNAIL_DIR/$SKIN_DIR_NAME.png" ] && [ "$SKIN_DIR_NAME" != "$skin_header" ]; then
mv -f "$THUMBNAIL_DIR/$SKIN_DIR_NAME.png" \
"$THUMBNAIL_DIR/$skin_header.png" || true
echo " ✓ Renamed thumbnail to $THUMBNAIL_DIR/$skin_header.png"
fi
INDEX=$((INDEX + 1))
done
echo ""
echo "[Asset Renaming Complete — processed $SKIN_COUNT skins]"

View File

@@ -1,40 +1,40 @@
name: "Commit and Push Changes" name: "Commit and Push Changes"
description: "Configure Git, commit changes, push to branch, and tag release" description: "Configure Git, commit changes, push to branch, and tag release"
inputs: inputs:
new_tag: new_tag:
description: "The tag to create and push" description: "The tag to create and push"
required: true required: true
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Configure Git - name: Configure Git
shell: bash shell: bash
run: | run: |
git config user.name "${{ github.actor }}" git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.${{ github.server_url }}" git config user.email "${{ github.actor }}@users.noreply.${{ github.server_url }}"
- name: Add and Commit changes - name: Add and Commit changes
shell: bash shell: bash
run: | run: |
git config advice.addIgnoredFile false git config advice.addIgnoredFile false
for p in docs/ media/gameplay media/thumbnail media/panel media/icons export README.md how-to-use.md src; do for p in docs/ media/gameplay media/thumbnail media/panel media/icons export README.md how-to-use.md src; do
if [ -e "$p" ]; then if [ -e "$p" ]; then
git add -A "$p" git add -A "$p"
fi fi
done done
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
shell: bash shell: bash
run: | run: |
if [ "${GITHUB_REF}" = "refs/heads/main" ]; then if [ "${GITHUB_REF}" = "refs/heads/main" ]; then
git push origin HEAD:main || echo "No changes to push" git push origin HEAD:main || echo "No changes to push"
git tag "${{ inputs.new_tag }}" git tag "${{ inputs.new_tag }}"
git push origin "${{ inputs.new_tag }}" git push origin "${{ inputs.new_tag }}"
else else
git push origin HEAD:"${GITHUB_REF_NAME}" || echo "No changes to push" git push origin HEAD:"${GITHUB_REF_NAME}" || echo "No changes to push"
fi fi

View File

@@ -1,62 +1,62 @@
name: "Prepare Assets" name: "Prepare Assets"
description: "Setup environment dirs and create directories for assets" description: "Setup environment dirs and create directories for assets"
inputs: inputs:
all_skins: all_skins:
description: "JSON array of all skins" description: "JSON array of all skins"
required: true required: true
outputs: outputs:
user_repository: user_repository:
description: "Path of the repository (relative inside container)" description: "Path of the repository (relative inside container)"
value: ${{ steps.repo.outputs.user_repository }} value: ${{ steps.repo.outputs.user_repository }}
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Extract Repository path - name: Extract Repository path
id: repo id: repo
shell: bash shell: bash
run: | run: |
echo "Extracting repository path..." echo "Extracting repository path..."
USER_REPOSITORY="${{ github.workspace }}" USER_REPOSITORY="${{ github.workspace }}"
USER_REPOSITORY="${USER_REPOSITORY#/workspace/}" USER_REPOSITORY="${USER_REPOSITORY#/workspace/}"
USER_REPOSITORY="${USER_REPOSITORY%/}" USER_REPOSITORY="${USER_REPOSITORY%/}"
echo "Repository path extracted: $USER_REPOSITORY" echo "Repository path extracted: $USER_REPOSITORY"
echo "user_repository=$USER_REPOSITORY" >> $GITHUB_OUTPUT echo "user_repository=$USER_REPOSITORY" >> $GITHUB_OUTPUT
- name: Set XDG_RUNTIME_DIR - name: Set XDG_RUNTIME_DIR
shell: bash shell: bash
run: | run: |
echo "Setting XDG_RUNTIME_DIR..." echo "Setting XDG_RUNTIME_DIR..."
mkdir -p /tmp/xdg_runtime_dir mkdir -p /tmp/xdg_runtime_dir
chmod 0700 /tmp/xdg_runtime_dir chmod 0700 /tmp/xdg_runtime_dir
echo "XDG_RUNTIME_DIR=/tmp/xdg_runtime_dir" >> "$GITHUB_ENV" echo "XDG_RUNTIME_DIR=/tmp/xdg_runtime_dir" >> "$GITHUB_ENV"
echo "XDG_RUNTIME_DIR set." echo "XDG_RUNTIME_DIR set."
- name: Create directories for assets - name: Create directories for assets
shell: bash shell: bash
run: | run: |
echo "Creating base directories for assets..." echo "Creating base directories for assets..."
mkdir -p "$REPO_SCREENSHOT_DIR" "$REPO_MOD_ICONS_DIR" "$REPO_RANKING_PANEL_DIR" "$OSK_PATH" "$REPO_THUMBNAIL_DIR" mkdir -p "$REPO_SCREENSHOT_DIR" "$REPO_MOD_ICONS_DIR" "$REPO_RANKING_PANEL_DIR" "$OSK_PATH" "$REPO_THUMBNAIL_DIR"
echo '${{ inputs.all_skins }}' | jq -r '.[]' | while IFS= read -r skin; do echo '${{ inputs.all_skins }}' | jq -r '.[]' | while IFS= read -r skin; do
[ -z "$skin" ] && continue [ -z "$skin" ] && continue
echo " → Creating subdirs for '$skin'…" echo " → Creating subdirs for '$skin'…"
mkdir -p \ mkdir -p \
"$REPO_SCREENSHOT_DIR/$skin" \ "$REPO_SCREENSHOT_DIR/$skin" \
"$REPO_MOD_ICONS_DIR/$skin" \ "$REPO_MOD_ICONS_DIR/$skin" \
"$REPO_RANKING_PANEL_DIR/$skin" \ "$REPO_RANKING_PANEL_DIR/$skin" \
"$OSK_PATH/$skin" \ "$OSK_PATH/$skin" \
"$REPO_THUMBNAIL_DIR/$skin" "$REPO_THUMBNAIL_DIR/$skin"
done done
echo "All asset directories created." echo "All asset directories created."
- name: Move Skin files to Danser Skins directory - name: Move Skin files to Danser Skins directory
shell: bash shell: bash
run: | run: |
echo "Moving Skin files to Danser Skins directory..." echo "Moving Skin files to Danser Skins directory..."
mkdir -p "$DANSER_SKINS_DIR" mkdir -p "$DANSER_SKINS_DIR"
mv "$SKINS_DIR"/* "$DANSER_SKINS_DIR" mv "$SKINS_DIR"/* "$DANSER_SKINS_DIR"
echo "Skin files moved." echo "Skin files moved."

View File

@@ -1,35 +1,35 @@
name: "Pull Git LFS Objects" name: "Pull Git LFS Objects"
description: "Pull only LFS objects for changed skins and core assets" description: "Pull only LFS objects for changed skins and core assets"
inputs: inputs:
changed_skins_file: changed_skins_file:
description: "Path to file containing changed skins" description: "Path to file containing changed skins"
required: false required: false
default: "" default: ""
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Pull Git LFS objects - name: Pull Git LFS objects
shell: bash shell: bash
run: | run: |
if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then if [ -z "${{ inputs.changed_skins_file }}" ] || [ ! -s "${{ inputs.changed_skins_file }}" ]; then
echo "No skins changed. Skipping git pull lfs." echo "No skins changed. Skipping git pull lfs."
exit 0 exit 0
fi fi
includes="src/**,export/**,media/**" includes="src/**,export/**,media/**"
skin_includes=$( skin_includes=$(
while IFS= read -r skin; do while IFS= read -r skin; do
esc=$(printf '%s' "$skin" \ esc=$(printf '%s' "$skin" \
| sed -e 's/\[/\\[/g' -e 's/\]/\\]/g') | sed -e 's/\[/\\[/g' -e 's/\]/\\]/g')
printf 'Skins/%s/**\n' "$esc" printf 'Skins/%s/**\n' "$esc"
done < "${{ inputs.changed_skins_file }}" \ done < "${{ inputs.changed_skins_file }}" \
| paste -sd ',' | paste -sd ','
) )
includes="$includes,$skin_includes" includes="$includes,$skin_includes"
echo "→ Pulling LFS objects for patterns: $includes" echo "→ Pulling LFS objects for patterns: $includes"
git lfs pull --include="$includes" git lfs pull --include="$includes"

View File

@@ -1 +1 @@
# Reusable Actions # Reusable Actions