Skip to content

Commit 799e3d2

Browse files
authored
Merge pull request #42637 from github/repo-sync
Repo sync
2 parents 2233319 + 54eeb51 commit 799e3d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+241
-2
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# Generate social card PNGs from template SVGs
4+
# Requires:
5+
# - librsvg (install with: brew install librsvg)
6+
# - zopfli (install with: brew install zopfli)
7+
# - Mona Sans font (install with: brew install --cask font-mona-sans)
8+
9+
set -e
10+
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
13+
# Check for required CLI tools
14+
if ! command -v rsvg-convert &> /dev/null; then
15+
echo "Error: rsvg-convert not found. Install with: brew install librsvg"
16+
exit 1
17+
fi
18+
19+
if ! command -v zopflipng &> /dev/null; then
20+
echo "Error: zopflipng not found. Install with: brew install zopfli"
21+
exit 1
22+
fi
23+
24+
# Check for Mona Sans font
25+
if ! fc-list | grep -qi "Mona Sans"; then
26+
echo "Error: Mona Sans font not found. Install with: brew install --cask font-mona-sans"
27+
exit 1
28+
fi
29+
30+
# Labels to generate from template (filename:Label Text)
31+
LABELS=(
32+
"account-and-profile:Account"
33+
"actions:Actions"
34+
"admin:Admin"
35+
"apps:Apps"
36+
"authentication:Auth"
37+
"billing:Billing"
38+
"code-security:Security"
39+
"codespaces:Codespaces"
40+
"communities:Community"
41+
"contributing:Contributing"
42+
"copilot:Copilot"
43+
"desktop:Desktop"
44+
"discussions:Discussions"
45+
"education:Education"
46+
"enterprise-onboarding:Enterprise"
47+
"get-started:Get Started"
48+
"github-cli:GitHub CLI"
49+
"github-models:Models"
50+
"graphql:GraphQL"
51+
"integrations:Integrations"
52+
"issues:Issues"
53+
"migrations:Migrations"
54+
"nonprofit:Nonprofit"
55+
"organizations:Orgs"
56+
"packages:Packages"
57+
"pages:Pages"
58+
"pull-requests:Pull requests"
59+
"repositories:Repositories"
60+
"rest:REST"
61+
"search-github:Search"
62+
"site-policy:Site Policy"
63+
"sponsors:Sponsors"
64+
"subscriptions-and-notifications:Account"
65+
"support:Support"
66+
"webhooks:Webhooks"
67+
)
68+
69+
# Generate default.png from _default.svg
70+
echo "Converting _default.svg to default.png..."
71+
rsvg-convert -w 1200 -h 628 "$SCRIPT_DIR/_default.svg" -o "$SCRIPT_DIR/default.png"
72+
echo "Optimizing default.png with zopflipng..."
73+
zopflipng -y "$SCRIPT_DIR/default.png" "$SCRIPT_DIR/default.png"
74+
75+
# Generate labeled PNGs from _template.svg
76+
for entry in "${LABELS[@]}"; do
77+
filename="${entry%%:*}"
78+
label="${entry##*:}"
79+
png="$SCRIPT_DIR/$filename.png"
80+
81+
echo "Generating $filename.png with label \"$label\"..."
82+
sed "s/{{LABEL}}/$label/g" "$SCRIPT_DIR/_template.svg" | rsvg-convert -w 1200 -h 628 -o "$png"
83+
echo "Optimizing $filename.png with zopflipng..."
84+
zopflipng -y "$png" "$png"
85+
done
86+
87+
echo "Done!"
Lines changed: 37 additions & 0 deletions
Lines changed: 48 additions & 0 deletions
9.91 KB
-23.6 KB
8.34 KB
9.02 KB
7.07 KB
8.04 KB
-24.8 KB

0 commit comments

Comments
 (0)