Fix release workflow trigger conditions #59
This file contains hidden or 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: Build | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: [ "v*" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| release: | |
| types: [ published ] | |
| jobs: | |
| # ── Linux ──────────────────────────────────────────────────────────────────── | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev wget | |
| - name: Build | |
| run: make | |
| - name: Create AppDir | |
| run: | | |
| mkdir -p AppDir/usr/bin AppDir/usr/lib \ | |
| AppDir/usr/share/applications \ | |
| AppDir/usr/share/icons/hicolor/256x256/apps | |
| cp photon AppDir/usr/bin/photon | |
| ldd photon | awk ' | |
| /=> \// { print $3 } | |
| /^\// { print $1 } | |
| ' | sort -u | while read -r lib; do | |
| base="$(basename "$lib")" | |
| case "$base" in | |
| libc.so.*|libm.so.*|libpthread.so.*|librt.so.*|libdl.so.*|ld-linux*.so.*) | |
| continue | |
| ;; | |
| esac | |
| cp -L "$lib" AppDir/usr/lib/ | |
| done | |
| install -m 0644 installer/linux/photon.desktop \ | |
| AppDir/usr/share/applications/photon.desktop | |
| install -m 0644 installer/photon.png \ | |
| AppDir/usr/share/icons/hicolor/256x256/apps/photon.png | |
| cp AppDir/usr/share/applications/photon.desktop AppDir/photon.desktop | |
| cp AppDir/usr/share/icons/hicolor/256x256/apps/photon.png AppDir/photon.png | |
| install -m 0755 installer/linux/AppRun AppDir/AppRun | |
| - name: Download appimagetool | |
| run: | | |
| wget -q "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" \ | |
| -O appimagetool | |
| chmod +x appimagetool | |
| - name: Build AppImage | |
| run: ARCH=x86_64 ./appimagetool --appimage-extract-and-run AppDir Photon-x86_64.AppImage | |
| - name: Upload AppImage artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Photon-Linux-AppImage | |
| path: Photon-x86_64.AppImage | |
| # ── Windows ────────────────────────────────────────────────────────────────── | |
| build-windows: | |
| runs-on: windows-latest | |
| defaults: | |
| run: | |
| shell: msys2 {0} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| install: >- | |
| mingw-w64-x86_64-gcc | |
| mingw-w64-x86_64-SDL2 | |
| mingw-w64-x86_64-SDL2_image | |
| mingw-w64-x86_64-SDL2_ttf | |
| make | |
| - name: Install NSIS | |
| shell: pwsh | |
| run: choco install nsis -y --no-progress | |
| - name: Build | |
| run: make | |
| - name: Bundle DLLs | |
| run: | | |
| mkdir -p release | |
| cp photon.exe release/ | |
| # Auto-detect every DLL photon.exe needs and copy from /mingw64/bin | |
| ldd photon.exe \ | |
| | grep -i '/mingw64/' \ | |
| | awk '{print $3}' \ | |
| | xargs -I{} cp {} release/ | |
| - name: Build installer | |
| shell: pwsh | |
| run: | | |
| $env:PATH = "C:\Program Files (x86)\NSIS;$env:PATH" | |
| $workdir = (Get-Location).Path -replace '\\','/' | |
| & "makensis.exe" /DWORKDIR="$workdir\release" installer\windows\photon.nsi | |
| - name: Zip portable release | |
| shell: pwsh | |
| run: Compress-Archive -Path release\* -DestinationPath Photon-Windows.zip | |
| - name: Upload Windows artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Photon-Windows | |
| path: | | |
| Photon-Windows.zip | |
| Photon-Setup.exe | |
| # ── GitHub Release ─────────────────────────────────────────────────────────── | |
| release: | |
| name: Create GitHub Release | |
| needs: [ build-linux, build-windows ] | |
| runs-on: ubuntu-latest | |
| if: | | |
| (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || | |
| (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v')) | |
| permissions: | |
| contents: write | |
| env: | |
| RELEASE_TAG: ${{ github.event.release.tag_name || github.ref_name }} | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.RELEASE_TAG }} | |
| name: Photon ${{ env.RELEASE_TAG }} | |
| body: | | |
| ## Photon Image Viewer ${{ env.RELEASE_TAG }} | |
| ### Downloads | |
| | Platform | File | Notes | | |
| |----------|------|-------| | |
| | Windows (Installer) | `Photon-Setup.exe` | Installs to Program Files, adds Photon to Open With | | |
| | Windows (Portable) | `Photon-Windows.zip` | Extract and run `photon.exe` — no install needed | | |
| | Linux | `Photon-x86_64.AppImage` | `chmod +x` then run | | |
| ### Controls | |
| | Key | Action | | |
| |-----|--------| | |
| | `O` | Open file dialog | | |
| | `←` / `→` | Previous / next image | | |
| | `R` / `Shift+R` | Rotate clockwise / counter-clockwise | | |
| | `I` | Toggle info panel | | |
| | `T` | Toggle thumbnail strip | | |
| | `Ctrl+C` | Copy image on Windows, file path on Linux/macOS | | |
| | `Del` | Delete image (with confirmation) | | |
| | `F` | Fit to window | | |
| | `1` | Actual size | | |
| | Mouse drag | Pan image | | |
| | Scroll wheel | Zoom | | |
| | Drag & drop | Open dropped image file | | |
| files: | | |
| Photon-Linux-AppImage/Photon-x86_64.AppImage | |
| Photon-Windows/Photon-Windows.zip | |
| Photon-Windows/Photon-Setup.exe |