fix: drop the GitHub Actions cache layer, keep the tool cache lookup

Review found that the GitHub Actions cache layer cost more than it
saved. Measured on ubuntu-latest, same job, same version:

  cold: download + checksum + cosign + extract   0.93 s
  cache hit: restore the 24 MB entry             1.28 s
  first run also pays a save                    +2.26 s

It is slower than a download in every configuration measured, because a
GitHub-hosted runner reaches the release CDN in about 0.4 s for a 15 MB
archive, and the cached entry is the larger extracted directory.

It also skipped the sha256 and cosign verification on a hit, which is
the control it was supposed to protect, and the only case where it wins
on time is when cosign is installed, which is exactly the case where
skipping is wrong. It cost 875 KB (+120%) of dist/index.js for every
user and 24 MB of repository cache quota per version and platform.

The restore and save wrappers were also dead code: @actions/cache
catches everything except ValidationError internally, so the try/catch
and the ReserveCacheError classification could never run.

What remains is the runner tool cache lookup, which is what #476 asked
for, and the distribution-keyed tool name that stops a Pro binary being
returned for an OSS install.

The tool cache test asserted that two installs return the same path, but
that path is a pure function of the tool, version and architecture: it
passed even with the tool cache wiped between the calls. It now asserts
that the second install reports a tool cache hit and does not download,
and it was verified to fail when the lookup is removed.

Co-authored-by: timbretimber <105982513+timbretimber@users.noreply.github.com>
Co-authored-by: Akkuman <akkumans@qq.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4eaf86fa-a85b-41f6-8763-612acc1ccc39
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2026-08-29 17:56:44 -03:00
co-authored by timbretimber Akkuman Copilot
parent df0896bb77
commit 7c44e618e7
12 changed files with 52 additions and 1770 deletions
+13 -23
View File
@@ -220,33 +220,24 @@ steps:
### Cache the binary
The action always looks for GoReleaser in the [runner tool cache][toolcache]
first. That cache is kept between jobs on self-hosted runners only, so on
GitHub-hosted runners every job downloads and verifies the release again.
The action looks for GoReleaser in the [runner tool cache][toolcache] before it
downloads. A second use of the action in the same job, or any job on a
self-hosted runner that already has the version, installs immediately.
Set `cache-binary` to store the binary in the [GitHub Actions cache][ghcache]
as well. Later jobs then restore it instead of downloading the release archive,
the checksums and the signature bundle again:
A binary taken from the tool cache is not verified again, because the checksum
and the cosign signature were verified when it was first written. On a
self-hosted runner the tool cache is kept between jobs, so it must be trusted
like the runner itself. GitHub-hosted runners start with an empty tool cache in
every job, so they always download and verify.
```yaml
steps:
-
name: Install GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
version: '~> v2'
install-only: true
cache-binary: true
```
The cache entry is written per distribution, version, operating system and
architecture, and it counts against the [cache size limit][ghcachelimit] of your
repository. Cache errors are not fatal: the action logs a warning and falls back
to a download.
The action does not use the [GitHub Actions cache][ghcache]. It was measured and
it is slower than a download: restoring the 24 MB entry takes about 1.3 s, while
downloading, verifying the checksum, verifying the cosign signature and
extracting the release takes about 0.9 s on a GitHub-hosted runner. It would
also skip the verification it is supposed to protect.
[toolcache]: https://github.com/actions/toolkit/tree/main/packages/tool-cache
[ghcache]: https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/cache-dependencies
[ghcachelimit]: https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#usage-limits-and-eviction-policy
## Customizing
@@ -262,7 +253,6 @@ Following inputs can be used as `step.with` keys
| `args` | String | | Arguments to pass to GoReleaser |
| `workdir` | String | `.` | Working directory (below repository root) |
| `install-only` | Bool | `false` | Just install GoReleaser |
| `cache-binary` | Bool | `false` | Cache the GoReleaser binary in the GitHub Actions cache (see below) |
> **¹** Can be a fixed version like `v0.117.0` or a max satisfying semver one like `~> 0.132`. In this case this will return `v0.132.1`.
>