Generate Icons #11
This file contains hidden or 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
| name: Generate Icons | |
| on: | |
| push: | |
| paths: | |
| - "src/icons/svg/*.svg" | |
| workflow_dispatch: | |
| jobs: | |
| build-icons: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install SVG → PNG + ICO tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y librsvg2-bin imagemagick optipng | |
| - name: Prepare output folders | |
| run: | | |
| rm -rf src/icons/png | |
| rm -rf src/icons/ico | |
| mkdir -p src/icons/png | |
| mkdir -p src/icons/ico | |
| - name: Generate PNGs and ICOs | |
| run: | | |
| set -e | |
| shopt -s nullglob | |
| for svg in src/icons/svg/*.svg; do | |
| base=$(basename "$svg" .svg) | |
| echo "Processing $base.svg" | |
| # PNG sizes | |
| for size in 16 24 32 48 64 128 256; do | |
| rsvg-convert -w ${size} -h ${size} "$svg" -o "src/icons/png/${base}-${size}.png" | |
| done | |
| # Optimize PNGs (lossless) | |
| for png in src/icons/png/${base}-*.png; do | |
| optipng -o7 "$png" | |
| done | |
| # ICO (Windows-relevant sizes) | |
| convert \ | |
| src/icons/png/${base}-16.png \ | |
| src/icons/png/${base}-24.png \ | |
| src/icons/png/${base}-32.png \ | |
| src/icons/png/${base}-48.png \ | |
| src/icons/png/${base}-64.png \ | |
| src/icons/png/${base}-128.png \ | |
| src/icons/png/${base}-256.png \ | |
| "src/icons/ico/${base}.ico" | |
| done | |
| - name: List generated icons (debug) | |
| run: | | |
| echo "=== src/icons tree ===" | |
| ls -R src/icons || true | |
| - name: Commit generated icons | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "Auto-generate PNG and ICO icons" | |
| file_pattern: src/icons/png/* src/icons/ico/* |