WIP - Automate readme screenshots #45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate Screenshots | |
on: [push, pull_request] | |
jobs: | |
screenshot: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ">=3.7 <3.12" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install . | |
Invoke-WebRequest -Uri "https://www.nirsoft.net/utils/nircmd.zip" -OutFile "nircmd.zip" | |
Expand-Archive -Path "nircmd.zip" -DestinationPath "C:\nircmd" | |
echo "C:\nircmd" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 | |
- name: Run app and take screenshot | |
run: | | |
$version = (Get-Content torf_gui\version.py | Select-String -Pattern '__version__ = "(.*)"').Matches.Groups[1].Value | |
# Debug print version | |
Write-Host "Version: $version" | |
# Start app | |
Start-Process -NoNewWindow -FilePath "python" -ArgumentList "torf_gui/gui.py" | |
# Wait for app to start | |
Start-Sleep -Seconds 5 | |
# Make sure app is current active window | |
nircmd win activate title "torf-gui $version" | |
# Take screenshot | |
nircmd savescreenshotwin screenshot-light.png | |
# Switch to dark theme | |
# TODO: This doesn't work yet | |
shell: powershell | |
- name: Upload screenshot | |
uses: actions/upload-artifact@v3 | |
with: | |
name: screenshot-light | |
path: screenshot-light.png |