feat(release): prereleases on the Homebrew tap, as devvm-rc (#19)

Prereleases now reach the Homebrew tap through a second formula, `devvm-rc`. The stable `devvm` formula stays on the last final release.

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
CJandClaude Opus 5.5 authored and GitHub committed 2026-11-07 11:36:20 -07:00
1 parent c27b913b17
commit 72b648df31
25 files changed
+831 -186

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ Install devvm's newest release
## Synopsis
Install devvm's newest release the way this devvm was installed, after asking. The install script's devvm gets the release once its signature and checksum check out, and Homebrew's runs brew upgrade devvm. --check only says whether a newer release is out.
Install devvm's newest release the way this devvm was installed, after asking. The install script's devvm gets the release once its signature and checksum check out, and Homebrew's runs brew upgrade devvm, or brew upgrade devvm-rc for the formula that follows prereleases. --check only says whether a newer release is out.
```text
devvm upgrade [flags]
+10 -8
View File
@@ -39,12 +39,13 @@ Until a fix ships, users can still build base, because devvm's fallback to the r
- **Once, the keys:** a minisign key for releases, `minisign -G -p packaging/minisign.pub -s ~/.minisign/devvm.key` (commit `packaging/minisign.pub`; the secret key and its password never go in the repo), and a key git signs tags with (`git config user.signingkey`, GPG, or SSH with `gpg.format ssh`) that `git tag -v` verifies on this machine. Commit its fingerprint in `packaging/release-signer`, one per line (`#` comments): the GPG fingerprint (`gpg --fingerprint`, no spaces), or the SSH key's `SHA256:…` (`ssh-keygen -lf KEY.pub`). `release.sh` refuses a tag signed by any other key, even one git trusts. To rotate, add the new key's line, tag with it, then remove the old one.
- **Each release:** bump `VERSION`, add the `CHANGELOG.md` entry and commit it on `main`. Then tag main's HEAD with `git tag -s v<version>` and run `mise exec -- scripts/publish.sh`, which asks for the minisign password once and asks once more before it publishes anything. The secret key never leaves this machine, and only minisign reads it, so no CI job and no GitHub secret ever has it.
- **A prerelease,** such as a release candidate or a beta, goes out the same way, with a version of the form `x.y.z-<word>.N`: `VERSION` holds `0.2.0-rc.1`, `CHANGELOG.md` gets an entry `## 0.2.0-rc.1`, and the tag is `v0.2.0-rc.1`. The word is lowercase letters, such as `rc`, `beta` or `alpha`, and `release.sh` refuses any other form of `VERSION`. `scripts/publish.sh` marks a prerelease's GitHub release as a prerelease, passing `--prerelease` to `gh release create` and `gh release edit`, so GitHub's latest release skips it, and so do the install script's default, devvm upgrade and the daily release check. It skips the tap altogether, so Homebrew stays on the last release, and it needs no tap checkout. Its printout says the tap is skipped, and it has three steps to do in place of four. At the end, it prints the prerelease's install script line and devvm upgrade `--to` with the version, for checking it.
- **A prerelease,** such as a release candidate or a beta, goes out the same way, with a version of the form `x.y.z-<word>.N`: `VERSION` holds `0.2.0-rc.1`, `CHANGELOG.md` gets an entry `## 0.2.0-rc.1`, and the tag is `v0.2.0-rc.1`. The word is lowercase letters, such as `rc`, `beta` or `alpha`, and `release.sh` refuses any other form of `VERSION`. `scripts/publish.sh` marks a prerelease's GitHub release as a prerelease, passing `--prerelease` to `gh release create` and `gh release edit`, so GitHub's latest release skips it, and so do the install script's default, devvm upgrade and the daily release check. In the tap it changes only `Formula/devvm-rc.rb`, the formula that follows prereleases, in a commit titled `devvm-rc <version>`, so the formula `devvm` stays on the last release. At the end, it prints how to check the prerelease with `brew upgrade devvm-rc` or `brew install devvmhq/tap/devvm-rc`, and the prerelease's install script line.
- **The tap's two formulas** are `devvm`, the newest release's, and `devvm-rc`, the newest prerelease's or release's, whichever is newer. `devvm-rc` only moves forward: each publish, a release's or a prerelease's, points `Formula/devvm-rc.rb` at the version it publishes, unless the tap's `devvm-rc` already names a newer one. So a release moves `devvm-rc` users onto it once it's newer than their prerelease, and a patch release of an older line, or a prerelease older than the tap's, leaves `devvm-rc` where it is. The printout says which way it goes, and when nothing in the tap changes, as for such a prerelease, it has no tap step and prints the install script line and devvm upgrade `--to` for checking it.
- **A prerelease's changelog entry** lists what changed since the version before it, whether that's a release or another prerelease, and it becomes that prerelease's notes on GitHub. When the release itself goes out, its entry, such as `## 0.2.0`, replaces its prereleases' entries and lists everything since the last release, so someone who upgrades from that release reads one entry. Each prerelease's notes stay on its GitHub release.
- **Before it builds,** `scripts/publish.sh` checks what it needs and stops with nothing done when a check fails. The tag `v<version>` has to pass `release.sh`'s own checks, so it exists, is signed, and is signed by a key in `packaging/release-signer`. The tag's commit has to be `main`'s HEAD, and `origin`'s `main` has to be an ancestor of it, so that the push is a fast-forward. If `origin` already has the tag, it has to be the same tag. The working tree has to be clean, `gh` has to be installed and logged in (`gh auth status`), and minisign has to be installed. A published GitHub release for the tag is refused unless it already has every file, which is the case when an earlier run stopped after it, and unless GitHub marks it as a prerelease exactly when the version is one. The refusal names the `gh release edit` command that fixes the mark. Except for a prerelease, the tap's checkout, a clone of `devvmhq/homebrew-tap`, has to exist, be clean and be on `main`: it's `DEVVM_TAP_DIR`, or `../homebrew-tap` next to this repo by default.
- **Then it builds and shows the release.** It runs `scripts/release.sh`, which builds `dist/` and signs `SHA256SUMS`, and where minisign asks for the password. It prints the version, the tag's commit, each file with its size and SHA-256, the release notes, which are the `CHANGELOG.md` entry for the version, and the tap's change as a `git diff` of `Formula/devvm.rb`, which a prerelease skips. It lists the four steps, each marked done or to do, and for a prerelease the fourth, the tap, as skipped. Then it asks `Publish devvm <version>? [y/N]` on the terminal, and any answer but y stops it with nothing published. `--dry-run` stops before the question, so it pushes and publishes nothing and makes no commit in the tap, and `--help` describes the script.
- **Then it publishes, in this order.** It pushes `main` and then the tag to `origin`. It makes the GitHub release `devvmhq/devvm` `v<version>` with `gh release create --verify-tag`, titled `devvm <version>`, with the release notes and the archives, the source tarball, `SHA256SUMS`, `SHA256SUMS.minisig` and `install.sh`. The release starts as a draft and is published only once every file is uploaded, so nobody sees a release that is missing files. Last, it copies `dist/devvm.rb` to the tap's `Formula/devvm.rb`, commits it as `devvm <version>` with the tap's own commit signing, and pushes the tap. It uses `gh` for GitHub and never puts a GitHub token on a command line. At the end it prints how to check the release: `brew update && brew upgrade devvm`, or `brew trust --formula devvmhq/tap/devvm` and then `brew install devvmhq/tap/devvm`, and the install script's `curl` line.
- **When a step fails,** it says which steps it published and which it didn't. Fix what failed and run it again, because every step skips what's already done: a pushed `main` or tag, a published release whose `SHA256SUMS` matches the new build's, and a tap already at the version, or any tap for a prerelease. A draft release that an earlier run left gets this build's files again before it's published. A release published from another build, whose `SHA256SUMS` doesn't match, is refused. To finish by hand instead, run the steps it didn't do in order: `git push origin main`, `git push origin v<version>`, the `gh release create` above (or `gh release upload --clobber` to a draft, then `gh release edit v<version> --draft=false`), each with `--prerelease` for a prerelease, and then, except for a prerelease, copy `dist/devvm.rb` to the tap, commit it and push it.
- **Before it builds,** `scripts/publish.sh` checks what it needs and stops with nothing done when a check fails. The tag `v<version>` has to pass `release.sh`'s own checks, so it exists, is signed, and is signed by a key in `packaging/release-signer`. The tag's commit has to be `main`'s HEAD, and `origin`'s `main` has to be an ancestor of it, so that the push is a fast-forward. If `origin` already has the tag, it has to be the same tag. The working tree has to be clean, `gh` has to be installed and logged in (`gh auth status`), and minisign has to be installed. A published GitHub release for the tag is refused unless it already has every file, which is the case when an earlier run stopped after it, and unless GitHub marks it as a prerelease exactly when the version is one. The refusal names the `gh release edit` command that fixes the mark. The tap's checkout, a clone of `devvmhq/homebrew-tap`, has to exist, be clean and be on `main`, for a prerelease too, and its `origin` has to have no commits that its `main` lacks. The checkout is `DEVVM_TAP_DIR`, or `../homebrew-tap` next to this repo by default.
- **Then it builds and shows the release.** It runs `scripts/release.sh`, which builds `dist/` and signs `SHA256SUMS`, and where minisign asks for the password. It prints the version, the tag's commit, each file with its size and SHA-256, the release notes, which are the `CHANGELOG.md` entry for the version, and the tap's changes as a `git diff` of each formula it writes: `Formula/devvm.rb` for a release, and `Formula/devvm-rc.rb`, with a line saying when a release moves it too, or when it stays on a newer version. It lists the four steps, each marked done or to do, and when nothing in the tap changes, the fourth says so. Then it asks `Publish devvm <version>? [y/N]` on the terminal, and any answer but y stops it with nothing published. `--dry-run` stops before the question, so it pushes and publishes nothing and makes no commit in the tap, and `--help` describes the script.
- **Then it publishes, in this order.** It pushes `main` and then the tag to `origin`. It makes the GitHub release `devvmhq/devvm` `v<version>` with `gh release create --verify-tag`, titled `devvm <version>`, with the release notes and the archives, the source tarball, `SHA256SUMS`, `SHA256SUMS.minisig` and `install.sh`. The release starts as a draft and is published only once every file is uploaded, so nobody sees a release that is missing files. Last, it copies `dist/devvm.rb` to the tap's `Formula/devvm.rb` and `dist/devvm-rc.rb` to its `Formula/devvm-rc.rb`, each only when it's one the tap gets and it differs, commits them in one commit, `devvm <version>` for a release or `devvm-rc <version>` for a prerelease, with the tap's own commit signing, and pushes the tap. It uses `gh` for GitHub and never puts a GitHub token on a command line. At the end it prints how to check the release: `brew update && brew upgrade devvm`, or `brew trust --formula devvmhq/tap/devvm` and then `brew install devvmhq/tap/devvm`, with `devvm-rc` in place of `devvm` for a prerelease, and the install script's `curl` line.
- **When a step fails,** it says which steps it published and which it didn't. Fix what failed and run it again, because every step skips what's already done: a pushed `main` or tag, a published release whose `SHA256SUMS` matches the new build's, and a tap whose formulas are already this build's. A draft release that an earlier run left gets this build's files again before it's published. A release published from another build, whose `SHA256SUMS` doesn't match, is refused. To finish by hand instead, run the steps it didn't do in order: `git push origin main`, `git push origin v<version>`, the `gh release create` above (or `gh release upload --clobber` to a draft, then `gh release edit v<version> --draft=false`), each with `--prerelease` for a prerelease, and then copy the formulas the printout listed, `dist/devvm.rb` and `dist/devvm-rc.rb`, to the tap's `Formula/`, commit them and push it.
- `scripts/release.sh` checks the tag with `git tag -v` and its signer against this checkout's `packaging/release-signer`, then builds `dist/` from the tagged commit with GoReleaser (`.goreleaser.yaml`), in a clone of its own, so only what's committed goes in, with one `goreleaser release --skip=publish`. It checks that the binary built for this host prints the version, writes `install.sh` and adds its checksum to `SHA256SUMS`, then signs `SHA256SUMS` with `~/.minisign/devvm.key` (or `DEVVM_MINISIGN_KEY`) and verifies it with `packaging/minisign.pub`. Nothing is published, because publishing is `scripts/publish.sh`'s. `scripts/release.sh --check` runs only the tag's checks and the build's preconditions, prints the tag's commit and builds nothing, and `scripts/publish.sh` runs it first.
- `dist/` then holds:
@@ -54,12 +55,13 @@ Until a fix ships, users can still build base, because devvm's fallback to the r
| `devvm-<version>.tar.gz` | the source, attached to the release for whoever wants to build devvm themselves |
| `SHA256SUMS`, `SHA256SUMS.minisig` | their checksums and `install.sh`'s, and the signature |
| `install.sh` | the install script, set to this release and to `packaging/minisign.pub`'s key |
| `devvm.rb` | the Homebrew formula, set to each platform's archive, its URL and its checksum from `SHA256SUMS` |
| `devvm-rc.rb` | the Homebrew formula `devvm-rc`, which follows prereleases, set to each platform's archive, its URL and its checksum from `SHA256SUMS` |
| `devvm.rb` | for a release, not a prerelease, the Homebrew formula `devvm`, set the same way |
- `scripts/release.sh --head` builds from HEAD's commit instead, for testing, with `VERSION`'s version, a release's or a prerelease's. It's unsigned unless `DEVVM_MINISIGN_KEY` names a test key; `DEVVM_MINISIGN_PUB` names its public key in place of `packaging/minisign.pub`. `DEVVM_RELEASE_URL` points the formula at a test location. A commit without `install.sh` is refused.
- `scripts/release.sh --formula-from DIR` writes only `dist/devvm.rb`, for `VERSION`'s release once it's published, and builds nothing. Download the release's `SHA256SUMS` and `SHA256SUMS.minisig` into `DIR` first. The script checks the signature against `packaging/minisign.pub`, then fills in the formula the same way a build does, from that `SHA256SUMS`.
- `scripts/release.sh --formula-from DIR` writes only the formulas, for `VERSION`'s release once it's published, and builds nothing: `dist/devvm-rc.rb`, and `dist/devvm.rb` too when `VERSION` isn't a prerelease. Download the release's `SHA256SUMS` and `SHA256SUMS.minisig` into `DIR` first. The script checks the signature against `packaging/minisign.pub`, and that its trusted comment is `devvm <version>` for `VERSION`'s version, so it refuses another release's files. Then it fills in the formulas the same way a build does, from that `SHA256SUMS`.
- To try `dist/install.sh` on such a build, copy `dist/` to `DIR/releases/download/v<version>/`, then in a throwaway `HOME` with `DEVVM_PREFIX` under it: `DEVVM_INSTALL_TEST=1 source dist/install.sh`, set `repo_url=file://DIR` and `protos='=https,file'` (it downloads over HTTPS only), and run `main --no-deps`. Without `--no-deps` it offers to install what the host lacks: answer no, or run it with no terminal.
- Every build sets the version with `-X github.com/devvmhq/devvm/internal/cli.version=<version>`: devvm doesn't read `VERSION`. The formula (`packaging/homebrew/devvm.rb`) builds nothing. It has an archive for each of macOS and Linux on arm64 and Intel, the same archives the install script installs, and it installs the binary alone from the one for this machine. `release.sh` fills in each archive's URL and its checksum, which it reads from the `SHA256SUMS` it just wrote, on every line that isn't a comment. The generated formula passes `brew audit --strict --online` and `brew style`.
- Every build sets the version with `-X github.com/devvmhq/devvm/internal/cli.version=<version>`: devvm doesn't read `VERSION`. The formula template (`packaging/homebrew/devvm.rb`) is both formulas' one source, and it builds nothing. It has an archive for each of macOS and Linux on arm64 and Intel, the same archives the install script installs, and it installs the binary alone from the one for this machine. `release.sh` fills in each formula's class, `Devvm` or `DevvmRc`, and the other formula, which it conflicts with by its full name, `devvmhq/tap/devvm-rc` or `devvmhq/tap/devvm`, because both install the `devvm` command. It also fills in each archive's URL and its checksum, which it reads from the `SHA256SUMS` it just wrote, on every line that isn't a comment. Both generated formulas pass `brew audit --strict --online` and `brew style`.
- Publishing is the maintainer's call, so an agent asks first and never runs `scripts/publish.sh` without `--dry-run` on its own. The script's tests (`testdata/script/publish.txtar`) run it against a local bare repo as `origin`, a local bare tap and a fake `gh`.
## The docs sites
+6 -4
View File
@@ -7,7 +7,7 @@ This page explains what devvm's install script downloads and checks, what `devvm
## The install script
The script installs the release it comes with, or the one that `--version` names, which may be a prerelease, such as `0.2.0-rc.1`. Without either, it installs the latest release, never a prerelease. Before it downloads anything, it checks whether Homebrew installed devvm, which it does when `brew` is on `PATH`. The check never runs `brew`, because Homebrew can download its own Ruby when it runs. Instead, the script looks for a version folder in `Cellar/devvm` in each place Homebrew keeps its Cellar: the folder next to the `brew` it found on `PATH` (`<brew's folder>/../Cellar`), `HOMEBREW_CELLAR` and `HOMEBREW_PREFIX/Cellar` when they're set, and the Cellar in `/opt/homebrew`, `/usr/local` and `/home/linuxbrew/.linuxbrew`. When Homebrew has devvm, the script stops with an error that says to run `brew upgrade devvm`, or `brew uninstall devvm` first, and exits with status 1, in a terminal or without one. `--force` skips this check. Then it installs in four steps:
The script installs the release it comes with, or the one that `--version` names, which may be a prerelease, such as `0.2.0-rc.1`. Without either, it installs the latest release, never a prerelease. Before it downloads anything, it checks whether Homebrew installed devvm, which it does when `brew` is on `PATH`. The check never runs `brew`, because Homebrew can download its own Ruby when it runs. Instead, the script looks for a version folder in `Cellar/devvm` or `Cellar/devvm-rc`, the kegs of Homebrew's two formulas, in each place Homebrew keeps its Cellar: the folder next to the `brew` it found on `PATH` (`<brew's folder>/../Cellar`), `HOMEBREW_CELLAR` and `HOMEBREW_PREFIX/Cellar` when they're set, and the Cellar in `/opt/homebrew`, `/usr/local` and `/home/linuxbrew/.linuxbrew`. When Homebrew has devvm, the script stops with an error that says to run `brew upgrade devvm`, or `brew uninstall devvm` first, each naming `devvm-rc` for its keg, and exits with status 1, in a terminal or without one. `--force` skips this check. Then it installs in four steps:
1. It downloads the archive for this machine and the release's `SHA256SUMS`, over HTTPS only. The archive is `devvm-<version>-<os>-<arch>.tar.gz`, where the OS is `darwin` or `linux` and the processor is `arm64` or `amd64`. On Apple silicon, the script picks `arm64` even when it runs under Rosetta.
2. It checks the signature of `SHA256SUMS`, then the archive's checksum, as [the signature](#the-signature-and-what-it-trusts) describes. When either check fails, it installs nothing.
@@ -136,14 +136,16 @@ When the script installs a new version, it removes the older versions in `~/.loc
`devvm upgrade` installs a release in Go, with the same files and checks as the install script, and it never runs the script. It reads the newest release's version from where GitHub's `releases/latest` redirects, `releases/tag/v<version>`, as the script does, so it needs no API and has no rate limit. Every request goes over HTTPS, and a redirect to anything else is refused.
GitHub's `releases/latest` skips the releases marked as prereleases, which are the versions with a suffix, such as `0.2.0-rc.1`. devvm upgrade, the daily release check and the install script also refuse a prerelease there, so none of them installs or announces one as the newest release, and a prerelease is installed only when `--to` or the script's `--version` names it. A record of the daily check that names a prerelease counts as no record, and the next check replaces it. Versions compare as semver orders them: the numbers as numbers, a prerelease before its release, and a prerelease's suffix part by part, a number below a word and numbers as numbers, so `0.2.0-rc.9` comes before `0.2.0-rc.10`.
GitHub's `releases/latest` skips the releases marked as prereleases, which are the versions with a suffix, such as `0.2.0-rc.1`. devvm upgrade, the daily release check and the install script also refuse a prerelease there, so none of them installs or announces one as the newest release, and a prerelease is installed only when `--to` or the script's `--version` names it. A record of the daily check that names a prerelease as the newest release counts as no record, and the next check replaces it. Versions compare as semver orders them: the numbers as numbers, a prerelease before its release, and a prerelease's suffix part by part, a number below a word and numbers as numbers, so `0.2.0-rc.9` comes before `0.2.0-rc.10`.
Homebrew's `devvm-rc` formula is the one exception, because it follows prereleases. For a devvm that `devvm-rc` installed, devvm upgrade and the daily check read the repository's releases feed, `releases.atom`, which lists the newest releases, prereleases among them, and needs no API either. The newest version in it, a prerelease or a release, is the newest release for that devvm. The daily check records it as `newest` in its record, beside `latest`, the newest release in the feed that isn't a prerelease, which stays as it was when the feed lists only prereleases.
### How it tells how devvm was installed
It follows the links of the running binary's path, and it reads only that path, never running anything:
- It's the install script's when the binary is `devvm` in `<prefix>/lib/devvm/<version>`, with a release's version as the folder's name, and `<prefix>/bin/devvm` is a link that resolves to that same binary. The prefix comes from the binary's own path, so `DEVVM_PREFIX` needs no setting.
- It's Homebrew's when the path has `Cellar/devvm/` in it, a keg of Homebrew's.
- It's Homebrew's when the path has `Cellar/devvm/` in it, a keg of Homebrew's `devvm` formula, or `Cellar/devvm-rc/`, a keg of its `devvm-rc` formula, which follows prereleases.
- Anything else is another way. A devvm whose version isn't a release's, such as a checkout's pseudo-version or `(devel)`, was built from the source. One with a release's version that wasn't set when it was built, as `go install` gives, was installed with `go install`. One that has a release's version is a copy of a release somewhere else.
### The release key and the signature
@@ -167,4 +169,4 @@ A server, or someone in the way of one, can offer an older release that's still
Then devvm upgrade removes the other versions in `<prefix>/lib/devvm`, as the script does: it keeps the new version, the one that ran devvm upgrade, and any version that a running process's command line names, such as a VM's proxy, which it lists with `ps`. When `ps` fails, it keeps them all. An interrupted upgrade leaves a `.<version>.new.<pid>` folder at most. The next upgrade removes it once no process has that pid, so it never takes the folder of an upgrade that's still running, and the script's next install removes it too.
With Homebrew, devvm upgrade runs `brew upgrade devvm` into the run log, after asking, and checks nothing of its own, because Homebrew checks the source against the formula's checksum.
With Homebrew, devvm upgrade runs `brew upgrade devvm`, or `brew upgrade devvm-rc` for a `devvm-rc` keg, into the run log, after asking, and checks nothing of its own, because Homebrew checks the source against the formula's checksum.
+1 -1
View File
@@ -84,7 +84,7 @@ A mirror can't give base a package that Ubuntu didn't publish. apt checks every
When you run devvm in a terminal, it checks at most once a day for a newer devvm release, and when one is out it says so in one line before it opens the VM, naming the release, the version you have and devvm upgrade. devvm never installs anything on its own, so you upgrade with [devvm upgrade](upgrading.md#upgrading) when you choose to. `release-check = false` turns the check off, and so does setting `DEVVM_NO_RELEASE_CHECK=1` in the environment, as CI can. `release-check` must be `true` or `false`, and devvm refuses anything else (`config.toml` names the line). No command saves it, so it's only ever in `config.toml`.
The check reads only where GitHub's latest devvm release is, over HTTPS, and sends nothing about you or your machine. The latest release is never a prerelease, so the check never announces one ([trying a prerelease](upgrading.md#trying-a-prerelease)). It runs beside the launch, so it never makes devvm wait, and when you're offline it says nothing and tries again the next day. The line comes from what the last check found, so a release that came out since then shows up at the launch after the next check. devvm keeps what the check found in `~/.local/share/devvm/cache/release.json`, and `devvm doctor` shows it. devvm says nothing without a terminal, with `--no-input`, for a devvm built from its source, or for a copy that neither the install script nor Homebrew installed, which devvm upgrade can't upgrade.
The check reads only where GitHub's latest devvm release is, over HTTPS, and sends nothing about you or your machine. The latest release is never a prerelease, so the check never announces one ([trying a prerelease](upgrading.md#trying-a-prerelease)). The exception is a devvm that Homebrew's `devvm-rc` formula installed, which follows prereleases: its check reads GitHub's list of devvm's newest releases instead, and it announces a newer prerelease or release, whichever is newest. It runs beside the launch, so it never makes devvm wait, and when you're offline it says nothing and tries again the next day. The line comes from what the last check found, so a release that came out since then shows up at the launch after the next check. devvm keeps what the check found in `~/.local/share/devvm/cache/release.json`, and `devvm doctor` shows it. devvm says nothing without a terminal, with `--no-input`, for a devvm built from its source, or for a copy that neither the install script nor Homebrew installed, which devvm upgrade can't upgrade.
### Where a default comes from
+36 -8
View File
@@ -30,7 +30,7 @@ You can also upgrade devvm without devvm upgrade, with the command for the way y
brew upgrade devvm
```
If you installed devvm with the install script instead, run the script again, as on Linux.
If you installed `devvm-rc`, Homebrew's formula for prereleases, run `brew upgrade devvm-rc` instead ([trying a prerelease](#trying-a-prerelease)). If you installed devvm with the install script, run the script again, as on Linux.
{{< /os-tab >}}
{{< os-tab name="Linux" >}}
@@ -53,7 +53,7 @@ Images whose inputs changed are built again the next time you use them. Existing
devvm upgrade tells how devvm was installed from where the devvm you ran is, and it never runs anything to find out:
- **With the install script**, devvm is `~/.local/lib/devvm/<version>/devvm`, and `~/.local/bin/devvm` links to it, or the same folders under `DEVVM_PREFIX`. devvm upgrade downloads the new release and checks it, as [What devvm upgrade checks](#what-devvm-upgrade-checks) describes. It unpacks the release into a folder of its own beside the devvm you have, runs the new devvm to see that it works, and then switches `~/.local/bin/devvm` to it. When anything fails before the new devvm runs through `~/.local/bin/devvm`, the link goes back, so the devvm you had stays the one that runs. The version you upgraded from stays in `~/.local/lib/devvm`, and so does any older version that a running VM still uses, until a later upgrade finds nothing using it.
- **With Homebrew**, devvm is in Homebrew's Cellar, and devvm upgrade runs `brew upgrade devvm` after asking. Homebrew may upgrade Lima at the same time, because the formula needs it. Homebrew installs the release its formula names, which can come out a little after the release itself, so until then `brew upgrade devvm` finds nothing to upgrade.
- **With Homebrew**, devvm is in Homebrew's Cellar, and devvm upgrade runs `brew upgrade devvm` after asking, or `brew upgrade devvm-rc` when you installed the formula for prereleases. Homebrew may upgrade Lima at the same time, because the formula needs it. Homebrew installs the release its formula names, which can come out a little after the release itself, so until then `brew upgrade devvm` finds nothing to upgrade.
- **Any other way**, such as `go install`, a build from devvm's source, or a copy of devvm somewhere else, devvm upgrade can't upgrade. It says how that devvm was installed and how to upgrade it, such as with `go install github.com/devvmhq/devvm/cmd/devvm@latest`, and fails.
A devvm built without devvm's release key can't check a release's signature, so devvm upgrade refuses to install a release with it and says to run the install script again.
@@ -77,10 +77,38 @@ Homebrew installs only its formula's release, so with Homebrew devvm upgrade doe
### Trying a prerelease
A prerelease is a version of devvm that you can try before its release is out, such as a release candidate, `0.2.0-rc.1`, or a beta, `0.2.0-beta.1`. devvm upgrade and the install script never pick a prerelease as the newest release, and the daily release check never announces one, so you get a prerelease only when you name it.
A prerelease is a version of devvm that you can try before its release is out, such as a release candidate, `0.2.0-rc.1`, or a beta, `0.2.0-beta.1`. devvm upgrade and the install script never pick a prerelease as the newest release, and the daily release check never announces one, so you get a prerelease only when you name it or when you install `devvm-rc`, Homebrew's formula for prereleases.
The docs at [devvm.dev](https://devvm.dev/) are for the newest release. The docs for the next release, which a prerelease comes before, are at [next.devvm.dev](https://next.devvm.dev/), and they change as that release is written, so they can describe more than a prerelease has.
Versions go in this order: a prerelease comes before its release, a beta before a release candidate, and the numbers in order, so `0.2.0-beta.3` comes before `0.2.0-rc.1`, then `0.2.0-rc.2`, then `0.2.0`.
#### With Homebrew
Homebrew's `devvm` formula always names the newest release, and the `devvm-rc` formula names the newest prerelease, or the newest release when that's newer. Both install the same `devvm` command, so Homebrew installs only one of them at a time. To switch from `devvm` to `devvm-rc`, uninstall `devvm` first, then trust and install `devvm-rc`:
```sh
brew uninstall devvm
brew trust --formula devvmhq/tap/devvm-rc
brew install devvmhq/tap/devvm-rc
```
To install `devvm-rc` when Homebrew hasn't installed devvm before, run only the last two lines. Your images, VMs and settings stay, because they don't live with devvm.
`brew upgrade devvm-rc` moves to the next prerelease once it's out, and to the release once that's out, so `devvm-rc` never leaves you on an old prerelease. devvm upgrade runs it for you, after asking, and the daily release check announces each newer prerelease and release. Homebrew installs only its formula's version, so devvm upgrade doesn't take `--to` here either.
To go back to releases only, uninstall `devvm-rc` and install `devvm` again, after trusting it if you never installed it before:
```sh
brew uninstall devvm-rc
brew trust --formula devvmhq/tap/devvm
brew install devvmhq/tap/devvm
```
`devvm` installs the newest release, even when that's older than the prerelease you had.
#### With the install script
To install a prerelease with the install script, run the copy of the script that comes with the prerelease, which installs that prerelease, or give its version to the newest release's script with `--version`:
```sh
@@ -88,9 +116,9 @@ curl -fsSL https://github.com/devvmhq/devvm/releases/download/v0.2.0-rc.1/instal
curl -fsSL https://github.com/devvmhq/devvm/releases/latest/download/install.sh | bash -s -- --version 0.2.0-rc.1
```
When the install script installed the devvm you have, `devvm upgrade --to 0.2.0-rc.1` installs the prerelease too. Both check a prerelease's signature and checksum as they check a release's. Homebrew's formula always names the newest release, so to try a prerelease on a Homebrew install, switch to the install script first, as [one devvm](#one-devvm) describes.
When the install script installed the devvm you have, `devvm upgrade --to 0.2.0-rc.1` installs the prerelease too. Both check a prerelease's signature and checksum as they check a release's.
Versions go in this order: a prerelease comes before its release, a beta before a release candidate, and the numbers in order, so `0.2.0-beta.3` comes before `0.2.0-rc.1`, then `0.2.0-rc.2`, then `0.2.0`. While you run a prerelease, devvm upgrade offers the release it comes before once that release is out, and the daily check says so. It never offers a newer prerelease, such as `0.2.0-rc.2`, so install one with `devvm upgrade --to 0.2.0-rc.2`.
While you run a prerelease that the install script installed, devvm upgrade offers the release it comes before once that release is out, and the daily check says so. It never offers a newer prerelease, such as `0.2.0-rc.2`, so install one with `devvm upgrade --to 0.2.0-rc.2`.
To go back to the newest release before the prerelease's own release is out, name the newest release's version, such as `devvm upgrade --to 0.1.0`. devvm upgrade asks first, because that release is older than the prerelease you have.
@@ -99,7 +127,7 @@ To go back to the newest release before the prerelease's own release is out, nam
`devvm upgrade --json` prints what `devvm upgrade --check` says as one JSON object, for scripts, as [output for scripts](command-line.md#output-for-scripts) describes, and installs nothing:
- `current` is the version of the devvm you ran.
- `latest` is the newest release's version, which is never a prerelease's.
- `latest` is the newest release's version, which is never a prerelease's, except with Homebrew's `devvm-rc`, where it's the newest prerelease's or release's, whichever is newer.
- `newer` says whether that's newer than `current`.
- `install` is how devvm was installed, `install.sh`, `homebrew` or `other`.
- `path` is where the devvm you ran is, its links followed.
@@ -117,7 +145,7 @@ To go back to the newest release before the prerelease's own release is out, nam
## One devvm
Install devvm one way, with Homebrew or with the install script, but not both. With two copies, the one that comes first on your `PATH` is the one that runs, and `brew upgrade devvm` may update the one you don't run. So when Homebrew installed devvm, the install script stops before it downloads anything and says to run `brew upgrade devvm` instead, or `brew uninstall devvm` first if you want to use the script. It stops whether or not it runs in a terminal, and its `--force` installs a second copy anyway.
Install devvm one way, with Homebrew or with the install script, but not both. With two copies, the one that comes first on your `PATH` is the one that runs, and `brew upgrade devvm` may update the one you don't run. So when Homebrew installed devvm, the install script stops before it downloads anything and says to run `brew upgrade devvm` instead, or `brew uninstall devvm` first if you want to use the script, and it names `devvm-rc` in both commands when that's the formula you installed. It stops whether or not it runs in a terminal, and its `--force` installs a second copy anyway.
To switch from one way to the other, remove devvm with the command for the way you installed it, as step 5 of [Uninstalling](#uninstalling) shows, and then install it the other way. Your images, VMs and settings stay, because they don't live with devvm.
@@ -138,7 +166,7 @@ After it installs devvm, the script warns when another devvm comes before `~/.lo
brew uninstall devvm
```
If you installed devvm with the install script instead, remove it as on Linux.
If you installed `devvm-rc`, run `brew uninstall devvm-rc` instead. If you installed devvm with the install script, remove it as on Linux.
{{< /os-tab >}}
{{< os-tab name="Linux" >}}
+8 -6
View File
@@ -90,10 +90,10 @@ brew_prefixes=(/opt/homebrew /usr/local /home/linuxbrew/.linuxbrew)
# check_brew: stops when Homebrew installed devvm, as a second copy would leave the one first on PATH
# running and brew upgrade updating the other. --force installs anyway. It never runs brew, which can
# download its own Ruby: it looks for a devvm keg (Cellar/devvm/<version>) in the Cellar next to the
# brew on PATH, in HOMEBREW_CELLAR and HOMEBREW_PREFIX's, and in brew_prefixes'.
# download its own Ruby: it looks for a keg of the formula devvm or devvm-rc (Cellar/<formula>/<version>)
# in the Cellar next to the brew on PATH, in HOMEBREW_CELLAR and HOMEBREW_PREFIX's, and in brew_prefixes'.
check_brew() {
local b cellars=() c k
local b cellars=() c f k
! $force || return 0
b=$(command -v brew) || return 0
[[ -z ${HOMEBREW_CELLAR:-} ]] || cellars+=("$HOMEBREW_CELLAR")
@@ -101,9 +101,11 @@ check_brew() {
cellars+=("$(dirname -- "$b")/../Cellar")
for c in ${brew_prefixes[@]+"${brew_prefixes[@]}"}; do cellars+=("$c/Cellar"); done
for c in "${cellars[@]}"; do
for k in "$c"/devvm/*; do
[[ -d $k ]] || continue
die "Homebrew installed devvm: run brew upgrade devvm to upgrade it, or brew uninstall devvm first to use this script (--force installs a second copy)"
for f in devvm devvm-rc; do
for k in "$c/$f"/*; do
[[ -d $k ]] || continue
die "Homebrew installed devvm: run brew upgrade $f to upgrade it, or brew uninstall $f first to use this script (--force installs a second copy)"
done
done
done
}
+6 -5
View File
@@ -5,7 +5,6 @@ import (
"os"
"time"
"github.com/devvmhq/devvm/internal/msg"
"github.com/devvmhq/devvm/internal/settings"
"github.com/devvmhq/devvm/internal/upgrade"
)
@@ -15,7 +14,8 @@ import (
const releaseWait = time.Second
// releaseNotice says, at a launch in a terminal, that a newer release is
// out, from the daily check's record, and starts the check beside the
// out, from the daily check's record (for Homebrew's devvm-rc, a newer
// prerelease or release), and starts the check beside the
// launch when it's due. It never asks and never blocks the launch: the
// check runs in the background, and the function it returns, which the
// launch calls once it's done, waits at most releaseWait for it. Nothing
@@ -40,9 +40,10 @@ func releaseNotice(ctx context.Context, a *app) (wait func()) {
return none
}
path := d.ReleaseCheck()
pre := up.Install.Prereleases()
known := upgrade.ReadKnown(path)
if known.Newer(up.Current) {
a.u.Info(msg.UpgradeAvailable(up.Current, known.Latest))
if next := known.Next(up.Current, pre); next != "" {
a.u.Info(upgrade.Announcement(up.Current, next))
}
now := time.Now()
if !known.Due(now) {
@@ -51,7 +52,7 @@ func releaseNotice(ctx context.Context, a *app) (wait func()) {
done := make(chan struct{})
go func() {
defer close(done)
_ = up.Source.Refresh(ctx, path, now) // offline is silent: the next day tries again
_ = up.Source.Refresh(ctx, path, now, pre) // offline is silent: the next day tries again
}()
return func() {
select {
+4 -3
View File
@@ -28,7 +28,8 @@ func newUpgradeCmd(a *app) *cobra.Command {
Use: "upgrade",
Short: "Install devvm's newest release",
Long: "Install devvm's newest release the way this devvm was installed, after asking. " +
"The install script's devvm gets the release once its signature and checksum check out, and Homebrew's runs brew upgrade devvm. " +
"The install script's devvm gets the release once its signature and checksum check out, and Homebrew's runs brew upgrade devvm, " +
"or brew upgrade devvm-rc for the formula that follows prereleases. " +
"--check only says whether a newer release is out.",
Example: examples(
"devvm upgrade", "install the newest release, asking first",
@@ -109,7 +110,7 @@ type upgradeJSON struct {
func showUpgrade(ctx context.Context, a *app, up upgrade.Upgrader, asJSON bool) error {
u := a.u
done := u.Status(msg.UpgradeChecking())
av, err := up.Source.Check(ctx, up.Current)
av, err := up.Source.Check(ctx, up.Current, up.Install.Prereleases())
done()
if err != nil {
return err
@@ -125,7 +126,7 @@ func showUpgrade(ctx context.Context, a *app, up upgrade.Upgrader, asJSON bool)
u.Info(msg.UpgradeLatestIs(av.Latest))
u.Info(up.NotInstalled())
case av.Newer:
u.Info(msg.UpgradeAvailable(av.Current, av.Latest))
u.Info(upgrade.Announcement(av.Current, av.Latest))
case av.Latest == av.Current:
u.Info(msg.UpgradeAlreadyLatest(av.Current))
case upgrade.Prerelease(av.Current):
+18 -12
View File
@@ -3684,6 +3684,11 @@ func UpgradeAvailable(current string, latest string) M {
return M{id: "upgrade_available", vals: []val{{"current", current}, {"latest", latest}}}
}
// UpgradeAvailablePrerelease is [upgrade_available_prerelease]: "devvm {{.latest}}, a prerelease, is out, and this is devvm {{.current}}. Run devvm upgrade to install it."
func UpgradeAvailablePrerelease(current string, latest string) M {
return M{id: "upgrade_available_prerelease", vals: []val{{"current", current}, {"latest", latest}}}
}
// UpgradeBadArchive is [upgrade_bad_archive]: "The archive of devvm {{.version}} holds something other than devvm's files, so nothing was installed."
func UpgradeBadArchive(version string) M {
return M{id: "upgrade_bad_archive", vals: []val{{"version", version}}}
@@ -3704,14 +3709,14 @@ func UpgradeBrewDone() M {
return M{id: "upgrade_brew_done"}
}
// UpgradeBrewFailed is [upgrade_brew_failed]: "Homebrew's brew upgrade devvm failed, so its devvm stays as it was."
func UpgradeBrewFailed() M {
return M{id: "upgrade_brew_failed"}
// UpgradeBrewFailed is [upgrade_brew_failed]: "Homebrew's brew upgrade {{.formula}} failed, so its devvm stays as it was."
func UpgradeBrewFailed(formula string) M {
return M{id: "upgrade_brew_failed", vals: []val{{"formula", formula}}}
}
// UpgradeBrewStep is [upgrade_brew_step]: "running brew upgrade devvm"
func UpgradeBrewStep() M {
return M{id: "upgrade_brew_step"}
// UpgradeBrewStep is [upgrade_brew_step]: "running brew upgrade {{.formula}}"
func UpgradeBrewStep(formula string) M {
return M{id: "upgrade_brew_step", vals: []val{{"formula", formula}}}
}
// UpgradeBrewVersion is [upgrade_brew_version]: "Homebrew installed this devvm and installs only its newest version, so devvm upgrade can't take --to. Run devvm upgrade without it."
@@ -3734,9 +3739,9 @@ func UpgradeConfirm(current string, version string) M {
return M{id: "upgrade_confirm", vals: []val{{"current", current}, {"version", version}}}
}
// UpgradeConfirmBrew is [upgrade_confirm_brew]: "Run brew upgrade devvm to install devvm {{.version}} in place of devvm {{.current}}?"
func UpgradeConfirmBrew(current string, version string) M {
return M{id: "upgrade_confirm_brew", vals: []val{{"current", current}, {"version", version}}}
// UpgradeConfirmBrew is [upgrade_confirm_brew]: "Run brew upgrade {{.formula}} to install devvm {{.version}} in place of devvm {{.current}}?"
func UpgradeConfirmBrew(current string, formula string, version string) M {
return M{id: "upgrade_confirm_brew", vals: []val{{"current", current}, {"formula", formula}, {"version", version}}}
}
// UpgradeConfirmOlder is [upgrade_confirm_older]: "This is devvm {{.current}}, and devvm {{.version}} is older. Install it anyway?"
@@ -4722,17 +4727,18 @@ var specs = map[string]spec{
"upgrade_already": {fields: []string{"version"}},
"upgrade_already_latest": {fields: []string{"version"}},
"upgrade_available": {fields: []string{"current", "latest"}},
"upgrade_available_prerelease": {fields: []string{"current", "latest"}},
"upgrade_bad_archive": {fields: []string{"version"}},
"upgrade_bad_checksum": {fields: []string{"archive", "version"}},
"upgrade_bad_signature": {fields: []string{"version"}},
"upgrade_brew_done": {},
"upgrade_brew_failed": {},
"upgrade_brew_step": {},
"upgrade_brew_failed": {fields: []string{"formula"}},
"upgrade_brew_step": {fields: []string{"formula"}},
"upgrade_brew_version": {},
"upgrade_checking": {},
"upgrade_checkout_build": {fields: []string{"version"}},
"upgrade_confirm": {fields: []string{"current", "version"}},
"upgrade_confirm_brew": {fields: []string{"current", "version"}},
"upgrade_confirm_brew": {fields: []string{"current", "formula", "version"}},
"upgrade_confirm_older": {fields: []string{"current", "version"}},
"upgrade_done": {fields: []string{"link", "version"}},
"upgrade_download_failed": {fields: []string{"file", "version"}},
+22 -4
View File
@@ -13,12 +13,20 @@ const (
// Script is install.sh's: <prefix>/lib/devvm/<version>/devvm, which
// <prefix>/bin/devvm links to.
Script Kind = "install.sh"
// Homebrew is Homebrew's: a keg in a Cellar, Cellar/devvm/<version>.
// Homebrew is Homebrew's: a keg in a Cellar, Cellar/<formula>/<version>,
// of the formula devvm or devvm-rc.
Homebrew Kind = "homebrew"
// Other is any other: go install, a build from a checkout, a copy.
Other Kind = "other"
)
// The tap's formulas: devvm, the newest release's, and devvm-rc, the
// newest prerelease's or release's, whichever is newer.
const (
Formula = "devvm"
RCFormula = "devvm-rc"
)
// An Install is where this devvm is and how it was installed.
type Install struct {
Kind Kind
@@ -27,8 +35,15 @@ type Install struct {
// Prefix is install.sh's prefix (DEVVM_PREFIX, ~/.local by default),
// for Script.
Prefix string
// Formula is Homebrew's formula, Formula or RCFormula, for Homebrew.
Formula string
}
// Prereleases reports whether this install follows prereleases, as
// Homebrew's devvm-rc does: its newest version is the newest release,
// prereleases included (Source.Newest).
func (in Install) Prereleases() bool { return in.Kind == Homebrew && in.Formula == RCFormula }
// Lib is the folder install.sh keeps each version in, a folder each.
func (in Install) Lib() string { return filepath.Join(in.Prefix, "lib", "devvm") }
@@ -38,7 +53,8 @@ func (in Install) Link() string { return filepath.Join(in.Prefix, "bin", "devvm"
// Detect says how the devvm at exe (os.Executable's) was installed, from
// where it is, never running anything: install.sh's when it's devvm in a
// version's folder of <prefix>/lib/devvm and <prefix>/bin/devvm links to
// it, Homebrew's when it's in a Cellar's devvm keg, else Other.
// it, Homebrew's when it's in a Cellar's devvm or devvm-rc keg, else
// Other.
func Detect(exe string) Install {
bin, err := filepath.EvalSymlinks(exe)
if err != nil {
@@ -57,8 +73,10 @@ func Detect(exe string) Install {
}
}
}
if strings.Contains(filepath.ToSlash(bin), "/Cellar/devvm/") {
in.Kind = Homebrew
for _, f := range []string{Formula, RCFormula} {
if strings.Contains(filepath.ToSlash(bin), "/Cellar/"+f+"/") {
in.Kind, in.Formula = Homebrew, f
}
}
return in
}
+37 -13
View File
@@ -1,6 +1,7 @@
package upgrade
import (
"cmp"
"context"
"encoding/json"
"os"
@@ -18,20 +19,23 @@ const noticeTimeout = 5 * time.Second
// Known is the daily check's record: the newest release it found and
// when, and when it last tried, found or not, so an offline machine tries
// once a day too.
// once a day too. Newest is the newest release, prereleases included,
// which only the check of an install that follows them records.
type Known struct {
Latest string `json:"latest,omitempty"`
Newest string `json:"newest,omitempty"`
Checked time.Time `json:"checked,omitzero"`
Tried time.Time `json:"tried,omitzero"`
}
// ReadKnown reads the record at path. A missing or unreadable one is
// none, as is one naming a prerelease, which is never announced: the
// next check writes it again.
// none, as is one naming a prerelease as Latest, which is never
// announced as the newest release: the next check writes it again.
func ReadKnown(path string) Known {
var k Known
data, err := os.ReadFile(path) //nolint:gosec // paths come from paths.Dirs
if err != nil || json.Unmarshal(data, &k) != nil || (k.Latest != "" && (!Valid(k.Latest) || Prerelease(k.Latest))) {
if err != nil || json.Unmarshal(data, &k) != nil || (k.Latest != "" && (!Valid(k.Latest) || Prerelease(k.Latest))) ||
(k.Newest != "" && !Valid(k.Newest)) {
return Known{}
}
return k
@@ -43,22 +47,42 @@ func (k Known) Due(now time.Time) bool {
return k.Tried.IsZero() || now.Sub(k.Tried) >= CheckEvery || k.Tried.After(now)
}
// Newer reports whether k's release is newer than current.
func (k Known) Newer(current string) bool {
return k.Latest != "" && Valid(current) && Compare(k.Latest, current) > 0
// Next is the release k knows of that's newer than current, for an
// install that follows prereleases (Newest) or doesn't (Latest); "" for
// none.
func (k Known) Next(current string, prereleases bool) string {
v := k.Latest
if prereleases {
v = k.Newest
}
if v == "" || !Valid(current) || Compare(v, current) <= 0 {
return ""
}
return v
}
// Refresh checks s for the newest release, within noticeTimeout, and
// records what it found at path, with now as the try's time. A failed
// check, such as offline, keeps what was known and returns its error.
func (s Source) Refresh(ctx context.Context, path string, now time.Time) error {
// records what it found at path, with now as the try's time: for an
// install that follows prereleases, the newest of those too, from the
// releases feed, which also gives the newest release when it lists one.
// A failed check, such as offline, keeps what was known and returns its
// error.
func (s Source) Refresh(ctx context.Context, path string, now time.Time, prereleases bool) error {
ctx, cancel := context.WithTimeout(ctx, noticeTimeout)
defer cancel()
k := ReadKnown(path)
k.Tried = now
av, err := s.Check(ctx, "")
if err == nil {
k.Latest, k.Checked = av.Latest, now
var err error
if prereleases {
var newest, latest string
if newest, latest, err = s.feed(ctx); err == nil {
k.Newest, k.Latest, k.Checked = newest, cmp.Or(latest, k.Latest), now
}
} else {
var latest string
if latest, err = s.Latest(ctx); err == nil {
k.Latest, k.Checked = latest, now
}
}
data, merr := json.Marshal(k)
if merr != nil {
+63 -13
View File
@@ -28,23 +28,70 @@ func TestKnown(t *testing.T) {
}
}
for _, c := range []struct {
latest, current string
newer bool
latest, newest, current string
pre bool
next string
}{
{"0.2.0", "0.1.0", true},
{"0.2.0", "0.2.0", false},
{"0.2.0", "0.3.0", false},
{"", "0.1.0", false},
{"0.2.0", "", false},
{"0.2.0", "0.2.0-rc.1", true},
{"0.1.0", "0.2.0-rc.1", false},
{"0.2.0", "", "0.1.0", false, "0.2.0"},
{"0.2.0", "", "0.2.0", false, ""},
{"0.2.0", "", "0.3.0", false, ""},
{"", "", "0.1.0", false, ""},
{"0.2.0", "", "", false, ""},
{"0.2.0", "", "0.2.0-rc.1", false, "0.2.0"},
{"0.1.0", "", "0.2.0-rc.1", false, ""},
// An install that follows prereleases goes by the newest of all.
{"0.1.0", "0.2.0-rc.2", "0.2.0-rc.1", true, "0.2.0-rc.2"},
{"0.1.0", "0.2.0-rc.2", "0.1.0", true, "0.2.0-rc.2"},
{"0.2.0", "0.2.0", "0.2.0-rc.2", true, "0.2.0"},
{"0.2.0", "0.2.0-rc.2", "0.2.0-rc.2", true, ""},
{"0.2.0", "", "0.1.0", true, ""},
// One that doesn't never hears of a prerelease.
{"0.1.0", "0.2.0-rc.2", "0.1.0", false, ""},
} {
if got := (upgrade.Known{Latest: c.latest}).Newer(c.current); got != c.newer {
t.Errorf("%q over %q: %v", c.latest, c.current, got)
k := upgrade.Known{Latest: c.latest, Newest: c.newest}
if got := k.Next(c.current, c.pre); got != c.next {
t.Errorf("%+v over %q (prereleases %v): %q", k, c.current, c.pre, got)
}
}
}
// For an install that follows prereleases, Refresh reads the releases
// feed: the newest of all, and the newest release, which a feed of
// prereleases alone leaves as it was.
func TestRefreshPrereleases(t *testing.T) {
key := upgradetest.NewKey()
srv := upgradetest.NewServer(t)
srv.Add("0.1.0", upgradetest.NewRelease(key, "0.1.0", nil), true)
srv.Add("0.2.0-rc.1", upgradetest.NewRelease(key, "0.2.0-rc.1", nil), false)
src := upgrade.NewSource(srv.URL, "")
src.Client.Trust(srv.Roots())
path := filepath.Join(t.TempDir(), "cache", "release.json")
now := time.Date(2026, 11, 5, 12, 0, 0, 0, time.UTC)
if err := src.Refresh(t.Context(), path, now, true); err != nil {
t.Fatal(err)
}
if k := upgrade.ReadKnown(path); k.Latest != "0.1.0" || k.Newest != "0.2.0-rc.1" || !k.Checked.Equal(now) {
t.Fatalf("recorded %+v", k)
}
only := upgradetest.NewServer(t)
only.Add("0.3.0-rc.1", upgradetest.NewRelease(key, "0.3.0-rc.1", nil), false)
src = upgrade.NewSource(only.URL, "")
src.Client.Trust(only.Roots())
if err := src.Refresh(t.Context(), path, now, true); err != nil {
t.Fatal(err)
}
if k := upgrade.ReadKnown(path); k.Latest != "0.1.0" || k.Newest != "0.3.0-rc.1" {
t.Fatalf("prereleases alone: %+v", k)
}
if err := os.WriteFile(path, []byte(`{"newest":"v1; rm"}`), 0o600); err != nil {
t.Fatal(err)
}
if k := upgrade.ReadKnown(path); k != (upgrade.Known{}) {
t.Errorf("an invalid newest: %+v", k)
}
}
// Refresh records the newest release and the try; offline it keeps what
// was known, records the try, and returns the error. A record devvm can't
// read is none.
@@ -58,7 +105,7 @@ func TestRefresh(t *testing.T) {
t.Fatalf("no record: %+v", k)
}
first := time.Date(2026, 11, 5, 12, 0, 0, 0, time.UTC)
if err := src.Refresh(t.Context(), path, first); err != nil {
if err := src.Refresh(t.Context(), path, first, false); err != nil {
t.Fatal(err)
}
if k := upgrade.ReadKnown(path); k.Latest != "0.2.0" || !k.Checked.Equal(first) || !k.Tried.Equal(first) {
@@ -66,9 +113,12 @@ func TestRefresh(t *testing.T) {
}
offline := upgrade.NewSource("https://127.0.0.1:1", "")
next := first.Add(upgrade.CheckEvery)
if err := offline.Refresh(t.Context(), path, next); err == nil {
if err := offline.Refresh(t.Context(), path, next, false); err == nil {
t.Fatal("offline: no error")
}
if err := offline.Refresh(t.Context(), path, next, true); err == nil {
t.Fatal("offline, following prereleases: no error")
}
if k := upgrade.ReadKnown(path); k.Latest != "0.2.0" || !k.Checked.Equal(first) || !k.Tried.Equal(next) {
t.Fatalf("offline: %+v", k)
}
+63
View File
@@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"context"
"encoding/xml"
"errors"
"path/filepath"
"runtime"
@@ -22,6 +23,8 @@ const Repo = "https://github.com/devvmhq/devvm"
const (
sumsCap = 64 << 10
signatureCap = 4 << 10
// feedCap is the releases feed's: its few newest releases' notes.
feedCap = 2 << 20
// archiveCap is an archive's: devvm's binary and three text files
// are far less.
archiveCap = 256 << 20
@@ -68,6 +71,66 @@ func (s Source) Latest(ctx context.Context) (string, error) {
return v, nil
}
// Newest returns the newest release's version, prereleases included, as
// Homebrew's devvm-rc follows them, from the repository's releases feed
// (releases.atom), which lists the newest releases, prereleases among
// them, and needs no API either.
func (s Source) Newest(ctx context.Context) (string, error) {
newest, _, err := s.feed(ctx)
return newest, err
}
// Find returns the newest release's version for an install that follows
// prereleases (Newest) or doesn't (Latest).
func (s Source) Find(ctx context.Context, prereleases bool) (string, error) {
if prereleases {
return s.Newest(ctx)
}
return s.Latest(ctx)
}
// atomFeed is what devvm reads of a releases feed: each entry's links,
// one of them the release's page, releases/tag/v<version>.
type atomFeed struct {
Entries []struct {
Links []struct {
Href string `xml:"href,attr"`
} `xml:"link"`
} `xml:"entry"`
}
// feed reads the releases feed: the newest release, prereleases
// included, and the newest that isn't a prerelease, "" when the feed
// lists none.
func (s Source) feed(ctx context.Context) (newest, latest string, err error) {
body, err := fetch.Get(ctx, s.Client, s.URL+"/releases.atom", feedCap)
if err != nil {
return "", "", msg.UpgradeNoLatest(s.URL).Because(err)
}
var f atomFeed
if err := xml.Unmarshal(body, &f); err != nil {
return "", "", msg.UpgradeNoLatest(s.URL).Because(err)
}
for _, e := range f.Entries {
for _, l := range e.Links {
_, v, ok := strings.Cut(l.Href, "/releases/tag/v")
if !ok || !Valid(v) {
continue
}
if newest == "" || Compare(v, newest) > 0 {
newest = v
}
if !Prerelease(v) && (latest == "" || Compare(v, latest) > 0) {
latest = v
}
}
}
if newest == "" {
return "", "", msg.UpgradeNoLatest(s.URL)
}
return newest, latest, nil
}
// Archive is the name of version's archive for the platform this devvm
// runs on, as .goreleaser.yaml names it, without .tar.gz.
func Archive(version string) string {
+26 -13
View File
@@ -2,7 +2,8 @@
// installed: for install.sh's, the release's archive, checked against its
// SHA256SUMS, whose minisign signature is checked against the release
// key built into devvm, unpacked beside the old version, and the link
// switched to it once it runs; for Homebrew's, brew upgrade devvm; for
// switched to it once it runs; for Homebrew's, brew upgrade devvm, or
// brew upgrade devvm-rc for the formula that follows prereleases; for
// any other, nothing but saying how it was installed.
package upgrade
@@ -31,17 +32,26 @@ type Available struct {
Newer bool
}
// Check returns the newest release at s and whether it's newer than
// current, this devvm's version. It installs nothing, for devvm upgrade
// --check and a notice that a release is out.
func (s Source) Check(ctx context.Context, current string) (Available, error) {
latest, err := s.Latest(ctx)
// Check returns the newest release at s, prereleases included for an
// install that follows them (Find), and whether it's newer than current,
// this devvm's version. It installs nothing, for devvm upgrade --check.
func (s Source) Check(ctx context.Context, current string, prereleases bool) (Available, error) {
latest, err := s.Find(ctx, prereleases)
if err != nil {
return Available{}, err
}
return Available{Current: current, Latest: latest, Newer: Valid(current) && Compare(latest, current) > 0}, nil
}
// Announcement says that version is out and this devvm, current, can
// upgrade to it, naming it a prerelease when it's one.
func Announcement(current, version string) msg.M {
if Prerelease(version) {
return msg.UpgradeAvailablePrerelease(current, version)
}
return msg.UpgradeAvailable(current, version)
}
// An Upgrader installs a release over this devvm, reporting through its
// Reporter, which asks before anything is installed.
type Upgrader struct {
@@ -65,7 +75,8 @@ type Options struct {
// Upgrade installs the newest release, or o.Version, over this devvm, as
// it was installed, once it's asked. The newest release is never a
// prerelease (Latest), so only o.Version installs one. It refuses a
// prerelease (Latest), so only o.Version installs one, but for
// Homebrew's devvm-rc, which follows prereleases (Newest). It refuses a
// newest release older than this devvm, as a server sending an old
// release would, unless o.Version names it; for a prerelease of a
// release not yet out, that's no failure, only said.
@@ -79,7 +90,7 @@ func (u Upgrader) Upgrade(ctx context.Context, o Options) error {
target := o.Version
if target == "" {
done := u.Status(msg.UpgradeChecking())
latest, err := u.Source.Latest(ctx)
latest, err := u.Source.Find(ctx, u.Install.Prereleases())
done()
if err != nil {
return err
@@ -119,7 +130,7 @@ func (u Upgrader) confirm(o Options, target string, older bool) (bool, error) {
q := msg.UpgradeConfirm(u.Current, target)
switch {
case u.Install.Kind == Homebrew:
q = msg.UpgradeConfirmBrew(u.Current, target)
q = msg.UpgradeConfirmBrew(u.Current, u.Install.Formula, target)
case older:
q = msg.UpgradeConfirmOlder(u.Current, target)
}
@@ -145,11 +156,13 @@ func (u Upgrader) NotInstalled() msg.M {
return msg.UpgradeOtherInstall(u.Install.Exe)
}
// brew runs brew upgrade devvm, which upgrades Homebrew's devvm.
// brew runs brew upgrade with the install's formula, devvm or devvm-rc,
// which upgrades Homebrew's devvm.
func (u Upgrader) brew(ctx context.Context) error {
cmd := exec.CommandContext(ctx, "brew", "upgrade", "devvm")
if err := u.LoggedCmd(ctx, msg.UpgradeBrewStep(), cmd); err != nil {
return backend.Logged(msg.UpgradeBrewFailed())
f := u.Install.Formula
cmd := exec.CommandContext(ctx, "brew", "upgrade", f) //nolint:gosec // f is Formula or RCFormula, which only Detect sets
if err := u.LoggedCmd(ctx, msg.UpgradeBrewStep(f), cmd); err != nil {
return backend.Logged(msg.UpgradeBrewFailed(f))
}
u.Info(msg.UpgradeBrewDone())
return nil
+95 -2
View File
@@ -127,9 +127,19 @@ func TestDetect(t *testing.T) {
}
keg := filepath.Join(f.prefix, "Cellar", "devvm", "0.1.0", "bin")
writeExe(t, keg, nil)
if in := upgrade.Detect(filepath.Join(keg, "devvm")); in.Kind != upgrade.Homebrew {
if in := upgrade.Detect(filepath.Join(keg, "devvm")); in.Kind != upgrade.Homebrew || in.Formula != upgrade.Formula || in.Prereleases() {
t.Errorf("a keg's: %+v", in)
}
rcKeg := filepath.Join(f.prefix, "Cellar", "devvm-rc", "0.2.0-rc.1", "bin")
writeExe(t, rcKeg, nil)
if in := upgrade.Detect(filepath.Join(rcKeg, "devvm")); in.Kind != upgrade.Homebrew || in.Formula != upgrade.RCFormula || !in.Prereleases() {
t.Errorf("devvm-rc's keg's: %+v", in)
}
other := filepath.Join(f.prefix, "Cellar", "devvm-nightly", "0.1.0", "bin")
writeExe(t, other, nil)
if in := upgrade.Detect(filepath.Join(other, "devvm")); in.Kind != upgrade.Other || in.Prereleases() {
t.Errorf("another formula's keg's: %+v", in)
}
writeExe(t, filepath.Join(f.prefix, "go", "bin"), nil)
if in := upgrade.Detect(filepath.Join(f.prefix, "go", "bin", "devvm")); in.Kind != upgrade.Other {
t.Errorf("go install's: %+v", in)
@@ -439,6 +449,89 @@ func TestUpgradeHomebrew(t *testing.T) {
}
}
// Homebrew's devvm-rc follows prereleases: its newest release is the
// releases feed's newest, a prerelease or a release, which brew upgrade
// devvm-rc installs, asked first, and never --to.
func TestUpgradeHomebrewRC(t *testing.T) {
dir := t.TempDir()
keg := filepath.Join(dir, "Cellar", "devvm-rc", "0.2.0-rc.1", "bin")
writeExe(t, keg, upgradetest.Script("0.2.0-rc.1"))
calls := filepath.Join(dir, "brew-calls")
brews := filepath.Join(dir, "brews")
writeExe(t, brews, []byte("#!/bin/sh\necho \"$@\" >> "+calls+"\n"))
if err := os.Rename(filepath.Join(brews, "devvm"), filepath.Join(brews, "brew")); err != nil {
t.Fatal(err)
}
t.Setenv("PATH", brews+string(os.PathListSeparator)+os.Getenv("PATH"))
f := newFixture(t, "0.2.0-rc.1")
f.release("0.1.0", true)
f.release("0.2.0-rc.2", false)
up := f.upgrader()
up.Install = upgrade.Detect(filepath.Join(keg, "devvm"))
up.Current = "0.2.0-rc.1"
err := up.Upgrade(t.Context(), upgrade.Options{})
r, ok := errors.AsType[*msg.Refusal](err)
if !ok || r.Question.ID() != "upgrade_confirm_brew" {
t.Fatalf("without a terminal: %v", err)
}
if got := msg.NamesOf(r.Question); got != "upgrade_confirm_brew current=0.2.0-rc.1 formula=devvm-rc version=0.2.0-rc.2" {
t.Errorf("asked %s", got)
}
if got := msg.IDOf(up.Upgrade(t.Context(), upgrade.Options{Version: "0.2.0-rc.2", Force: true})); got != "upgrade_brew_version" {
t.Errorf("--to: %s", got)
}
if err := up.Upgrade(t.Context(), upgrade.Options{Force: true}); err != nil {
t.Fatal(err)
}
if b, _ := os.ReadFile(calls); string(b) != "upgrade devvm-rc\n" { //nolint:gosec // the test's own file
t.Errorf("brew ran %q", b)
}
av, err := up.Source.Check(t.Context(), up.Current, up.Install.Prereleases())
if err != nil || av.Latest != "0.2.0-rc.2" || !av.Newer {
t.Errorf("Check: %+v, %v", av, err)
}
if got := msg.NamesOf(upgrade.Announcement(av.Current, av.Latest)); got != "upgrade_available_prerelease current=0.2.0-rc.1 latest=0.2.0-rc.2" {
t.Errorf("announced %s", got)
}
if got := msg.IDOf(upgrade.Announcement("0.2.0-rc.2", "0.2.0")); got != "upgrade_available" {
t.Errorf("a release announced as %s", got)
}
// The release itself, once it's out, is the newest.
f.release("0.2.0", true)
if v, err := up.Source.Newest(t.Context()); err != nil || v != "0.2.0" {
t.Errorf("Newest = %q, %v", v, err)
}
}
// The releases feed: a feed devvm can't read, or one without a release,
// has no newest release.
func TestNewestFeed(t *testing.T) {
empty := upgradetest.NewServer(t)
src := upgrade.NewSource(empty.URL, "")
src.Client.Trust(empty.Roots())
if _, err := src.Newest(t.Context()); msg.IDOf(err) != "upgrade_no_latest" {
t.Errorf("no releases: %v", err)
}
garbled := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte("<feed><entry>"))
}))
t.Cleanup(garbled.Close)
src = upgrade.NewSource(garbled.URL, "")
pool := x509.NewCertPool()
pool.AddCert(garbled.Certificate())
src.Client.Trust(pool)
if _, err := src.Find(t.Context(), true); msg.IDOf(err) != "upgrade_no_latest" {
t.Errorf("a garbled feed: %v", err)
}
src = upgrade.NewSource("https://127.0.0.1:1", "")
if _, err := src.Newest(t.Context()); msg.IDOf(err) != "upgrade_no_latest" {
t.Errorf("offline: %v", err)
}
}
// Any other devvm is refused, saying how it was installed.
func TestUpgradeOther(t *testing.T) {
f := newFixture(t, "0.1.0")
@@ -472,7 +565,7 @@ func TestCheck(t *testing.T) {
f.release("0.2.0", true)
src := f.upgrader().Source
for current, newer := range map[string]bool{"0.1.0": true, "0.2.0": false, "0.3.0": false, "(devel)": false, "0.2.0-rc.1": true} {
av, err := src.Check(t.Context(), current)
av, err := src.Check(t.Context(), current, false)
if err != nil || av.Latest != "0.2.0" || av.Newer != newer || av.Current != current {
t.Errorf("Check(%s) = %+v, %v", current, av, err)
}
@@ -14,8 +14,10 @@ import (
"encoding/base64"
"encoding/hex"
"encoding/pem"
"maps"
"net/http"
"net/http/httptest"
"slices"
"strings"
"sync"
"testing"
@@ -174,6 +176,8 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request) {
switch {
case p == "/releases/latest" && s.latest != "":
http.Redirect(w, r, "/releases/tag/v"+s.latest, http.StatusFound)
case p == "/releases.atom":
s.feed(w)
case strings.HasPrefix(p, "/releases/tag/v") && s.releases[strings.TrimPrefix(p, "/releases/tag/v")] != nil:
w.WriteHeader(http.StatusOK)
case strings.HasPrefix(p, "/releases/download/v"):
@@ -189,6 +193,25 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request) {
}
}
// feed writes the releases feed, as GitHub's releases.atom lists them:
// the feed's own link, then an entry for each release, prereleases too,
// its link the release's page.
func (s *Server) feed(w http.ResponseWriter) {
vs := slices.Sorted(maps.Keys(s.releases))
var b strings.Builder
b.WriteString(`<?xml version="1.0" encoding="UTF-8"?>` + "\n" +
`<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US">` + "\n" +
` <link type="text/html" rel="alternate" href="` + s.URL + `/releases"/>` + "\n")
for _, v := range vs {
b.WriteString(` <entry><id>tag:github.com,2008:Repository/1/v` + v + `</id>` +
`<link rel="alternate" type="text/html" href="` + s.URL + `/releases/tag/v` + v + `"/>` +
`<title>devvm ` + v + `</title></entry>` + "\n")
}
b.WriteString("</feed>\n")
w.Header().Set("Content-Type", "application/atom+xml")
_, _ = w.Write([]byte(b.String()))
}
func must(err error) {
if err != nil {
panic(err)
+10 -4
View File
@@ -2652,8 +2652,8 @@ description = "a status step: devvm upgrade downloads and checks a release"
other = "downloading devvm {{.version}}"
[upgrade_brew_step]
description = "a status step: devvm upgrade runs Homebrew"
other = "running brew upgrade devvm"
description = "a status step: devvm upgrade runs Homebrew; formula is Homebrew's formula, devvm or devvm-rc"
other = "running brew upgrade {{.formula}}"
[upgrade_no_latest]
description = "url is the repository whose releases devvm upgrade reads, such as https://github.com/devvmhq/devvm"
@@ -2665,6 +2665,10 @@ other = "The newest release is devvm {{.latest}}."
[upgrade_available]
other = "devvm {{.latest}} is out, and this is devvm {{.current}}. Run devvm upgrade to install it."
[upgrade_available_prerelease]
description = "latest is a prerelease's version, such as 0.2.0-rc.1, which Homebrew's devvm-rc installs"
other = "devvm {{.latest}}, a prerelease, is out, and this is devvm {{.current}}. Run devvm upgrade to install it."
[upgrade_already_latest]
other = "This is devvm {{.version}}, the newest release."
@@ -2686,7 +2690,8 @@ other = "Install devvm {{.version}} in place of devvm {{.current}}?"
other = "This is devvm {{.current}}, and devvm {{.version}} is older. Install it anyway?"
[upgrade_confirm_brew]
other = "Run brew upgrade devvm to install devvm {{.version}} in place of devvm {{.current}}?"
description = "formula is Homebrew's formula, devvm or devvm-rc"
other = "Run brew upgrade {{.formula}} to install devvm {{.version}} in place of devvm {{.current}}?"
[upgrade_nothing_installed]
other = "Nothing was installed."
@@ -2744,7 +2749,8 @@ other = "Installed devvm {{.version}} at {{.link}}."
other = "devvm {{.version}} stays installed, because a running VM uses it."
[upgrade_brew_failed]
other = "Homebrew's brew upgrade devvm failed, so its devvm stays as it was."
description = "formula is Homebrew's formula, devvm or devvm-rc"
other = "Homebrew's brew upgrade {{.formula}} failed, so its devvm stays as it was."
[upgrade_brew_done]
other = "Homebrew upgraded devvm."
+8 -5
View File
@@ -1,8 +1,9 @@
# The formula for the devvmhq/homebrew-tap repo. scripts/release.sh fills in each platform's
# @URL_<OS>_<ARCH>@ and @SHA256_<OS>_<ARCH>@ from the release's SHA256SUMS, and writes the result to
# dist/devvm.rb. It installs the release's binary, which SHA256SUMS.minisig signs. Homebrew reads the
# version from the URLs (devvm-<version>-<os>-<arch>.tar.gz).
class Devvm < Formula
# The formulas for the devvmhq/homebrew-tap repo: devvm, a release's, and devvm-rc, the newest
# prerelease's or release's. scripts/release.sh fills in @CLASS@ and @CONFLICTS@ for each formula, and
# each platform's @URL_<OS>_<ARCH>@ and @SHA256_<OS>_<ARCH>@ from the release's SHA256SUMS, and writes the
# result to dist/devvm.rb or dist/devvm-rc.rb. It installs the release's binary, which SHA256SUMS.minisig
# signs. Homebrew reads the version from the URLs (devvm-<version>-<os>-<arch>.tar.gz).
class @CLASS@ < Formula
desc "Isolated Lima VM per project folder, with shared read-only toolchains"
homepage "https://github.com/devvmhq/devvm"
license "MIT"
@@ -31,6 +32,8 @@ class Devvm < Formula
end
end
conflicts_with "@CONFLICTS@", because: "both install the devvm binary"
def install
bin.install "devvm"
end
+97 -40
View File
@@ -7,11 +7,13 @@
# scripts/publish.sh --help this
# It pushes main and the tag to origin, makes the GitHub release devvmhq/devvm v<version> with the archives,
# the source tarball, SHA256SUMS, SHA256SUMS.minisig and install.sh, its notes CHANGELOG.md's entry, then
# commits dist/devvm.rb to the tap's Formula/devvm.rb and pushes the tap. Each step skips what's already
# done, so after a failure, fix it and run it again.
# commits dist/devvm.rb to the tap's Formula/devvm.rb, and dist/devvm-rc.rb to its Formula/devvm-rc.rb when
# the tap's devvm-rc is older, so devvm-rc's users get the release too, and pushes the tap. Each step skips
# what's already done, so after a failure, fix it and run it again.
# A prerelease (VERSION x.y.z-rc.N, such as 0.2.0-rc.1) gets a GitHub release marked as a prerelease, which
# GitHub's latest release, and so install.sh's default and devvm upgrade, skips, and no tap commit: the tap,
# and so Homebrew, stays on the last release, and no tap checkout is needed.
# GitHub's latest release, and so install.sh's default and devvm upgrade, skips. Its tap commit,
# devvm-rc <version>, changes only Formula/devvm-rc.rb, when the tap's devvm-rc is older, so the formula
# devvm stays on the last release.
# DEVVM_TAP_DIR: the checkout of devvmhq/homebrew-tap, clean and on main (default ../homebrew-tap, next to
# this repo). DEVVM_MINISIGN_KEY: the release key (scripts/release.sh's).
# Needs gh, logged in (gh auth login), and release.sh's goreleaser and minisign: mise exec -- scripts/publish.sh.
@@ -43,6 +45,31 @@ remote_ref() {
awk -v r="$2" '$2 == r { print $1 }' <<<"$out"
}
sha256() { { sha256sum "$1" 2>/dev/null || shasum -a 256 "$1"; } | cut -c1-64; }
# formula_version FILE: the release the formula FILE installs, from its first URL
# (releases/download/v<version>/); "" for no file or none it names as release.sh writes versions.
formula_version() {
local got
[[ -f $1 ]] || return 0
got=$(sed -n 's|.*/releases/download/v\([^/"]*\)/.*|\1|p' "$1" | head -n1)
[[ $got =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?$ ]] && echo "$got"
return 0
}
# newer A B: whether version A is newer than version B, both x.y.z or x.y.z-<word>.N (release.sh's
# forms): numbers as numbers, a prerelease before its release, words as text, then their numbers.
newer() {
local a b i ap=0 bp=0
IFS=.- read -r -a a <<<"$1"
IFS=.- read -r -a b <<<"$2"
for i in 0 1 2; do
((10#${a[i]} == 10#${b[i]})) || { ((10#${a[i]} > 10#${b[i]})); return; }
done
[[ $1 == *-* ]] && ap=1
[[ $2 == *-* ]] && bp=1
((ap == bp)) || { ((ap < bp)); return; }
((ap)) || return 1
[[ ${a[3]} == "${b[3]}" ]] || { [[ ${a[3]} > ${b[3]} ]]; return; }
((10#${a[4]} > 10#${b[4]}))
}
# The preconditions, before anything asks for the password.
[[ -z $(git status --porcelain) ]] || die "the working tree isn't clean: commit or remove what git status lists"
@@ -90,24 +117,32 @@ elif ! grep -qi 'not found' <<<"$out"; then
die "can't read the GitHub release $tag (gh release view): $out"
fi
# The tap, which a prerelease leaves alone.
# The tap.
tap=${DEVVM_TAP_DIR:-$(dirname "$root")/homebrew-tap}
if ! $pre; then
[[ -d $tap ]] && top=$(git -C "$tap" rev-parse --show-toplevel 2>/dev/null) && [[ $top == "$(cd "$tap" && pwd -P)" ]] ||
die "no tap checkout at $tap: clone devvmhq/homebrew-tap there, or set DEVVM_TAP_DIR"
[[ $(git -C "$tap" symbolic-ref -q --short HEAD) == main ]] || die "the tap at $tap isn't on main"
[[ -z $(git -C "$tap" status --porcelain) ]] || die "the tap at $tap isn't clean: commit or remove what git status lists"
tap_origin=$(remote_ref "$tap" refs/heads/main) || die "can't read the tap's origin (git -C $tap ls-remote origin)"
tap_head=$(git -C "$tap" rev-parse HEAD)
if [[ -n $tap_origin && $tap_origin != "$tap_head" ]]; then
git -C "$tap" merge-base --is-ancestor "$tap_origin" "$tap_head" 2>/dev/null ||
die "the tap's origin has commits its main lacks: git -C $tap pull"
fi
[[ -d $tap ]] && top=$(git -C "$tap" rev-parse --show-toplevel 2>/dev/null) && [[ $top == "$(cd "$tap" && pwd -P)" ]] ||
die "no tap checkout at $tap: clone devvmhq/homebrew-tap there, or set DEVVM_TAP_DIR"
[[ $(git -C "$tap" symbolic-ref -q --short HEAD) == main ]] || die "the tap at $tap isn't on main"
[[ -z $(git -C "$tap" status --porcelain) ]] || die "the tap at $tap isn't clean: commit or remove what git status lists"
tap_origin=$(remote_ref "$tap" refs/heads/main) || die "can't read the tap's origin (git -C $tap ls-remote origin)"
tap_head=$(git -C "$tap" rev-parse HEAD)
if [[ -n $tap_origin && $tap_origin != "$tap_head" ]]; then
git -C "$tap" merge-base --is-ancestor "$tap_origin" "$tap_head" 2>/dev/null ||
die "the tap's origin has commits its main lacks: git -C $tap pull"
fi
# The tap's formulas this release writes: devvm.rb for a release, and devvm-rc.rb unless the tap's
# devvm-rc is newer than this, so devvm-rc only moves forward, to a prerelease or a release.
rc_was=$(formula_version "$tap/Formula/devvm-rc.rb")
rc_moves=true
if [[ -n $rc_was ]] && newer "$rc_was" "$v"; then rc_moves=false; fi
tap_files=()
$pre || tap_files+=(devvm.rb)
! $rc_moves || tap_files+=(devvm-rc.rb)
tap_msg="devvm $v"
$pre && tap_msg="devvm-rc $v"
# The build, from the tag. minisign asks for the password.
scripts/release.sh || die "scripts/release.sh failed: nothing published"
for f in "${files[@]}" devvm.rb; do [[ -f dist/$f ]] || die "dist/ has no $f: nothing published"; done
for f in "${files[@]}" ${tap_files[@]+"${tap_files[@]}"}; do [[ -f dist/$f ]] || die "dist/ has no $f: nothing published"; done
tmp=$(mktemp -d "${TMPDIR:-/tmp}/devvm-publish.XXXXXX")
trap 'rm -rf "$tmp"' EXIT
notes=$tmp/notes.md
@@ -129,7 +164,13 @@ done_main=false done_tag=false done_release=false done_tap=false
[[ $origin_main != "$commit" ]] || done_main=true
[[ $origin_tag != "$tagobj" ]] || done_tag=true
[[ $release != published ]] || done_release=true
if $pre || { cmp -s "$tap/Formula/devvm.rb" dist/devvm.rb && [[ $tap_origin == "$tap_head" ]]; }; then done_tap=true; fi
if ((${#tap_files[@]})); then
done_tap=true
[[ $tap_origin == "$tap_head" ]] || done_tap=false
for f in "${tap_files[@]}"; do cmp -s "$tap/Formula/$f" "dist/$f" || done_tap=false; done
else
done_tap=true
fi
state() { if $1; then echo "done"; else echo "$2"; fi; }
echo
@@ -145,15 +186,24 @@ echo
echo "Release notes, CHANGELOG.md's ## $v:"
sed 's/^/ /' "$notes"
echo
if $pre; then
echo "Tap: skipped, as this is a prerelease: Homebrew stays on the last release."
else
echo "Tap, $tap, Formula/devvm.rb:"
old=$tap/Formula/devvm.rb
echo "Tap, $tap:"
$pre && echo "Formula/devvm.rb: stays on the last release, as this is a prerelease."
for f in ${tap_files[@]+"${tap_files[@]}"}; do
if [[ $f == devvm-rc.rb && $rc_was != "$v" ]] && ! $pre; then
if [[ -n $rc_was ]]; then
echo "Formula/devvm-rc.rb, which moves from $rc_was to this release too:"
else
echo "Formula/devvm-rc.rb, which the tap doesn't have yet, for this release too:"
fi
else
echo "Formula/$f:"
fi
old=$tap/Formula/$f
[[ -f $old ]] || old=/dev/null
git -C "$tap" diff --no-index -- "$old" "$root/dist/devvm.rb" || true
cmp -s "$old" dist/devvm.rb && echo " (already this release's)"
fi
git -C "$tap" diff --no-index -- "$old" "$root/dist/$f" || true
if cmp -s "$old" "dist/$f"; then echo " (already this release's)"; fi
done
$rc_moves || echo "Formula/devvm-rc.rb: stays at $rc_was, which is newer than $v."
echo
echo "Steps:"
echo " 1. git push origin main: $(state $done_main "to do")"
@@ -162,18 +212,20 @@ todo="to do"
[[ $release != draft ]] || todo="to do, the draft's files replaced"
$pre && todo="$todo, marked as a prerelease"
echo " 3. the GitHub $kind $tag: $(state $done_release "$todo")"
if $pre; then
echo " 4. the tap: skipped (a prerelease)"
if ((${#tap_files[@]})); then
echo " 4. the tap's commit, $tap_msg, and git push: $(state $done_tap "to do")"
else
echo " 4. the tap's commit, devvm $v, and git push: $(state $done_tap "to do")"
echo " 4. the tap: nothing to change"
fi
echo
check() {
if $pre; then
local formula=devvm
$pre && formula=devvm-rc
if $pre && ! $rc_moves; then
echo "Check it with the install script, or devvm upgrade --to $v:"
else
echo "Check it with Homebrew, brew update && brew upgrade devvm (or brew trust --formula devvmhq/tap/devvm, then brew install devvmhq/tap/devvm), or the install script:"
echo "Check it with Homebrew, brew update && brew upgrade $formula (or brew trust --formula devvmhq/tap/$formula, then brew install devvmhq/tap/$formula), or the install script:"
fi
echo " curl -fsSL https://github.com/devvmhq/devvm/releases/download/$tag/install.sh | bash"
}
@@ -212,18 +264,23 @@ step_release() {
gh release edit "$tag" --repo "$repo" --title "devvm $v" --notes-file "$notes" --draft=false ${pre_flag[@]+"${pre_flag[@]}"}
}
step_tap() {
$done_tap && { echo "the tap is already at devvm $v"; return 0; }
if ! cmp -s "$tap/Formula/devvm.rb" dist/devvm.rb; then
mkdir -p "$tap/Formula" && cp dist/devvm.rb "$tap/Formula/devvm.rb" || return 1
git -C "$tap" add Formula/devvm.rb && git -C "$tap" commit -q -m "devvm $v" || return 1
$done_tap && { echo "the tap is already at $tap_msg"; return 0; }
local f changed=()
for f in "${tap_files[@]}"; do
cmp -s "$tap/Formula/$f" "dist/$f" && continue
mkdir -p "$tap/Formula" && cp "dist/$f" "$tap/Formula/$f" || return 1
changed+=("Formula/$f")
done
if ((${#changed[@]})); then
git -C "$tap" add "${changed[@]}" && git -C "$tap" commit -q -m "$tap_msg" || return 1
fi
git -C "$tap" push origin main
}
names=(main tag release tap)
labels=("main on origin" "the tag $tag on origin" "the GitHub release $tag" "the tap's Formula/devvm.rb")
if $pre; then
names=(main tag release)
labels=("main on origin" "the tag $tag on origin" "the GitHub prerelease $tag")
names=(main tag release)
labels=("main on origin" "the tag $tag on origin" "the GitHub $kind $tag")
if ((${#tap_files[@]})); then
names+=(tap)
labels+=("the tap's Formula/${tap_files[0]}${tap_files[1]:+ and Formula/${tap_files[1]}}")
fi
for i in "${!names[@]}"; do
echo "==> ${labels[$i]}"
+41 -15
View File
@@ -5,7 +5,9 @@
# SHA256SUMS their checksums and install.sh's, which install.sh checks
# SHA256SUMS.minisig SHA256SUMS signed with the release key (minisign), which install.sh checks
# install.sh the install script, set to install this release and to trust the key
# devvm.rb the Homebrew formula for devvmhq/homebrew-tap: each platform's archive
# devvm-rc.rb the Homebrew formula devvm-rc for devvmhq/homebrew-tap, which follows
# prereleases: each platform's archive
# devvm.rb for a release, not a prerelease, the formula devvm too
# Nothing is published. The version is VERSION's: x.y.z, or a prerelease's x.y.z-rc.N (any lowercase word,
# such as beta or alpha, then a number). The public key is packaging/minisign.pub (committed); the secret key
# is the maintainer's, at DEVVM_MINISIGN_KEY (default ~/.minisign/devvm.key), never in the repo.
@@ -16,8 +18,9 @@
# scripts/release.sh --check only the tag's checks and what the build needs, then prints the tag's commit
# (scripts/publish.sh runs it first); nothing is built
# scripts/release.sh --formula-from DIR
# only dist/devvm.rb, for VERSION's published release, from its SHA256SUMS
# only the formulas, for VERSION's published release, from its SHA256SUMS
# and SHA256SUMS.minisig downloaded into DIR, checked against minisign.pub
# and its trusted comment, devvm <version>
# Needs goreleaser and minisign, pinned in mise.toml: mise exec -- scripts/release.sh.
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -30,15 +33,29 @@ v=$(tr -d '[:space:]' < VERSION)
ref=v$v
check=false
# formula TEMPLATE SUMS URL VERSION: the Homebrew formula, from its template, with each platform's
# archive's URL and its checksum from SHA256SUMS (on lines that aren't comments).
# The Homebrew formulas VERSION gets: devvm-rc, which follows prereleases, for every release, and devvm
# for a release that isn't a prerelease.
names=(devvm-rc)
[[ $v == *-* ]] || names=(devvm devvm-rc)
# formula TEMPLATE SUMS URL VERSION NAME: the Homebrew formula NAME, devvm or devvm-rc, from its template:
# its class, the other formula, which it conflicts with (by its full name, which no other tap's devvm
# makes ambiguous), and each platform's archive's URL and its checksum from SHA256SUMS (on lines that
# aren't comments).
formula() {
awk -v sums="$2" -v u="$3" -v v="$4" '
local class other
case $5 in
devvm) class=Devvm other=devvmhq/tap/devvm-rc ;;
devvm-rc) class=DevvmRc other=devvmhq/tap/devvm ;;
*) echo "no formula $5" >&2; return 1 ;;
esac
awk -v sums="$2" -v u="$3" -v v="$4" -v class="$class" -v other="$other" '
BEGIN {
while ((getline line < sums) > 0) { split(line, f, " "); sha[f[2]] = f[1] }
split("darwin linux", oses, " "); split("arm64 amd64", arches, " ")
}
!/^#/ {
gsub("@CLASS@", class); gsub("@CONFLICTS@", other)
for (i in oses) for (j in arches) {
p = toupper(oses[i] "_" arches[j]); a = "devvm-" v "-" oses[i] "-" arches[j] ".tar.gz"
if (index($0, "@SHA256_" p "@")) {
@@ -52,21 +69,30 @@ formula() {
{ print } END { exit bad }' "$1"
}
# formulas TEMPLATE SUMS URL OUT: VERSION's formulas (names), each as OUT/<name>.rb.
formulas() {
local n
for n in "${names[@]}"; do formula "$1" "$2" "$3" "$v" "$n" > "$4/$n.rb" || return 1; done
}
case ${1:-} in
--head) ref=HEAD ;;
--check) check=true ;;
--formula-from)
# The formula for a published release, from its downloaded SHA256SUMS and SHA256SUMS.minisig in DIR,
# checked against packaging/minisign.pub; nothing is built.
# The formulas for a published release, from its downloaded SHA256SUMS and SHA256SUMS.minisig in
# DIR, checked against packaging/minisign.pub, and signed as VERSION's release: its trusted comment
# is devvm <version>, as this script signs it. Nothing is built.
dir=${2:-}
[[ -n $dir && -f $dir/SHA256SUMS && -f $dir/SHA256SUMS.minisig ]] || die "--formula-from DIR needs DIR/SHA256SUMS and DIR/SHA256SUMS.minisig"
command -v minisign >/dev/null || die "needs minisign (mise exec -- scripts/release.sh)"
minisign -Vm "$dir/SHA256SUMS" -x "$dir/SHA256SUMS.minisig" -p packaging/minisign.pub >/dev/null ||
verified=$(minisign -Vm "$dir/SHA256SUMS" -x "$dir/SHA256SUMS.minisig" -p packaging/minisign.pub) ||
die "$dir/SHA256SUMS doesn't verify with packaging/minisign.pub"
comment=$(sed -n 's/^Trusted comment: //p' <<<"$verified")
[[ $comment == "devvm $v" ]] || die "$dir/SHA256SUMS is signed as '$comment', not VERSION's 'devvm $v'"
mkdir -p dist
formula packaging/homebrew/devvm.rb "$dir/SHA256SUMS" "https://github.com/devvmhq/devvm/releases/download/v$v" "$v" \
> dist/devvm.rb || die "couldn't write the formula"
echo "==> dist/devvm.rb for devvm $v, from $dir/SHA256SUMS"
formulas packaging/homebrew/devvm.rb "$dir/SHA256SUMS" "https://github.com/devvmhq/devvm/releases/download/v$v" dist ||
die "couldn't write the formulas"
for n in "${names[@]}"; do echo "==> dist/$n.rb for devvm $v, from $dir/SHA256SUMS"; done
exit 0 ;;
"") ;;
*) die "unknown argument '$1' (--head, --check, --formula-from DIR)" ;;
@@ -146,7 +172,7 @@ git show "$commit:install.sh" |
> "$out/install.sh" || die "install.sh needs one release_version=\"\" and one minisign_key=\"\" line"
chmod 755 "$out/install.sh"
git show "$commit:packaging/homebrew/devvm.rb" > "$tmp/devvm.rb" || die "no packaging/homebrew/devvm.rb in $ref"
formula "$tmp/devvm.rb" "$out/SHA256SUMS" "$url" "$v" > "$out/devvm.rb" || die "couldn't write the formula"
formulas "$tmp/devvm.rb" "$out/SHA256SUMS" "$url" "$out" || die "couldn't write the formulas"
# install.sh's checksum goes in SHA256SUMS before it's signed, so you can check the script against the
# release key before you run it.
@@ -158,10 +184,10 @@ if $sign; then
fi
echo "==> dist/ for devvm $v (from $ref):"
(cd "$out" && ls -l devvm-*.tar.gz SHA256SUMS* install.sh devvm.rb 2>/dev/null) || true
(cd "$out" && ls -l devvm-*.tar.gz SHA256SUMS* install.sh devvm*.rb 2>/dev/null) || true
$sign || echo "(not signed: a test build without DEVVM_MINISIGN_KEY)"
if [[ $v == *-* ]]; then
echo "scripts/publish.sh publishes them: the archives, SHA256SUMS, SHA256SUMS.minisig and install.sh to the GitHub prerelease v$v; devvm.rb stays out of the tap, which keeps the last release."
echo "scripts/publish.sh publishes them: the archives, SHA256SUMS, SHA256SUMS.minisig and install.sh to the GitHub prerelease v$v, devvm-rc.rb to devvmhq/homebrew-tap's Formula/; the formula devvm keeps the last release."
else
echo "scripts/publish.sh publishes them: the archives, SHA256SUMS, SHA256SUMS.minisig and install.sh to the GitHub release v$v, devvm.rb to devvmhq/homebrew-tap's Formula/."
echo "scripts/publish.sh publishes them: the archives, SHA256SUMS, SHA256SUMS.minisig and install.sh to the GitHub release v$v, devvm.rb to devvmhq/homebrew-tap's Formula/, and devvm-rc.rb too when the tap's devvm-rc is older."
fi
+5
View File
@@ -180,6 +180,11 @@ stderr '^install: Homebrew installed devvm: run brew upgrade devvm to upgrade it
exec bash main.sh --no-deps --version 0.1.0 --force
stdout '^==> installed devvm 0.1.0: \S+/prefix/bin/devvm$'
rm Cellar/devvm/0.0.9
# devvm-rc's keg, the formula that follows prereleases, too.
mkdir Cellar/devvm-rc/0.1.0-rc.1
! exec bash main.sh --no-deps --version 0.1.0
stderr '^install: Homebrew installed devvm: run brew upgrade devvm-rc to upgrade it, or brew uninstall devvm-rc first to use this script \(--force installs a second copy\)$'
rm Cellar/devvm-rc/0.1.0-rc.1
# An empty rack isn't a keg.
exec bash main.sh --no-deps --version 0.1.0
stdout '^==> installed devvm 0.1.0: \S+/prefix/bin/devvm$'
+98 -18
View File
@@ -73,6 +73,9 @@ stdout '^ SHA256SUMS\.minisig +[0-9]+ bytes [0-9a-f]{64}$'
stdout '^ - \*\*New:\*\* a thing\.$'
! stdout 'Older'
stdout '^\+ url "https://github.com/devvmhq/devvm/releases/download/v1\.2\.3/devvm-1\.2\.3-darwin-arm64\.tar\.gz"$'
stdout '^Formula/devvm\.rb:$'
stdout '^Formula/devvm-rc\.rb, which the tap doesn''t have yet, for this release too:$'
stdout '^\+class DevvmRc < Formula$'
stdout '^ 1\. git push origin main: to do$'
stdout '^ 4\. the tap''s commit, devvm 1\.2\.3, and git push: to do$'
stdout '^--dry-run: nothing published\.$'
@@ -101,7 +104,7 @@ stderr '^publish: the GitHub release v1\.2\.3 failed\.$'
stderr '^ published: main on origin$'
stderr '^ published: the tag v1\.2\.3 on origin$'
stderr '^ not published: the GitHub release v1\.2\.3$'
stderr '^ not published: the tap''s Formula/devvm\.rb$'
stderr '^ not published: the tap''s Formula/devvm\.rb and Formula/devvm-rc\.rb$'
! exists gh/release
# Run again, with gh failing to publish the draft: it skips the pushes and
@@ -117,12 +120,13 @@ exists gh/draft
exists gh/release/SHA256SUMS.minisig
# And again: it uploads the draft's files again, publishes it, then commits
# the formula to the tap and pushes it.
# the formulas to the tap, devvm's and devvm-rc's, and pushes it.
rm gh/fail-edit
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
stdout '^ 3\. the GitHub release v1\.2\.3: to do, the draft''s files replaced$'
stdout '^==> devvm 1\.2\.3 is published$'
stdout '^Check it with Homebrew, brew update && brew upgrade devvm \(or brew trust --formula devvmhq/tap/devvm, then brew install devvmhq/tap/devvm\), or the install script:$'
stdout '^ curl -fsSL https://github.com/devvmhq/devvm/releases/download/v1\.2\.3/install\.sh \| bash$'
cmp calls calls.want
exec bash refs.sh
@@ -132,6 +136,7 @@ cmp stdout assets.want
! exists gh/draft
cmp gh/notes notes.want
cmp tap/Formula/devvm.rb repo/dist/devvm.rb
cmp tap/Formula/devvm-rc.rb repo/dist/devvm-rc.rb
exec git -C tap.git log -1 --format=%s main
stdout '^devvm 1\.2\.3$'
@@ -139,33 +144,46 @@ stdout '^devvm 1\.2\.3$'
rm calls
exec repo/scripts/publish.sh
stdout '^devvm 1\.2\.3 is already published: nothing to do\.$'
stdout '^Formula/devvm-rc\.rb:\n \(already this release''s\)$'
grep '^gh release download v1\.2\.3 ' calls
! grep 'push|create|edit' calls
# A prerelease, 1.3.0-rc.1: its GitHub release is marked as one, and it
# needs no tap checkout and leaves the tap alone.
exec bash prerelease.sh
# A prerelease, 1.3.0-rc.1: its GitHub release is marked as one, and its
# tap commit, devvm-rc 1.3.0-rc.1, moves only devvm-rc, so the formula
# devvm stays on 1.2.3. It needs the tap checkout too.
exec bash version.sh 1.3.0-rc.1 'A release candidate.' 'another thing'
rm gh/release
rm gh/notes
rm calls
env DEVVM_TAP_DIR=$WORK/nowhere
! exec repo/scripts/publish.sh --dry-run
stderr '^publish: no tap checkout at '
env DEVVM_TAP_DIR=$WORK/tap
exec repo/scripts/publish.sh --dry-run
stdout '^Version: 1\.3\.0-rc\.1, a prerelease$'
stdout '^Tap: skipped, as this is a prerelease: Homebrew stays on the last release\.$'
stdout '^Formula/devvm\.rb: stays on the last release, as this is a prerelease\.$'
stdout '^Formula/devvm-rc\.rb:$'
stdout '^\+ url "https://github.com/devvmhq/devvm/releases/download/v1\.3\.0-rc\.1/devvm-1\.3\.0-rc\.1-darwin-arm64\.tar\.gz"$'
! stdout '^\+class'
stdout '^ 3\. the GitHub prerelease v1\.3\.0-rc\.1: to do, marked as a prerelease$'
stdout '^ 4\. the tap: skipped \(a prerelease\)$'
stdout '^ 4\. the tap''s commit, devvm-rc 1\.3\.0-rc\.1, and git push: to do$'
stdout '^ - \*\*New:\*\* another thing\.$'
! stdout 'Released today'
! exists repo/dist/devvm.rb
rm calls
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
stdout '^==> devvm 1\.3\.0-rc\.1 is published$'
stdout '^Check it with the install script, or devvm upgrade --to 1\.3\.0-rc\.1:$'
stdout '^Check it with Homebrew, brew update && brew upgrade devvm-rc \(or brew trust --formula devvmhq/tap/devvm-rc, then brew install devvmhq/tap/devvm-rc\), or the install script:$'
cmp calls calls.pre
exists gh/prerelease
cmp gh/notes notes.pre
exec git -C tap.git log -1 --format=%s main
stdout '^devvm 1\.2\.3$'
stdout '^devvm-rc 1\.3\.0-rc\.1$'
exec git -C tap.git show --name-only --format= main
cmp stdout rc.changed
cmp tap/Formula/devvm-rc.rb repo/dist/devvm-rc.rb
grep 'download/v1\.2\.3/' tap/Formula/devvm.rb
# Run again: everything's done.
rm calls
@@ -178,6 +196,65 @@ rm gh/prerelease
! exec repo/scripts/publish.sh --dry-run
stderr '^publish: devvm v1\.3\.0-rc\.1 is a prerelease, but its GitHub release isn''t marked as one'
# A release older than devvm-rc's prerelease, 1.2.4: devvm moves to it,
# and devvm-rc stays on 1.3.0-rc.1.
exec bash version.sh 1.2.4 'A fix.' 'a fix'
rm gh/release
rm gh/notes
exec repo/scripts/publish.sh --dry-run
stdout '^Formula/devvm\.rb:$'
stdout '^Formula/devvm-rc\.rb: stays at 1\.3\.0-rc\.1, which is newer than 1\.2\.4\.$'
stdout '^ 4\. the tap''s commit, devvm 1\.2\.4, and git push: to do$'
rm calls
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
stdout '^==> the tap''s Formula/devvm\.rb$'
exec git -C tap.git show --name-only --format= main
stdout '^Formula/devvm\.rb\n\z'
grep 'download/v1\.3\.0-rc\.1/' tap/Formula/devvm-rc.rb
# A prerelease older than devvm-rc's, 1.2.5-rc.1: nothing in the tap
# changes, so there's no tap step.
exec bash version.sh 1.2.5-rc.1 'An older candidate.' 'an older thing'
rm gh/release
rm gh/notes
exec repo/scripts/publish.sh --dry-run
stdout '^Formula/devvm-rc\.rb: stays at 1\.3\.0-rc\.1, which is newer than 1\.2\.5-rc\.1\.$'
stdout '^ 4\. the tap: nothing to change$'
rm calls
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
stdout '^Check it with the install script, or devvm upgrade --to 1\.2\.5-rc\.1:$'
! grep 'push tap' calls
# The release 1.3.0, newer than devvm-rc's prerelease: devvm-rc moves to
# it with devvm, in one commit.
exec bash version.sh 1.3.0 'The release.' 'the release'
rm gh/release
rm gh/notes
rm gh/prerelease
exec repo/scripts/publish.sh --dry-run
stdout '^Formula/devvm-rc\.rb, which moves from 1\.3\.0-rc\.1 to this release too:$'
stdout '^\+ url "https://github.com/devvmhq/devvm/releases/download/v1\.3\.0/devvm-1\.3\.0-darwin-arm64\.tar\.gz"$'
rm calls
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
exec git -C tap.git log -1 --format=%s main
stdout '^devvm 1\.3\.0$'
exec git -C tap.git show --name-only --format= main
cmp stdout both.changed
cmp tap/Formula/devvm.rb repo/dist/devvm.rb
cmp tap/Formula/devvm-rc.rb repo/dist/devvm-rc.rb
rm calls
exec repo/scripts/publish.sh
stdout '^devvm 1\.3\.0 is already published: nothing to do\.$'
! grep 'push|create|edit' calls
-- rc.changed --
Formula/devvm-rc.rb
-- both.changed --
Formula/devvm-rc.rb
Formula/devvm.rb
-- calls.pre --
gh auth status
gh release view v1.3.0-rc.1 --repo devvmhq/devvm --json isDraft,isPrerelease,assets --jq (.isDraft | tostring), (.isPrerelease | tostring), .assets[].name
@@ -185,6 +262,7 @@ push origin.git refs/heads/main
push origin.git refs/tags/v1.3.0-rc.1
gh release create v1.3.0-rc.1 --repo devvmhq/devvm --title devvm 1.3.0-rc.1 --notes-file notes.md --verify-tag --draft --prerelease devvm-1.3.0-rc.1-darwin-arm64.tar.gz devvm-1.3.0-rc.1-darwin-amd64.tar.gz devvm-1.3.0-rc.1-linux-arm64.tar.gz devvm-1.3.0-rc.1-linux-amd64.tar.gz devvm-1.3.0-rc.1.tar.gz SHA256SUMS SHA256SUMS.minisig install.sh
gh release edit v1.3.0-rc.1 --repo devvmhq/devvm --title devvm 1.3.0-rc.1 --notes-file notes.md --draft=false --prerelease
push tap.git refs/heads/main
-- notes.pre --
A release candidate.
@@ -240,29 +318,31 @@ set -eu
t=${2:-v1.2.3}
git -C repo tag -d "$t" >/dev/null 2>&1 || true
git -C repo -c user.signingkey="$PWD/keys/$1" tag -s "$t" -m "$t"
-- prerelease.sh --
# VERSION 1.3.0-rc.1 and its changelog entry, committed on main and tagged.
-- version.sh --
# VERSION $1 and its changelog entry, $2 then a list item New: $3, over
# 1.2.3's, committed on main and tagged.
set -eu
echo 1.3.0-rc.1 > repo/VERSION
printf '# Changelog\n\n## 1.3.0-rc.1\n\nA release candidate.\n\n- **New:** another thing.\n\n## 1.2.3\n\nReleased today.\n' > repo/CHANGELOG.md
git -C repo commit -qam 'release 1.3.0-rc.1'
bash tag.sh good v1.3.0-rc.1
echo "$1" > repo/VERSION
printf '# Changelog\n\n## %s\n\n%s\n\n- **New:** %s.\n\n## 1.2.3\n\nReleased today.\n' "$1" "$2" "$3" > repo/CHANGELOG.md
git -C repo commit -qam "release $1"
bash tag.sh good "v$1"
-- refs.sh --
# What origin and the tap hold: main's commit message, the tag, the tap's
# last commit, and whether it has the formula.
git -C origin.git log -1 --format=%s main
git -C origin.git tag -l
git -C tap.git log -1 --format=%s main
git -C tap.git cat-file -e main:Formula/devvm.rb 2>/dev/null && echo formula || echo no formula
f=$(git -C tap.git ls-tree --name-only main Formula/ | paste -sd' ' -)
echo "formulas: ${f:-none}"
-- refs.before --
r
tap
no formula
formulas: none
-- refs.after --
release 1.2.3
v1.2.3
devvm 1.2.3
formula
formulas: Formula/devvm-rc.rb Formula/devvm.rb
-- calls.view --
gh auth status
gh release view v1.2.3 --repo devvmhq/devvm --json isDraft,isPrerelease,assets --jq (.isDraft | tostring), (.isPrerelease | tostring), .assets[].name
+101 -10
View File
@@ -30,20 +30,51 @@ grep '^release_version="1.2.3"$' repo/dist/install.sh
cmp stdout key.want
exec bash sums.sh
cmp stdout sums.want
exec bash formula.sh
exec bash formula.sh devvm.rb
cmp stdout formula.want
exec bash formula.sh devvm-rc.rb
cmp stdout formula.want
# --formula-from: the same formula from a published release's signed
# SHA256SUMS, checked against packaging/minisign.pub; a changed one refused.
# A release gets both formulas, devvm and devvm-rc, each conflicting with
# the other: they differ only in that.
exec bash -c 'diff repo/dist/devvm.rb repo/dist/devvm-rc.rb || true'
cmp stdout formulas.diff
# --formula-from: the same formulas from a published release's signed
# SHA256SUMS, checked against packaging/minisign.pub and its trusted
# comment; a changed one refused, and one signed as another release's.
mkdir pub
cp repo/dist/SHA256SUMS repo/dist/SHA256SUMS.minisig pub/
cp repo/dist/devvm.rb devvm.rb.built
cp repo/dist/devvm-rc.rb devvm-rc.rb.built
cp keys/test.pub repo/packaging/minisign.pub
exec repo/scripts/release.sh --formula-from $WORK/pub
stdout '^==> dist/devvm\.rb for devvm 1\.2\.3, from '
stdout '^==> dist/devvm-rc\.rb for devvm 1\.2\.3, from '
cmp repo/dist/devvm.rb devvm.rb.built
cmp repo/dist/devvm-rc.rb devvm-rc.rb.built
exec bash -c 'echo 1.2.4 > repo/VERSION'
! exec repo/scripts/release.sh --formula-from $WORK/pub
stderr '^release: \S+/SHA256SUMS is signed as ''devvm 1\.2\.3'', not VERSION''s ''devvm 1\.2\.4''$'
exec git -C repo checkout -q VERSION
exec bash -c 'echo x >> pub/SHA256SUMS'
! exec repo/scripts/release.sh --formula-from $WORK/pub
stderr 'SHA256SUMS doesn''t verify with packaging/minisign.pub$'
# The formula substitution, whole: a prerelease's SHA256SUMS gives only
# devvm-rc.rb, its class, its conflict and each platform's URL and
# checksum in place.
mkdir pubrc
cp sums.rc pubrc/SHA256SUMS
exec minisign -Sm pubrc/SHA256SUMS -s keys/test.key -t 'devvm 1.3.0-rc.1' -x pubrc/SHA256SUMS.minisig
exec bash -c 'echo 1.3.0-rc.1 > repo/VERSION'
rm repo/dist/devvm.rb repo/dist/devvm-rc.rb
exec repo/scripts/release.sh --formula-from $WORK/pubrc
! stdout 'dist/devvm\.rb'
! exists repo/dist/devvm.rb
exec grep -v '^#' repo/dist/devvm-rc.rb
cmp stdout devvm-rc.want
exec git -C repo checkout -q VERSION
rm repo/packaging/minisign.pub
# Only what's committed goes in.
@@ -52,15 +83,21 @@ stdout '^devvm-1.2.3/VERSION$'
! stdout uncommitted
# A prerelease's VERSION, 1.3.0-rc.1: its archives, install.sh and the
# trusted comment all name it, and the tap is said to keep the last
# release.
# trusted comment all name it, it gets only the formula devvm-rc, and the
# formula devvm is said to keep the last release.
exec bash -c 'echo 1.3.0-rc.1 > repo/VERSION && git -C repo commit -qam rc'
exec repo/scripts/release.sh --head
stdout 'GitHub prerelease v1\.3\.0-rc\.1; devvm\.rb stays out of the tap'
stdout 'GitHub prerelease v1\.3\.0-rc\.1, devvm-rc\.rb to devvmhq/homebrew-tap''s Formula/; the formula devvm keeps the last release\.$'
exists repo/dist/devvm-1.3.0-rc.1-linux-arm64.tar.gz
exists repo/dist/devvm-1.3.0-rc.1.tar.gz
grep '^release_version="1.3.0-rc.1"$' repo/dist/install.sh
grep 'releases/download/v1\.3\.0-rc\.1/devvm-1\.3\.0-rc\.1-darwin-arm64\.tar\.gz"$' repo/dist/devvm.rb
! exists repo/dist/devvm.rb
grep '^class DevvmRc < Formula$' repo/dist/devvm-rc.rb
grep '^ conflicts_with "devvmhq/tap/devvm", because: "both install the devvm binary"$' repo/dist/devvm-rc.rb
grep 'releases/download/v1\.3\.0-rc\.1/devvm-1\.3\.0-rc\.1-darwin-arm64\.tar\.gz"$' repo/dist/devvm-rc.rb
exec bash formula.sh devvm-rc.rb
stdout '^https://github.com/devvmhq/devvm/releases/download/v1\.3\.0-rc\.1/devvm-1\.3\.0-rc\.1-linux-amd64\.tar\.gz checksum$'
stdout '^comments$'
exec minisign -Vm repo/dist/SHA256SUMS -p keys/test.pub
stdout 'Trusted comment: devvm 1\.3\.0-rc\.1$'
exec bash -c 'echo 1.2.3 > repo/VERSION && git -C repo commit -qam back'
@@ -124,9 +161,9 @@ cd repo/dist
-- sums.want --
install.sh: OK
-- formula.sh --
# Each platform's URL, and the checksum after it, against each archive's own
# and SHA256SUMS's line for it.
f=repo/dist/devvm.rb
# Formula $1's each platform's URL, and the checksum after it, against each
# archive's own and SHA256SUMS's line for it.
f=repo/dist/$1
grep -A1 '^ url ' "$f" | grep -v '^--$' | sed -n 'N;s/\n/ /;p' | while read -r _ u _ s; do
u=${u//\"/}; s=${s//\"/}; a=${u##*/}
sha=$({ sha256sum 2>/dev/null || shasum -a 256; } < "repo/dist/$a" | cut -c1-64)
@@ -141,6 +178,60 @@ https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-darwin-amd
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-linux-arm64.tar.gz checksum
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-linux-amd64.tar.gz checksum
comments
-- formulas.diff --
6c6
< class Devvm < Formula
---
> class DevvmRc < Formula
35c35
< conflicts_with "devvmhq/tap/devvm-rc", because: "both install the devvm binary"
---
> conflicts_with "devvmhq/tap/devvm", because: "both install the devvm binary"
-- sums.rc --
1111111111111111111111111111111111111111111111111111111111111111 devvm-1.3.0-rc.1-darwin-arm64.tar.gz
2222222222222222222222222222222222222222222222222222222222222222 devvm-1.3.0-rc.1-darwin-amd64.tar.gz
3333333333333333333333333333333333333333333333333333333333333333 devvm-1.3.0-rc.1-linux-arm64.tar.gz
4444444444444444444444444444444444444444444444444444444444444444 devvm-1.3.0-rc.1-linux-amd64.tar.gz
-- devvm-rc.want --
class DevvmRc < Formula
desc "Isolated Lima VM per project folder, with shared read-only toolchains"
homepage "https://github.com/devvmhq/devvm"
license "MIT"
depends_on "lima"
on_macos do
on_arm do
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-darwin-arm64.tar.gz"
sha256 "1111111111111111111111111111111111111111111111111111111111111111"
end
on_intel do
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-darwin-amd64.tar.gz"
sha256 "2222222222222222222222222222222222222222222222222222222222222222"
end
end
on_linux do
on_arm do
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-linux-arm64.tar.gz"
sha256 "3333333333333333333333333333333333333333333333333333333333333333"
end
on_intel do
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-linux-amd64.tar.gz"
sha256 "4444444444444444444444444444444444444444444444444444444444444444"
end
end
conflicts_with "devvmhq/tap/devvm", because: "both install the devvm binary"
def install
bin.install "devvm"
end
test do
assert_equal version.to_s, shell_output("#{bin}/devvm --version").strip
end
end
-- log.want --
release --clean --skip=publish --snapshot DEVVM_VERSION=1.2.3 GORELEASER_CURRENT_TAG=
-- bin/goreleaser --
+24
View File
@@ -113,6 +113,30 @@ ttyin -stdin $WORK/no.txt
! exec $DEVVM
stdout '^==> upgrade_available current=0.3.0-rc.1 latest=0.3.0$'
# Homebrew's devvm-rc follows prereleases: its check reads the releases
# feed, and a launch announces a newer prerelease, then the release once
# it's out.
mkdir $WORK/Cellar/devvm-rc/0.3.0-rc.1/bin
cp_exe $DEVVM_BIN/devvm $WORK/Cellar/devvm-rc/0.3.0-rc.1/bin/devvm
env DEVVM=$WORK/Cellar/devvm-rc/0.3.0-rc.1/bin/devvm
release_server 0.2.0 0.3.0-rc.2 0.3.0-rc.1
json_set $DATA/cache/release.json tried=2026-01-01T00:00:00Z
ttyin -stdin $WORK/no.txt
! exec $DEVVM
! stdout upgrade_available
grep '"newest":"0.3.0-rc.2"' $DATA/cache/release.json
ttyin -stdin $WORK/no.txt
! exec $DEVVM
stdout '^==> upgrade_available_prerelease current=0.3.0-rc.1 latest=0.3.0-rc.2$'
release_server 0.3.0 0.3.0-rc.2 0.3.0-rc.1
json_set $DATA/cache/release.json tried=2026-01-01T00:00:00Z
ttyin -stdin $WORK/no.txt
! exec $DEVVM
grep '"newest":"0.3.0"' $DATA/cache/release.json
ttyin -stdin $WORK/no.txt
! exec $DEVVM
stdout '^==> upgrade_available current=0.3.0-rc.1 latest=0.3.0$'
-- no.txt --
n
-- off.toml --
+28 -1
View File
@@ -160,7 +160,7 @@ mkdir Cellar/devvm/0.1.0/bin
cp_exe $DEVVM_BIN/devvm Cellar/devvm/0.1.0/bin/devvm
env PATH=$WORK/brews${:}$PATH
! exec Cellar/devvm/0.1.0/bin/devvm upgrade
stderr '^upgrade_confirm_brew current=0.1.0 version=0.2.0\ndevvm: no_input answer=--force$'
stderr '^upgrade_confirm_brew current=0.1.0 formula=devvm version=0.2.0\ndevvm: no_input answer=--force$'
! exec Cellar/devvm/0.1.0/bin/devvm upgrade --to 0.2.0 --force
stderr '^devvm: upgrade_brew_version$'
! exists brew-calls
@@ -170,6 +170,33 @@ grep '^upgrade devvm$' brew-calls
exec Cellar/devvm/0.1.0/bin/devvm upgrade --json
stdout '"install": "homebrew"'
# Homebrew's devvm-rc, which follows prereleases: its newest release is
# the newest prerelease or release, which brew upgrade devvm-rc installs,
# asked first, and never --to.
env DEVVM_TEST_VERSION=0.2.0-rc.1
release_server 0.1.0 0.2.0-rc.2 0.2.0-rc.1
mkdir Cellar/devvm-rc/0.2.0-rc.1/bin
cp_exe $DEVVM_BIN/devvm Cellar/devvm-rc/0.2.0-rc.1/bin/devvm
env RC=$WORK/Cellar/devvm-rc/0.2.0-rc.1/bin/devvm
exec $RC upgrade --check
stdout '^==> upgrade_available_prerelease current=0.2.0-rc.1 latest=0.2.0-rc.2\n\z'
! exec $RC upgrade
stderr '^upgrade_confirm_brew current=0.2.0-rc.1 formula=devvm-rc version=0.2.0-rc.2\ndevvm: no_input answer=--force$'
! exec $RC upgrade --to 0.2.0-rc.2 --force
stderr '^devvm: upgrade_brew_version$'
rm brew-calls
exec $RC upgrade --force
stdout '^==> upgrade_brew_done\n\z'
grep '^upgrade devvm-rc$' brew-calls
# Once the release is out, it's the newest.
release_server 0.2.0 0.2.0-rc.2 0.2.0-rc.1
exec $RC upgrade --check
stdout '^==> upgrade_available current=0.2.0-rc.1 latest=0.2.0\n\z'
exec $RC upgrade --json
stdout '"latest": "0.2.0"'
stdout '"install": "homebrew"'
-- yes.txt --
y
-- no.txt --