Skip to content

Commit 0d92245

Browse files
Move theme distribution from PackedThemes/ to GitHub Release assets
The auto-pack and manual-pack workflows now upload .7z files to the "Theme Garden" release (tag: 1) instead of committing them to the PackedThemes/ directory. This removes the 100MB file size limit that was blocking themes like COMIC STYLE (195MB). Filenames are normalized (spaces to underscores, apostrophes and exclamation marks removed) to avoid GitHub's asset name mangling. The gallery workflow now checks release assets instead of PackedThemes/ and generates download links pointing to the release. PackedThemes/ is left in place for now so existing devices on older builds can still download themes via the old raw.githubusercontent URLs.
1 parent 07db8e4 commit 0d92245

3 files changed

Lines changed: 90 additions & 60 deletions

File tree

.github/workflows/auto-pack-themes.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ on:
1818
jobs:
1919
package-themes:
2020
runs-on: ubuntu-latest
21-
21+
permissions:
22+
contents: write
23+
2224
steps:
2325
- uses: actions/checkout@v4
2426
with:
@@ -77,13 +79,23 @@ jobs:
7779
fi
7880
done
7981
80-
- name: Commit and push changes
82+
- name: Upload to Release
83+
env:
84+
GH_TOKEN: ${{ github.token }}
8185
run: |
82-
git config --local user.email "action@github.com"
83-
git config --local user.name "GitHub Action"
84-
85-
# Add and commit changes
86-
git add PackedThemes/*.7z
87-
git commit -m "Update theme packages" || echo "No changes to commit"
88-
git push
86+
normalize_name() {
87+
echo "$1" | sed "s/ /_/g; s/'//g; s/!//g"
88+
}
89+
90+
for f in PackedThemes/*.7z; do
91+
[ -f "$f" ] || continue
92+
base="$(basename "$f")"
93+
normalized="$(normalize_name "$base")"
94+
if [ "$base" != "$normalized" ]; then
95+
cp "$f" "PackedThemes/$normalized"
96+
gh release upload 1 "PackedThemes/$normalized" --clobber
97+
else
98+
gh release upload 1 "$f" --clobber
99+
fi
100+
done
89101

.github/workflows/generate-theme-gallery.yml

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,97 +16,106 @@ on:
1616
jobs:
1717
update-readme:
1818
runs-on: ubuntu-latest
19-
19+
permissions:
20+
contents: write
21+
2022
steps:
2123
- uses: actions/checkout@v4
2224
with:
2325
fetch-depth: 0 # Fetch all history for all branches and tags
2426

2527
- name: Check for new themes
2628
id: check-themes
29+
env:
30+
GH_TOKEN: ${{ github.token }}
2731
run: |
28-
# Get list of all current theme directories, sorted
29-
current_themes=$(find Themes -maxdepth 1 -mindepth 1 -type d | sed 's|Themes/||' | sort)
30-
echo "::debug::Current themes in directory:"
32+
normalize_name() {
33+
echo "$1" | sed "s/ /_/g; s/'//g; s/!//g"
34+
}
35+
36+
# Get normalized list of theme directories
37+
current_themes=$(find Themes -maxdepth 1 -mindepth 1 -type d | sed 's|Themes/||' | while IFS= read -r name; do normalize_name "$name"; done | sort)
38+
echo "::debug::Current themes (normalized):"
3139
echo "::debug::$current_themes"
32-
33-
# Get list of themes from README, sorted
34-
readme_themes=$(grep -o 'PackedThemes/[^/]*\.7z' README.md |
35-
sed 's|PackedThemes/||' |
36-
sed 's|\.7z$||' |
37-
sed 's/%20/ /g' |
38-
sort)
39-
echo "::debug::Themes found in README:"
40-
echo "::debug::$readme_themes"
41-
42-
# Create temporary files for comparison
40+
41+
# Get list of themes from release assets
42+
release_themes=$(gh release view 1 --json assets -q '.assets[].name' 2>/dev/null | sed 's|\.7z$||' | sort)
43+
echo "::debug::Themes in release:"
44+
echo "::debug::$release_themes"
45+
4346
echo "$current_themes" > current_themes.txt
44-
echo "$readme_themes" > readme_themes.txt
45-
46-
# Compare the sorted lists and store differences
47-
if ! diff current_themes.txt readme_themes.txt > theme_diff.txt; then
48-
echo "::notice::Differences detected between directory and README:"
47+
echo "$release_themes" > release_themes.txt
48+
49+
if ! diff current_themes.txt release_themes.txt > theme_diff.txt; then
50+
echo "::notice::Differences detected between directory and release:"
4951
cat theme_diff.txt
5052
echo "theme_changed=1" >> "$GITHUB_OUTPUT"
5153
else
5254
echo "::notice::No differences detected"
5355
echo "theme_changed=0" >> "$GITHUB_OUTPUT"
5456
fi
55-
56-
# Clean up temp files
57-
rm current_themes.txt readme_themes.txt theme_diff.txt
57+
58+
rm current_themes.txt release_themes.txt theme_diff.txt
5859
5960
- name: Generate Theme Gallery
6061
if: github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_run' || steps.check-themes.outputs.theme_changed == '1'
6162
id: generate-gallery
63+
env:
64+
GH_TOKEN: ${{ github.token }}
6265
run: |
66+
normalize_name() {
67+
echo "$1" | sed "s/ /_/g; s/'//g; s/!//g"
68+
}
69+
70+
# Fetch release asset list once
71+
RELEASE_ASSETS=$(gh release view 1 --json assets -q '.assets[].name' 2>/dev/null || echo "")
72+
6373
# Create backup of current README
6474
cp README.md README.md.bak
65-
75+
6676
# Create temporary files
6777
TEMP_FILE=$(mktemp)
6878
GALLERY_CONTENT=$(mktemp)
69-
79+
7080
# Generate the new gallery content
7181
echo -e "## Theme Gallery\n" > "$GALLERY_CONTENT"
72-
82+
7383
# Initialize arrays for the grid
7484
declare -a themes=()
75-
85+
7686
# Process each theme folder
7787
for theme_dir in Themes/*/; do
7888
if [ -d "$theme_dir" ] && [ "$theme_dir" != "PackedThemes/" ]; then
7989
theme_name="${theme_dir#Themes/}"
8090
theme_name="${theme_name%/}"
8191
preview_path_gif="$theme_dir/preview.gif"
8292
preview_path_png="$theme_dir/preview.png"
83-
packed_path="PackedThemes/$theme_name.7z"
8493
config_path="$theme_dir/config.json"
85-
86-
if [ -f "$packed_path" ] && [ -f "$config_path" ] && { [ -f "$preview_path_gif" ] || [ -f "$preview_path_png" ]; }; then
94+
normalized_theme="$(normalize_name "$theme_name")"
95+
96+
if echo "$RELEASE_ASSETS" | grep -qF "${normalized_theme}.7z" && [ -f "$config_path" ] && { [ -f "$preview_path_gif" ] || [ -f "$preview_path_png" ]; }; then
8797
# Extract author and description from config.json
8898
author=$(jq -r '.author' "$config_path")
8999
description=$(jq -r '.description' "$config_path")
90-
100+
91101
# Determine which preview file to use
92102
if [ -f "$preview_path_gif" ]; then
93103
preview_path="$preview_path_gif"
94104
else
95105
preview_path="$preview_path_png"
96106
fi
97-
107+
98108
# Create properly encoded URLs
99109
preview_path=$(echo "$preview_path" | sed 's|^Themes/||')
100110
theme_name_encoded=$(echo "$theme_name" | sed -e 's/ /%20/g')
101-
111+
102112
preview_url="https://raw.githubusercontent.com/$GITHUB_REPOSITORY/main/Themes/${theme_name_encoded}/preview.png"
103113
preview_img="<img title=\"${theme_name}\" width=\"200px\" src=\"${preview_url}\" />"
104-
download_url="https://raw.githubusercontent.com/$GITHUB_REPOSITORY/main/PackedThemes/${theme_name_encoded}.7z"
105-
106-
# Clean up URLs (remove any double slashes except after https:)
114+
download_url="https://github.com/$GITHUB_REPOSITORY/releases/download/1/${normalized_theme}.7z"
115+
116+
# Clean up preview URL (remove any double slashes except after https:)
107117
preview_url=$(echo "$preview_url" | sed -e 's|//|/|g' -e 's|https:/|https://|')
108-
download_url=$(echo "$download_url" | sed -e 's|//|/|g' -e 's|https:/|https://|')
109-
118+
110119
# Create theme cell content
111120
theme_cell="<td align=\"center\" valign=\"top\" width=\"33.33%\">
112121
<br/>
@@ -116,7 +125,7 @@ jobs:
116125
<small><i>$author</i></small><br/>
117126
<small>$description</small><br/>
118127
</td>"
119-
128+
120129
themes+=("$theme_cell")
121130
fi
122131
fi

.github/workflows/manually-pack-themes.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ on:
66
jobs:
77
package-themes:
88
runs-on: ubuntu-latest
9-
9+
permissions:
10+
contents: write
11+
1012
steps:
1113
- uses: actions/checkout@v4
1214
with:
@@ -19,11 +21,6 @@ jobs:
1921
2022
- name: Prepare PackedThemes Directory
2123
run: |
22-
# Create PackedThemes directory if it doesn't exist
23-
mkdir -p PackedThemes
24-
# Remove all existing files in PackedThemes (including git-tracked files)
25-
git rm -rf PackedThemes/*.7z || true
26-
# Ensure the directory exists after git rm
2724
mkdir -p PackedThemes
2825
2926
- name: Package All Themes
@@ -59,10 +56,22 @@ jobs:
5956
fi
6057
done
6158
62-
- name: Commit and Push Changes
59+
- name: Upload to Release
60+
env:
61+
GH_TOKEN: ${{ github.token }}
6362
run: |
64-
git config --local user.email "action@github.com"
65-
git config --local user.name "GitHub Action"
66-
git add PackedThemes/*.7z
67-
git commit -m "Update all theme packages" || echo "No changes to commit"
68-
git push
63+
normalize_name() {
64+
echo "$1" | sed "s/ /_/g; s/'//g; s/!//g"
65+
}
66+
67+
for f in PackedThemes/*.7z; do
68+
[ -f "$f" ] || continue
69+
base="$(basename "$f")"
70+
normalized="$(normalize_name "$base")"
71+
if [ "$base" != "$normalized" ]; then
72+
cp "$f" "PackedThemes/$normalized"
73+
gh release upload 1 "PackedThemes/$normalized" --clobber
74+
else
75+
gh release upload 1 "$f" --clobber
76+
fi
77+
done

0 commit comments

Comments
 (0)