Skip to content

Commit da33a70

Browse files
committed
Replace inkscape with resvg
1 parent 8e76715 commit da33a70

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

.github/workflows/main.yml

+23-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,30 @@ jobs:
4242
id: pages
4343
uses: actions/configure-pages@v5
4444

45-
- name: Install dependencies
45+
- name: Get resvg sha
46+
id: get-resvg-sha
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: |
50+
echo "data=$(gh api "repos/RazrFalcon/resvg/git/ref/tags/$(gh api repos/RazrFalcon/resvg/releases/latest --jq '.tag_name')" --jq '.object.sha')" >> "$GITHUB_OUTPUT"
51+
52+
- name: Restore resvg
53+
id: restore-resvg
54+
uses: actions/cache@v4
55+
with:
56+
path: |
57+
bin/resvg
58+
key: resvg-${{ steps.get-resvg-sha.outputs.data }}
59+
60+
- if: ${{ steps.restore-resvg.outputs.cache-hit != 'true' }}
61+
name: Get resvg
62+
id: get-resvg
63+
env:
64+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4665
run: |
47-
sudo apt install -y inkscape imagemagick
66+
asset="resvg-linux-x86_64.tar.gz" &&
67+
gh release --repo RazrFalcon/resvg download --pattern "$asset" --dir bin &&
68+
tar -C bin -xzf "bin/$asset"
4869
4970
- name: Build
5071
env:

build.sh

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ done
2121

2222
set -e
2323

24+
if [[ -d bin ]]; then
25+
export PATH="$(realpath bin):$PATH"
26+
fi
27+
2428
echo "Generating images..."
2529
./gen-icon.sh assets/opengraph-*.svg assets/twitter-*.svg &
2630
asset_job=$!

gen-icon.sh

+12-9
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,29 @@ fi
6969

7070
set -- "${args[@]}"
7171

72-
command -v inkscape > /dev/null; inkscape=$?
72+
command -v resvg > /dev/null; resvg=$?
7373

74-
if [[ inkscape -ne 0 ]]; then
75-
echo $'Cannot find \'inkscape\' command. Make sure Inkscape is installed and reachable from the current working directory. See: https://inkscape.org' >&2
74+
if [[ resvg -ne 0 ]]; then
75+
echo "Cannot find 'resvg' command. Make sure resvg is installed and resvg reachable from the current working directory. See: https://github.com/RazrFalcon/resvg" >&2
7676
exit 1
7777
fi
7878

7979
command -v convert > /dev/null; magick=$?
8080

8181
if [[ magick -ne 0 ]]; then
82-
echo $'Cannot find \'convert\' command. Make sure ImageMagick is installed and reachable from the current working directory. See: https://www.imagemagick.org' >&2
82+
echo "Cannot find 'convert' command. Make sure ImageMagick is installed and reachable from the current working directory. See: https://www.imagemagick.org" >&2
8383
exit 1
8484
fi
8585

8686
status=0
8787

8888
export_png() {
89-
# https://gitlab.com/inkscape/inkscape/-/issues/4716#note_1898150983
90-
if [[ $3 -nt $2 ]]; then
91-
SELF_CALL=xxx inkscape -C -w "$1" -h "$1" -o "$2" "$3"
89+
if [[ $2 -nt $3 ]]; then
90+
if (( $1 == 0 )); then
91+
resvg "$2" "$3"
92+
else
93+
resvg -w "$1" -h "$1" "$2" "$3"
94+
fi
9295
fi
9396
}
9497

@@ -109,13 +112,13 @@ for f in "$@"; do
109112
else
110113
png="$name-$i.g.png"
111114
fi
112-
export_png "$i" "$png" "$f" &
115+
export_png "$i" "$f" "$png" &
113116
size2job["$i"]=$!
114117
job2png[$!]="$png"
115118
done
116119
if (( apple != 0 )); then
117120
apple_icon="$(dirname "$name")/apple-touch-icon.g.png"
118-
export_png "$apple_touch_icon_content_size" "$apple_icon" "$f" &
121+
export_png "$apple_touch_icon_content_size" "$f" "$apple_icon" &
119122
apple_job=$!
120123
fi
121124

0 commit comments

Comments
 (0)