diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml new file mode 100644 index 0000000..34034d8 --- /dev/null +++ b/.github/workflows/screenshots.yml @@ -0,0 +1,53 @@ +name: Screenshots + +on: + push: + branches: [main] + paths: + - '*.go' + - 'examples/**/*.go' + - 'examples/**/*.tape' + pull_request: + paths: + - '*.go' + - 'examples/**/*.go' + - 'examples/**/*.tape' + workflow_dispatch: + +permissions: + contents: write + +jobs: + screenshots: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Install vhs dependencies + run: sudo apt-get update -q && sudo apt-get install -y ffmpeg ttyd + + - name: Install vhs + run: go install github.com/charmbracelet/vhs@latest + + - name: Pre-build examples + run: go build ./examples/... + + - name: Generate screenshots + run: find examples -name '*.tape' -print0 | sort -z | xargs -0 -I{} vhs {} + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: screenshots + path: 'examples/**/*.gif' + + - uses: stefanzweifel/git-auto-commit-action@v5 + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + with: + commit_message: 'chore: update example screenshots [skip ci]' + file_pattern: 'examples/**/*.gif' diff --git a/examples/basic/basic.tape b/examples/basic/basic.tape new file mode 100644 index 0000000..f263377 --- /dev/null +++ b/examples/basic/basic.tape @@ -0,0 +1,15 @@ +Output examples/basic/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 200 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/basic/" +Enter +Sleep 10s diff --git a/examples/basic/screenshot.gif b/examples/basic/screenshot.gif new file mode 100644 index 0000000..06fd2de Binary files /dev/null and b/examples/basic/screenshot.gif differ diff --git a/examples/colorize/colorize.tape b/examples/colorize/colorize.tape new file mode 100644 index 0000000..b33dbf8 --- /dev/null +++ b/examples/colorize/colorize.tape @@ -0,0 +1,15 @@ +Output examples/colorize/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 450 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/colorize/" +Enter +Sleep 10s diff --git a/examples/colorize/screenshot.gif b/examples/colorize/screenshot.gif new file mode 100644 index 0000000..fd467c8 Binary files /dev/null and b/examples/colorize/screenshot.gif differ diff --git a/examples/colors/colors.tape b/examples/colors/colors.tape new file mode 100644 index 0000000..1b9a349 --- /dev/null +++ b/examples/colors/colors.tape @@ -0,0 +1,15 @@ +Output examples/colors/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 1000 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/colors/" +Enter +Sleep 15s diff --git a/examples/colors/screenshot.gif b/examples/colors/screenshot.gif new file mode 100644 index 0000000..724d376 Binary files /dev/null and b/examples/colors/screenshot.gif differ diff --git a/examples/custom-theme/custom-theme.tape b/examples/custom-theme/custom-theme.tape new file mode 100644 index 0000000..f88a28f --- /dev/null +++ b/examples/custom-theme/custom-theme.tape @@ -0,0 +1,15 @@ +Output examples/custom-theme/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 800 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/custom-theme/" +Enter +Sleep 15s diff --git a/examples/custom-theme/screenshot.gif b/examples/custom-theme/screenshot.gif new file mode 100644 index 0000000..00a00d1 Binary files /dev/null and b/examples/custom-theme/screenshot.gif differ diff --git a/examples/env-theme/env-theme.tape b/examples/env-theme/env-theme.tape new file mode 100644 index 0000000..c2f6496 --- /dev/null +++ b/examples/env-theme/env-theme.tape @@ -0,0 +1,15 @@ +Output examples/env-theme/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 500 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "CLI_THEME=dracula go run ./examples/env-theme/" +Enter +Sleep 15s diff --git a/examples/env-theme/screenshot.gif b/examples/env-theme/screenshot.gif new file mode 100644 index 0000000..1a7a1fe Binary files /dev/null and b/examples/env-theme/screenshot.gif differ diff --git a/examples/fatal/fatal.tape b/examples/fatal/fatal.tape new file mode 100644 index 0000000..5764d95 --- /dev/null +++ b/examples/fatal/fatal.tape @@ -0,0 +1,15 @@ +Output examples/fatal/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 250 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/fatal/" +Enter +Sleep 10s diff --git a/examples/fatal/screenshot.gif b/examples/fatal/screenshot.gif new file mode 100644 index 0000000..8a633ce Binary files /dev/null and b/examples/fatal/screenshot.gif differ diff --git a/examples/formatting/formatting.tape b/examples/formatting/formatting.tape new file mode 100644 index 0000000..c14d12c --- /dev/null +++ b/examples/formatting/formatting.tape @@ -0,0 +1,15 @@ +Output examples/formatting/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 650 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/formatting/" +Enter +Sleep 15s diff --git a/examples/formatting/screenshot.gif b/examples/formatting/screenshot.gif new file mode 100644 index 0000000..ff6f95c Binary files /dev/null and b/examples/formatting/screenshot.gif differ diff --git a/examples/instance/instance.tape b/examples/instance/instance.tape new file mode 100644 index 0000000..4c4d456 --- /dev/null +++ b/examples/instance/instance.tape @@ -0,0 +1,15 @@ +Output examples/instance/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 900 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/instance/" +Enter +Sleep 15s diff --git a/examples/instance/screenshot.gif b/examples/instance/screenshot.gif new file mode 100644 index 0000000..1f6ff8c Binary files /dev/null and b/examples/instance/screenshot.gif differ diff --git a/examples/levels/levels.tape b/examples/levels/levels.tape new file mode 100644 index 0000000..5611dc6 --- /dev/null +++ b/examples/levels/levels.tape @@ -0,0 +1,15 @@ +Output examples/levels/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 800 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/levels/" +Enter +Sleep 15s diff --git a/examples/levels/screenshot.gif b/examples/levels/screenshot.gif new file mode 100644 index 0000000..a2681e4 Binary files /dev/null and b/examples/levels/screenshot.gif differ diff --git a/examples/nocolor/nocolor.tape b/examples/nocolor/nocolor.tape new file mode 100644 index 0000000..4c06cf1 --- /dev/null +++ b/examples/nocolor/nocolor.tape @@ -0,0 +1,15 @@ +Output examples/nocolor/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 800 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/nocolor/" +Enter +Sleep 15s diff --git a/examples/nocolor/screenshot.gif b/examples/nocolor/screenshot.gif new file mode 100644 index 0000000..4a07495 Binary files /dev/null and b/examples/nocolor/screenshot.gif differ diff --git a/examples/prefix/prefix.tape b/examples/prefix/prefix.tape new file mode 100644 index 0000000..9067561 --- /dev/null +++ b/examples/prefix/prefix.tape @@ -0,0 +1,15 @@ +Output examples/prefix/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 800 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/prefix/" +Enter +Sleep 15s diff --git a/examples/prefix/screenshot.gif b/examples/prefix/screenshot.gif new file mode 100644 index 0000000..a3d91b3 Binary files /dev/null and b/examples/prefix/screenshot.gif differ diff --git a/examples/real-world/real-world.tape b/examples/real-world/real-world.tape new file mode 100644 index 0000000..5c7ab80 --- /dev/null +++ b/examples/real-world/real-world.tape @@ -0,0 +1,15 @@ +Output examples/real-world/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 700 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/real-world/" +Enter +Sleep 25s diff --git a/examples/real-world/screenshot.gif b/examples/real-world/screenshot.gif new file mode 100644 index 0000000..1528475 Binary files /dev/null and b/examples/real-world/screenshot.gif differ diff --git a/examples/theme-selector/screenshot.gif b/examples/theme-selector/screenshot.gif new file mode 100644 index 0000000..8a034de Binary files /dev/null and b/examples/theme-selector/screenshot.gif differ diff --git a/examples/theme-selector/theme-selector.tape b/examples/theme-selector/theme-selector.tape new file mode 100644 index 0000000..550c48f --- /dev/null +++ b/examples/theme-selector/theme-selector.tape @@ -0,0 +1,15 @@ +Output examples/theme-selector/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 950 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/theme-selector/ --list" +Enter +Sleep 15s diff --git a/examples/themes/screenshot.gif b/examples/themes/screenshot.gif new file mode 100644 index 0000000..625c48e Binary files /dev/null and b/examples/themes/screenshot.gif differ diff --git a/examples/themes/themes.tape b/examples/themes/themes.tape new file mode 100644 index 0000000..3958671 --- /dev/null +++ b/examples/themes/themes.tape @@ -0,0 +1,15 @@ +Output examples/themes/screenshot.gif + +Set Shell "bash" +Set FontSize 14 +Set Width 1200 +Set Height 5000 +Set Theme "Dracula" +Set TypingSpeed 10ms + +Env PS1 "$ " + +Sleep 500ms +Type "go run ./examples/themes/" +Enter +Sleep 15s diff --git a/justfile b/justfile index 95b49c4..4660d5f 100644 --- a/justfile +++ b/justfile @@ -38,5 +38,9 @@ fmt: vet: go vet ./... +# generate screenshots for all examples (requires vhs: https://github.com/charmbracelet/vhs) +screenshots: + find examples -name '*.tape' -print0 | sort -z | xargs -0 -I{} vhs {} + # run all checks (fmt, vet, lint, test) check: fmt vet lint test diff --git a/mise.toml b/mise.toml index 5a064cf..88486a8 100644 --- a/mise.toml +++ b/mise.toml @@ -1,3 +1,4 @@ [tools] go = "1.26.0" golangci-lint = "2.8.0" +"ubi:charmbracelet/vhs" = "latest"