Upload screenshots to GitHub release in CI
Captures screenshots after creating the release, tarballs them,
and attaches the archive as a release asset. The capture task
outputs JSON in CI for reliable path extraction via jq.

Assisted-by: Claude Opus 4.6 via Claude Code
change zmyzpqqukosvwrulsywpxplpxtqxuyum
commit 48796c21fbd446ee1859db7257f2a1d85bbfe28e
author Alpha Chen <alpha@kejadlen.dev>
date
parent tmqykqnz
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d69491f..49d8b45 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -25,6 +25,9 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
+      - uses: ruby/setup-ruby@v1
+        with:
+          bundler-cache: true
       - uses: docker/setup-buildx-action@v3
       - uses: docker/login-action@v3
         if: github.ref == 'refs/heads/main' && github.event_name == 'push'
@@ -52,3 +55,12 @@ jobs:
         env:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: gh release create "${{ steps.meta.outputs.version }}" --generate-notes
+      - if: github.ref == 'refs/heads/main' && github.event_name == 'push'
+        run: |
+          output=$(bundle exec rake snapshots:capture)
+          dir=$(echo "$output" | jq -r .output_dir)
+          tar czf snapshots.tar.gz -C "$dir" .
+      - if: github.ref == 'refs/heads/main' && github.event_name == 'push'
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: gh release upload "${{ steps.meta.outputs.version }}" snapshots.tar.gz
diff --git a/Rakefile b/Rakefile
index b16fa74..af555ab 100644
--- a/Rakefile
+++ b/Rakefile
@@ -124,7 +124,12 @@ namespace :snapshots do
     launcher.stop
     thread.join
 
-    puts "Screenshots saved to #{output_dir}"
+    if ENV["CI"]
+      require "json"
+      puts({ output_dir: output_dir }.to_json)
+    else
+      puts "Screenshots saved to #{output_dir}"
+    end
   end
 
   desc "Compare current screenshots against baseline from latest release"