Add self-update, version 1.0.1

ghosttyconf --update installs the newest release from git.micw.org,
--check-update only checks. The download lands next to the running
binary, is started once with --version and only then replaces it.

Once a day a normal start asks in the background and mentions a newer
release in the header, at the top of the help and on stderr after
quitting; only on a terminal and not with GHOSTTYCONF_NO_UPDATE_CHECK
set. selfupdate.go is nscan's copyable template, with goca's --update
spelling in the hints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mikeandClaude Opus 5.5 committed 2026-10-28 10:22:51 +01:00
1 parent e5750ef24b
commit fb5602452a
13 files changed
+818 -11

No files matched your search

+25
View File
@@ -26,6 +26,7 @@ for macOS and Linux. Other platforms only save.
| `main.go` | flags, startup, wiring |
| `version.go`, `version.txt` | the version: `version.txt` is the released one, `build.sh` injects it |
| `build.sh` | builds the release binaries into `./bin` |
| `selfupdate.go` | `--update`, `--check-update` and the daily background check against the Gitea releases |
| `internal/schema` | the option schema: kinds, categories, platform detection, value validation; `schema.json` is embedded |
| `internal/config` | the comment- and layout-preserving config file model, atomic saving |
| `internal/ghostty` | finding and running the `ghostty` binary (docs, themes, fonts, actions, validation), config paths, reload |
@@ -64,6 +65,30 @@ on git.micw.org. Every regular file in `./bin` is attached to it. If the tag
already exists with a longer annotation, that annotation becomes the release
notes. `./bin` is not part of the repository.
### Self-update
`selfupdate.go` is the copyable template from nscan (originally goca). Only
its configuration block is specific to ghosttyconf: the repository URL, the
asset name and `GHOSTTYCONF_NO_UPDATE_CHECK`. It relies on the release layout
above, so keep these when changing the build or the release:
- The tag is the bare version number.
- The assets are named `ghosttyconf-<os>-<arch>`, exactly as `build.sh` names
them.
- `ghosttyconf --version` prints the version number. The downloaded binary is
started with it, and the update is refused if the number is missing.
- The release is neither a draft nor a prerelease. Gitea's
`/releases/latest` skips both, so a prerelease is a way to publish without
offering it as an update.
The daily check starts the program again as `ghosttyconf --update-refresh`
and doesn't wait for it. `main` takes that argument before the flags, so it
stays out of the help. The note goes to
`os.UserCacheDir()/ghosttyconf/update.json`. `tools/screenshots.sh` sets
`GHOSTTYCONF_NO_UPDATE_CHECK=1`, so no update hint lands in a screenshot. The
tests in `selfupdate_test.go` run against a fake Gitea built with `httptest`
and never touch the network.
## The schema
Ghostty's own documentation (`ghostty +show-config --default --docs`) contains