Update .gitea/workflows/ci.yml
This commit is contained in:
@@ -126,8 +126,8 @@ jobs:
|
|||||||
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:]]*}"}" # Trim leading whitespace
|
skin="${skin#"${skin%%[![:space:]]*}"}"
|
||||||
skin="${skin%"${skin##*[![:space:]]}"}" # Trim trailing whitespace
|
skin="${skin%"${skin##*[![:space:]]}"}"
|
||||||
if [ -n "$skin" ]; then
|
if [ -n "$skin" ]; then
|
||||||
uniq_skins+=("$skin")
|
uniq_skins+=("$skin")
|
||||||
fi
|
fi
|
||||||
@@ -260,69 +260,70 @@ 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 Started]"
|
echo "[Asset Renaming Started]"
|
||||||
|
|
||||||
if [ -z "${CHANGED_SKINS_FILE:-}" ] || [ ! -s "$CHANGED_SKINS_FILE" ]; then
|
|
||||||
echo "No skins changed. Skipping asset renaming."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
sanitize_filename() {
|
|
||||||
echo "$1" | \
|
|
||||||
sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' | \
|
|
||||||
tr -s ' ' | \
|
|
||||||
sed 's/^ *//;s/ *$//'
|
|
||||||
}
|
|
||||||
|
|
||||||
mapfile -t changed_skins < "$CHANGED_SKINS_FILE"
|
|
||||||
skin_dirs=()
|
skin_dirs=()
|
||||||
for skin in "${changed_skins[@]}"; do
|
|
||||||
[ -d "$DANSER_SKINS_DIR/$skin" ] && skin_dirs+=("$DANSER_SKINS_DIR/$skin/")
|
if [ -n "${CHANGED_SKINS_FILE:-}" ] && [ -s "$CHANGED_SKINS_FILE" ]; then
|
||||||
done
|
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
|
||||||
|
|
||||||
SKIN_COUNT=${#skin_dirs[@]}
|
SKIN_COUNT=${#skin_dirs[@]}
|
||||||
INDEX=1
|
INDEX=1
|
||||||
|
|
||||||
if [ "$SKIN_COUNT" -eq 0 ]; then
|
sanitize_filename() {
|
||||||
echo "No valid skin directories to process. Skipping."
|
echo "$1" \
|
||||||
exit 0
|
| sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' \
|
||||||
fi
|
| tr -s ' ' \
|
||||||
|
| sed 's/^ *//;s/ *$//'
|
||||||
|
}
|
||||||
|
|
||||||
for skin_path in "${skin_dirs[@]}"; do
|
for skin_path in "${skin_dirs[@]}"; do
|
||||||
[ -d "$skin_path" ] || continue
|
[ -d "$skin_path" ] || continue
|
||||||
SKIN_NAME=$(basename "$skin_path")
|
SKIN_NAME=$(basename "$skin_path" \
|
||||||
|
| tr -d '\r\n' \
|
||||||
echo ""
|
| sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
echo "[$INDEX/$SKIN_COUNT] Skin: $SKIN_NAME"
|
echo "Processing skin $INDEX/$SKIN_COUNT: $SKIN_NAME"
|
||||||
|
|
||||||
|
ini_file=$(find "$skin_path" -maxdepth 1 -iname "skin.ini" | head -n1 || true)
|
||||||
skin_header="$SKIN_NAME"
|
skin_header="$SKIN_NAME"
|
||||||
|
if [ -f "$ini_file" ]; then
|
||||||
if ini_file=$(find "$skin_path" -maxdepth 1 -iname "skin.ini" | head -n 1); then
|
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n1 || true)
|
||||||
if [ -f "$ini_file" ]; then
|
if [ -n "$name_line" ]; then
|
||||||
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n 1)
|
new_name=$(echo "$name_line" | cut -d':' -f2- \
|
||||||
if [ -n "$name_line" ]; then
|
| 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
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$REPO_SCREENSHOT_DIR/$SKIN_NAME.gif" ] && [ "$SKIN_NAME" != "$skin_header" ]; then
|
if [ -f "$REPO_SCREENSHOT_DIR/$SKIN_NAME.gif" ] \
|
||||||
mv -f "$REPO_SCREENSHOT_DIR/$SKIN_NAME.gif" "$REPO_SCREENSHOT_DIR/$skin_header.gif"
|
&& [ "$SKIN_NAME" != "$skin_header" ]; then
|
||||||
|
mv -f "$REPO_SCREENSHOT_DIR/$SKIN_NAME.gif" \
|
||||||
|
"$REPO_SCREENSHOT_DIR/$skin_header.gif" || true
|
||||||
echo " ✓ Renamed GIF"
|
echo " ✓ Renamed GIF"
|
||||||
else
|
|
||||||
echo " → No GIF to rename or already named correctly"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$REPO_RANKING_PANEL_DIR/$SKIN_NAME.png" ] && [ "$SKIN_NAME" != "$skin_header" ]; then
|
if [ -f "$REPO_RANKING_PANEL_DIR/$SKIN_NAME.png" ] \
|
||||||
mv -f "$REPO_RANKING_PANEL_DIR/$SKIN_NAME.png" "$REPO_RANKING_PANEL_DIR/$skin_header.png"
|
&& [ "$SKIN_NAME" != "$skin_header" ]; then
|
||||||
echo " ✓ Renamed Screenshot"
|
mv -f "$REPO_RANKING_PANEL_DIR/$SKIN_NAME.png" \
|
||||||
else
|
"$REPO_RANKING_PANEL_DIR/$skin_header.png" || true
|
||||||
echo " → No Screenshot to rename or already named correctly"
|
echo " ✓ Renamed PNG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " ✓ Completed"
|
|
||||||
INDEX=$((INDEX + 1))
|
INDEX=$((INDEX + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -332,18 +333,32 @@ jobs:
|
|||||||
- name: Generate Mod Icons
|
- name: Generate Mod Icons
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
echo "[Mod Icon Generation Started]"
|
echo "[Mod Icon Generation Started]"
|
||||||
|
|
||||||
sanitize_filename() {
|
sanitize_filename() {
|
||||||
echo "$1" | \
|
echo "$1" \
|
||||||
sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' | \
|
| sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' \
|
||||||
tr -s ' ' | \
|
| tr -s ' ' \
|
||||||
sed 's/^ *//;s/ *$//'
|
| sed 's/^ *//;s/ *$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$CHANGED_SKINS_FILE" ] || [ ! -s "$CHANGED_SKINS_FILE" ]; then
|
skin_dirs=()
|
||||||
echo "No skins changed. Skipping mod icon generation."
|
|
||||||
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
|
||||||
|
|
||||||
ICONS_JSON_FILE="${{ github.workspace }}/.gitea/workflows/icons.json"
|
ICONS_JSON_FILE="${{ github.workspace }}/.gitea/workflows/icons.json"
|
||||||
@@ -351,28 +366,23 @@ jobs:
|
|||||||
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")
|
||||||
|
|
||||||
mapfile -t skins < "$CHANGED_SKINS_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=${#skins[@]}
|
SKIN_COUNT=${#skin_dirs[@]}
|
||||||
INDEX=1
|
INDEX=1
|
||||||
|
|
||||||
for skin_path in "${skins[@]}"; do
|
for SKIN_DIR in "${skin_dirs[@]}"; do
|
||||||
[ -z "$skin_path" ] && continue
|
|
||||||
SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
|
|
||||||
[ -d "$SKIN_DIR" ] || continue
|
[ -d "$SKIN_DIR" ] || continue
|
||||||
|
skin_header=$(basename "$SKIN_DIR" | tr -d '\r\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
|
|
||||||
skin_header=$(basename "$SKIN_DIR")
|
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n 1 || true)
|
||||||
if ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n 1); then
|
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 -n 1)
|
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
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -416,54 +426,60 @@ 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]"
|
||||||
|
|
||||||
sanitize_filename() {
|
sanitize_filename() {
|
||||||
echo "$1" | \
|
echo "$1" \
|
||||||
sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' | \
|
| sed -e 's#[\\/:\*\?"<>|]#-#g' -e 's#%#_#g' \
|
||||||
tr -s ' ' | \
|
| tr -s ' ' \
|
||||||
sed 's/^ *//;s/ *$//'
|
| sed 's/^ *//;s/ *$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "${CHANGED_SKINS_FILE:-}" ] || [ ! -s "$CHANGED_SKINS_FILE" ]; then
|
skin_dirs=()
|
||||||
echo "No skins to process. Skipping OSK file generation."
|
|
||||||
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
|
||||||
|
|
||||||
mapfile -t skins < "$CHANGED_SKINS_FILE"
|
|
||||||
|
|
||||||
FIXED_TIMESTAMP="2025-01-01 00:00:00"
|
FIXED_TIMESTAMP="2025-01-01 00:00:00"
|
||||||
|
SKIN_COUNT=${#skin_dirs[@]}
|
||||||
SKIN_COUNT=${#skins[@]}
|
|
||||||
INDEX=1
|
INDEX=1
|
||||||
|
|
||||||
for skin_path in "${skins[@]}"; do
|
for SKIN_DIR in "${skin_dirs[@]}"; do
|
||||||
SKIN_DIR="$DANSER_SKINS_DIR/$skin_path"
|
|
||||||
[ -d "$SKIN_DIR" ] || continue
|
[ -d "$SKIN_DIR" ] || continue
|
||||||
|
|
||||||
skin_header="$skin_path"
|
skin_header=$(basename "$SKIN_DIR" | tr -d '\r\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
if ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n 1); then
|
|
||||||
if [ -f "$ini_file" ]; then
|
ini_file=$(find "$SKIN_DIR" -maxdepth 1 -iname "skin.ini" | head -n 1 || true)
|
||||||
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n 1)
|
if [ -f "$ini_file" ]; then
|
||||||
if [ -n "$name_line" ]; then
|
name_line=$(grep -i '^[[:space:]]*name:' "$ini_file" | head -n 1 || true)
|
||||||
new_name=$(echo "$name_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
if [ -n "$name_line" ]; then
|
||||||
new_name=$(sanitize_filename "$new_name")
|
new_name=$(echo "$name_line" | cut -d ':' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
[ -n "$new_name" ] && skin_header="$new_name"
|
new_name=$(sanitize_filename "$new_name")
|
||||||
fi
|
[ -n "$new_name" ] && skin_header="$new_name"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
skin_header=$(printf '%s' "$skin_header" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "[$INDEX/$SKIN_COUNT] Processing skin: $skin_header"
|
echo "[$INDEX/$SKIN_COUNT] Processing skin: $skin_header"
|
||||||
|
|
||||||
(cd "$SKIN_DIR" && find . -type f -exec touch -d "$FIXED_TIMESTAMP" {} +)
|
(cd "$SKIN_DIR" && find . -type f -exec touch -d "$FIXED_TIMESTAMP" {} +)
|
||||||
|
|
||||||
(cd "$SKIN_DIR" && find . -type f | sort | zip -rq -D -X -9 --compression-method deflate "$OSK_PATH/${skin_header}.osk" -@)
|
(cd "$SKIN_DIR" && find . -type f | sort | zip -rq -D -X -9 --compression-method deflate "$OSK_PATH/${skin_header}.osk" -@)
|
||||||
|
|
||||||
echo " ✓ OSK file created successfully."
|
echo " ✓ OSK file created successfully."
|
||||||
|
|||||||
Reference in New Issue
Block a user