1name: Generate Screenshots
2
3on:
4 workflow_dispatch:
5 release:
6 types: [published]
7
8permissions:
9 contents: write
10 pull-requests: write
11
12jobs:
13 generate-screenshots:
14 if: github.event_name == 'workflow_dispatch' || github.event.release.prerelease == false
15 name: Generate Feature Screenshots
16 runs-on: ubuntu-latest
17 steps:
18 - name: Checkout code
19 uses: actions/checkout@v6
20 with:
21 ref: master
22 persist-credentials: false
23
24 - name: Set up Go
25 uses: actions/setup-go@v6
26 with:
27 go-version: "stable"
28
29 - name: Install system dependencies
30 run: sudo apt-get update && sudo apt-get install -y libpcsclite-dev
31
32 - name: Create Dummy Config
33 run: |
34 mkdir -p ~/.config/matcha
35 cat <<EOF > ~/.config/matcha/config.json
36 {
37 "accounts": [
38 {
39 "id": "demo-user",
40 "name": "Matcha Client",
41 "email": "matcha@floatpane.com",
42 "password": "dummy-password",
43 "service_provider": "custom",
44 "fetch_email": "matcha@floatpane.com"
45 }
46 ]
47 }
48 EOF
49
50 - name: Create Dummy Drafts
51 run: |
52 cat <<EOF > ~/.config/matcha/drafts.json
53 {
54 "drafts": [
55 {
56 "id": "draft-001",
57 "to": "team@example.com",
58 "subject": "Q1 Planning Document",
59 "body": "# Q1 Planning\n\nHere are the key objectives for Q1...",
60 "account_id": "demo-user"
61 },
62 {
63 "id": "draft-002",
64 "to": "alice@example.com",
65 "subject": "Re: Design Review Feedback",
66 "body": "Thanks for the review! I'll address the comments...",
67 "account_id": "demo-user"
68 }
69 ],
70 "updated_at": "2026-01-15T10:00:00Z"
71 }
72 EOF
73
74 - name: Build Matcha
75 env:
76 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77 run: |
78 LATEST_TAG=$(gh release view --json tagName -q ".tagName" 2>/dev/null || echo "dev")
79 echo "Using version: $LATEST_TAG"
80
81 git fetch --tags 2>/dev/null || true
82
83 COMMIT=$(git rev-parse --short HEAD)
84 DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
85 go build -ldflags="-s -w -X main.version=$LATEST_TAG -X main.commit=$COMMIT -X main.date=$DATE" -o matcha .
86 go build -o email_view ./screenshots/cmd/email_view
87 go build -o inbox_view ./screenshots/cmd/inbox_view
88
89 - name: Prepare Tapes
90 run: |
91 for tape in screenshots/*.tape; do
92 [ "$tape" = "screenshots/common.tape" ] && continue
93 sed -i 's|go run \./screenshots/cmd/email_view|./email_view|' "$tape"
94 sed -i 's|go run \./screenshots/cmd/inbox_view|./inbox_view|' "$tape"
95 sed -i 's|go run \.|./matcha|' "$tape"
96 done
97
98 - name: Install Dependencies
99 run: |
100 sudo apt-get update
101 sudo apt-get install -y ffmpeg ttyd
102 mkdir -p ~/.local/share/fonts
103 wget -q https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/JetBrainsMono.zip
104 unzip -o JetBrainsMono.zip -d ~/.local/share/fonts
105 fc-cache -fv
106 go install github.com/charmbracelet/vhs@latest
107
108 - name: Generate Screenshots
109 env:
110 CLICOLOR_FORCE: "1"
111 run: |
112 mkdir -p docs/docs/assets/features/
113 for tape in screenshots/*.tape; do
114 [ "$tape" = "screenshots/common.tape" ] && continue
115 name=$(basename "$tape" .tape)
116 echo "==> Generating screenshot: $name"
117 TERM=xterm-256color vhs "$tape" || echo "Warning: $name failed"
118 done
119 # Move generated screenshots to public assets, clean up intermediate gifs
120 mv screenshots/*.png docs/docs/assets/features/ 2>/dev/null || true
121 rm -f screenshots/*.gif 2>/dev/null || true
122 ls -la docs/docs/assets/features/
123
124 - name: Generate PR Body
125 id: pr-body
126 run: |
127 BODY="## What?
128
129 Refreshes the feature screenshots in \`docs/docs/assets/features/\`.
130
131 ### Screenshots included:"
132
133 for png in docs/docs/assets/features/*.png; do
134 [ -f "$png" ] || continue
135 filename=$(basename "$png")
136 BODY="$BODY
137 - \`$filename\`"
138 done
139
140 BODY="$BODY
141
142 ## Why?
143
144 Keeps documentation visuals aligned with the current TUI. Generated automatically by the Generate Screenshots workflow on the latest release."
145
146 echo "body<<EOF" >> $GITHUB_OUTPUT
147 echo "$BODY" >> $GITHUB_OUTPUT
148 echo "EOF" >> $GITHUB_OUTPUT
149
150 - name: Create Pull Request
151 uses: peter-evans/create-pull-request@v8
152 with:
153 token: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
154 commit-message: "docs: update feature screenshots"
155 title: "docs: update feature screenshots"
156 body: ${{ steps.pr-body.outputs.body }}
157 branch: "update-screenshots"
158 base: "master"
159 add-paths: docs/docs/assets/features/
160 labels: documentation