screenshots.yml

  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: Create Dummy Config
 30        run: |
 31          mkdir -p ~/.config/matcha
 32          cat <<EOF > ~/.config/matcha/config.json
 33          {
 34            "accounts": [
 35              {
 36                "id": "demo-user",
 37                "name": "Matcha Client",
 38                "email": "matcha@floatpane.com",
 39                "password": "dummy-password",
 40                "service_provider": "custom",
 41                "fetch_email": "matcha@floatpane.com"
 42              }
 43            ]
 44          }
 45          EOF
 46
 47      - name: Create Dummy Drafts
 48        run: |
 49          cat <<EOF > ~/.config/matcha/drafts.json
 50          {
 51            "drafts": [
 52              {
 53                "id": "draft-001",
 54                "to": "team@example.com",
 55                "subject": "Q1 Planning Document",
 56                "body": "# Q1 Planning\n\nHere are the key objectives for Q1...",
 57                "account_id": "demo-user"
 58              },
 59              {
 60                "id": "draft-002",
 61                "to": "alice@example.com",
 62                "subject": "Re: Design Review Feedback",
 63                "body": "Thanks for the review! I'll address the comments...",
 64                "account_id": "demo-user"
 65              }
 66            ],
 67            "updated_at": "2026-01-15T10:00:00Z"
 68          }
 69          EOF
 70
 71      - name: Build Matcha
 72        env:
 73          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 74        run: |
 75          LATEST_TAG=$(gh release view --json tagName -q ".tagName" 2>/dev/null || echo "dev")
 76          echo "Using version: $LATEST_TAG"
 77
 78          git fetch --tags 2>/dev/null || true
 79
 80          COMMIT=$(git rev-parse --short HEAD)
 81          DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
 82          go build -ldflags="-s -w -X main.version=$LATEST_TAG -X main.commit=$COMMIT -X main.date=$DATE" -o matcha .
 83          go build -o email_view ./screenshots/cmd/email_view
 84          go build -o inbox_view ./screenshots/cmd/inbox_view
 85
 86      - name: Prepare Tapes
 87        run: |
 88          for tape in screenshots/*.tape; do
 89            [ "$tape" = "screenshots/common.tape" ] && continue
 90            sed -i 's|go run \./screenshots/cmd/email_view|./email_view|' "$tape"
 91            sed -i 's|go run \./screenshots/cmd/inbox_view|./inbox_view|' "$tape"
 92            sed -i 's|go run \.|./matcha|' "$tape"
 93          done
 94
 95      - name: Install Dependencies
 96        run: |
 97          sudo apt-get update
 98          sudo apt-get install -y ffmpeg ttyd
 99          mkdir -p ~/.local/share/fonts
100          wget -q https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/JetBrainsMono.zip
101          unzip -o JetBrainsMono.zip -d ~/.local/share/fonts
102          fc-cache -fv
103          go install github.com/charmbracelet/vhs@latest
104
105      - name: Generate Screenshots
106        env:
107          CLICOLOR_FORCE: "1"
108        run: |
109          mkdir -p docs/docs/assets/features/
110          for tape in screenshots/*.tape; do
111            [ "$tape" = "screenshots/common.tape" ] && continue
112            name=$(basename "$tape" .tape)
113            echo "==> Generating screenshot: $name"
114            TERM=xterm-256color vhs "$tape" || echo "Warning: $name failed"
115          done
116          # Move generated screenshots to public assets, clean up intermediate gifs
117          mv screenshots/*.png docs/docs/assets/features/ 2>/dev/null || true
118          rm -f screenshots/*.gif 2>/dev/null || true
119          ls -la docs/docs/assets/features/
120
121      - name: Create Pull Request
122        uses: peter-evans/create-pull-request@v8
123        with:
124          token: ${{ secrets.GITHUB_TOKEN }}
125          commit-message: "docs: update feature screenshots [skip ci]"
126          title: "docs: update feature screenshots"
127          body: |
128            This PR updates the feature screenshots based on the latest release version.
129
130            Generated automatically by the Generate Screenshots workflow.
131
132            ### Screenshots included:
133            - `main_menu.png` - Main menu / choice screen
134            - `compose_email.png` - Email composition with Markdown
135            - `compose_empty.png` - Clean compose interface
136            - `email_view.png` - HTML email with inline images and attachments
137            - `inbox_view.png` - Inbox with emails from various senders and dates
138            - `settings.png` - Settings / account management
139            - `drafts.png` - Draft management view
140          branch: "update-screenshots"
141          base: "master"
142          add-paths: docs/docs/assets/features/