|
| 1 | +# Auto-Update System for PiwigoPublish Plugin |
| 2 | + |
| 3 | +By Gotcha26 - contact@julien-moreau.fr |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The auto-update system allows the PiwigoPublish Lightroom plugin to check for new versions via the GitHub Releases API and notify users when updates are available. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Automatic check on startup**: Silent check when Lightroom loads (once per day) |
| 12 | +- **Manual check**: Button in Plugin Manager to check on demand |
| 13 | +- **Multi-format versioning**: Supports both date-based and SemVer formats |
| 14 | +- **Cross-format comparison**: Can compare versions even when switching versioning schemes |
| 15 | +- **User-friendly notifications**: Dialog with changelog and download link |
| 16 | + |
| 17 | +## Version Format Support |
| 18 | + |
| 19 | +| Format | Example | Use Case | |
| 20 | +|--------|---------|----------| |
| 21 | +| Date-based | `20260121.3` or `v20260121.3` | Current format, revision incremented daily | |
| 22 | +| SemVer | `1.2.3` or `v1.2.3` | Industry standard, for future migration | |
| 23 | + |
| 24 | +The system automatically detects which format is used and applies the appropriate comparison logic. |
| 25 | + |
| 26 | +### Cross-Format Comparison |
| 27 | + |
| 28 | +When the local and remote versions use different formats, the system falls back to comparing the **GitHub release publish date** (`published_at` metadata) against the **build date** embedded in the local version. |
| 29 | + |
| 30 | +This ensures seamless updates even if the versioning scheme changes in the future. |
| 31 | + |
| 32 | +## Configuration |
| 33 | + |
| 34 | +In `UpdateChecker.lua`, the following constants can be adjusted: |
| 35 | + |
| 36 | +```lua |
| 37 | +UpdateChecker.GITHUB_OWNER = "Piwigo" -- GitHub organization/user |
| 38 | +UpdateChecker.GITHUB_REPO = "PiwigoPublish-lrc-plugin" -- Repository name |
| 39 | +UpdateChecker.CHECK_INTERVAL_DAYS = 1 -- Days between automatic checks |
| 40 | +``` |
| 41 | + |
| 42 | +## User Interface |
| 43 | + |
| 44 | +### Plugin Manager Section |
| 45 | + |
| 46 | +A new "Plugin Updates" section appears in **File > Plug-in Manager > Piwigo Publisher**: |
| 47 | + |
| 48 | +- Current version display |
| 49 | +- Update status indicator |
| 50 | +- "Check for Updates" button |
| 51 | +- "Visit GitHub Repository" button |
| 52 | + |
| 53 | +### Update Notification Dialog |
| 54 | + |
| 55 | +When an update is available, users see: |
| 56 | + |
| 57 | +- Current vs. new version comparison |
| 58 | +- Changelog excerpt (first 500 characters) |
| 59 | +- "Download" button → opens GitHub release page |
| 60 | +- "Later" button → dismisses until next check |
| 61 | + |
| 62 | +## Creating a New Release |
| 63 | + |
| 64 | +1. Update `VERSION` in `Info.lua`: |
| 65 | + ```lua |
| 66 | + VERSION = { major=20260122, minor=1, revision=0 }, |
| 67 | + ``` |
| 68 | + |
| 69 | +2. Commit and push changes |
| 70 | + |
| 71 | +3. Create a GitHub Release: |
| 72 | + - **Tag**: `v20260122.1` (or `v1.0.0` for SemVer) |
| 73 | + - **Title**: Version number or descriptive title |
| 74 | + - **Description**: Changelog in Markdown format |
| 75 | + |
| 76 | +4. The plugin will automatically detect the new release |
| 77 | + |
| 78 | +## Technical Details |
| 79 | + |
| 80 | +### API Endpoint |
| 81 | + |
| 82 | +``` |
| 83 | +GET https://api.github.com/repos/{owner}/{repo}/releases/latest |
| 84 | +``` |
| 85 | + |
| 86 | +### Response Fields Used |
| 87 | + |
| 88 | +| Field | Purpose | |
| 89 | +|-------|---------| |
| 90 | +| `tag_name` | Version identifier | |
| 91 | +| `published_at` | Release date (ISO 8601) for cross-format comparison | |
| 92 | +| `body` | Changelog content (Markdown) | |
| 93 | +| `html_url` | Download page URL | |
| 94 | + |
| 95 | +### Storage (LrPrefs) |
| 96 | + |
| 97 | +| Key | Purpose | |
| 98 | +|-----|---------| |
| 99 | +| `lastUpdateCheck` | Timestamp of last check | |
| 100 | +| `latestVersion` | Cached latest version string | |
| 101 | +| `latestVersionUrl` | Cached download URL | |
| 102 | +| `pluginBuildDate` | Build date for SemVer installations | |
| 103 | + |
| 104 | +## Functions Reference |
| 105 | + |
| 106 | +| Function | Description | |
| 107 | +|----------|-------------| |
| 108 | +| `parseVersion(versionStr)` | Converts version string to comparable number | |
| 109 | +| `parseGitHubDate(dateStr)` | Parses ISO 8601 date to timestamp | |
| 110 | +| `getInstalledVersionDate()` | Extracts build date from installed version | |
| 111 | +| `shouldCheckForUpdates()` | Checks if interval has elapsed | |
| 112 | +| `checkForUpdates(silent)` | Main update check logic | |
| 113 | +| `openDownloadPage(url)` | Opens browser to download page | |
| 114 | +| `getUpdateStatus()` | Returns status string for UI | |
| 115 | + |
| 116 | +## Future Considerations |
| 117 | + |
| 118 | +- **Migration to SemVer**: The system is ready for a versioning scheme change without breaking update detection |
| 119 | +- **Pre-release support**: Could be extended to check for beta/RC releases via `prerelease` flag |
| 120 | +- **Auto-download**: Could be enhanced to download and extract updates automatically (requires additional permissions) |
| 121 | + |
| 122 | +## Files Modified |
| 123 | + |
| 124 | +| File | Changes | |
| 125 | +|------|---------| |
| 126 | +| `UpdateChecker.lua` | New file - update checking logic | |
| 127 | +| `Init.lua` | Added require and startup check | |
| 128 | +| `PluginInfoDialogSections.lua` | Added "Plugin Updates" UI section | |
| 129 | +| `Info.lua` | VERSION table (existing, used as source of truth) | |
0 commit comments