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:
1 parent
e5750ef24b
commit
fb5602452a
13 files changed
+818
-11
No files matched your search
@@ -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
|
||||
|
||||
@@ -12,6 +12,7 @@ the [README](../README.md).
|
||||
- [Key bindings](#key-bindings)
|
||||
- [Saving](#saving)
|
||||
- [Reloading Ghostty](#reloading-ghostty)
|
||||
- [Updating ghosttyconf](#updating-ghosttyconf)
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
|
||||
## Which file is edited
|
||||
@@ -279,6 +280,29 @@ The documentation of an option mentions this where it matters.
|
||||
Use `--no-reload` to only save. The status line then reminds you of the
|
||||
shortcut.
|
||||
|
||||
## Updating ghosttyconf
|
||||
|
||||
`ghosttyconf --update` installs the newest release from
|
||||
[git.micw.org](https://git.micw.org/mike/ghosttyconf/releases) in place of the
|
||||
running binary, and `ghosttyconf --check-update` only looks. The update:
|
||||
|
||||
1. asks for the newest release that is neither a draft nor a prerelease,
|
||||
2. downloads `ghosttyconf-<os>-<arch>` next to the running binary and checks
|
||||
its size,
|
||||
3. starts the download once with `--version` and expects the new version
|
||||
number,
|
||||
4. renames it over the old binary. A symlink stays and the file behind it is
|
||||
replaced.
|
||||
|
||||
If any step fails, the old binary stays as it was.
|
||||
|
||||
Once a day, a normal start also asks in the background, without delaying the
|
||||
start. A newer release then shows up on the next start, in yellow on the
|
||||
right of the header and at the top of the help (`?`), and once more as a line
|
||||
in the terminal after you quit. Nothing is installed on its own. The check
|
||||
stays quiet when stderr is not a terminal, and `GHOSTTYCONF_NO_UPDATE_CHECK=1`
|
||||
turns it off.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**"Ghostty refused the AppleScript command"**: your config sets
|
||||
@@ -296,6 +320,12 @@ Ghostty release, see [Development](development.md#updating-for-a-new-ghostty-rel
|
||||
**A key combination can't be recorded**: Ghostty or macOS handled it before
|
||||
ghosttyconf could see it. Type it into the trigger field.
|
||||
|
||||
**"cannot write to …" on `--update`**: ghosttyconf lives in a directory you
|
||||
can't write to, such as `/usr/local/bin`. Run `sudo ghosttyconf --update`.
|
||||
|
||||
**`--update` is an unknown flag**: that is version 1.0.0, from before
|
||||
self-update. Download the newest release by hand once.
|
||||
|
||||
**Validation fails for an entry you didn't touch**: the problem was already
|
||||
in your file. ghosttyconf marks invalid values in red. Fix or reset them, or
|
||||
save anyway.
|
||||
Reference in new issue
Block a user