-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logo and resource file GH Action
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Regenerate Resource Files | ||
|
||
on: | ||
push: | ||
paths: | ||
- ".github/workflows/resources.yml" | ||
- "res/**" | ||
- "tools/generate-assets.sh" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
regenerate-assets: | ||
name: Regenerate Resource Files | ||
runs-on: self-hosted | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Generate Assets | ||
run: tools/generate-assets.sh |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Deps | ||
xbps-install -Syu > /dev/null | ||
xbps-install -y ImageMagick yarn > /dev/null | ||
yarn global add svgo > /dev/null | ||
|
||
# Functions | ||
regenerate() | ||
{ | ||
echo "Generating assets for $1" | ||
|
||
# Optimize the SVG file | ||
svgo --multipass --quiet "$1" | ||
|
||
# Convert to PNG | ||
convert "$1" -size 1024x1024 "${1%.*}.png" | ||
|
||
# Convert to ICO | ||
# https://stackoverflow.com/a/15104985 | ||
convert "$1" -bordercolor white -border 0 \ | ||
\( -clone 0 -resize 16x16 \) \ | ||
\( -clone 0 -resize 32x32 \) \ | ||
\( -clone 0 -resize 48x48 \) \ | ||
\( -clone 0 -resize 64x64 \) \ | ||
-delete 0 -alpha off -colors 256 "${1%.*}.ico" | ||
} | ||
|
||
# Iterate over each file matching the pattern "*.svg" in the "res" directory | ||
for file in res/*.svg; do | ||
# Execute the "regenerate" command on each file | ||
regenerate "$file" | ||
done | ||
|
||
# Check if any files were modified | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
git add res > /dev/null | ||
git diff-index --quiet HEAD | ||
if [ "$?" == "1" ]; then | ||
git commit -m "[ci-skip] Regenerate resource files." > /dev/null | ||
git push > /dev/null | ||
else | ||
echo "No resource files were modified." | ||
fi |