[Backport release-1.7] perf(ci): build release lines from their own cache, in parallel (#5489)

## What this PR does

Port of #5484 to release-1.7. `build-release.yaml` and `tags.yaml` run
from the line's own copy, so the line builds from its own cache only
once it has the change itself. Cherry-picked with `-x`, docs edit goes
to `docs/release.md`.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
perf(ci): release-1.7 builds images from its own build cache, several units at a time
```
This commit is contained in:
Aleksei Sviridkin authored and GitHub committed 2026-12-02 03:53:50 +03:00
commit 6ca411972c
12 files changed
+251 -35

No files matched your search

+14 -12
View File
@@ -3,7 +3,7 @@ name: Build release line
# Publishes the per-line equivalent of what build-main.yaml publishes for main:
# every image tagged with the line's branch name, and the whole packages tree as
# the `cozystack-packages:<branch>` OCI artifact with each image reference
# digest-pinned to the images this run just pushed (`make build` ->
# digest-pinned to the images this run just pushed (`make build-parallel` ->
# packages/core/installer image-packages does the `flux push artifact`).
#
# Why it exists: pull-requests.yaml overlays image refs for every package a PR
@@ -16,9 +16,9 @@ name: Build release line
# artifact published per line, the overlay reads the PR's own base branch and the
# generations match.
#
# Cost: one full `make build` per push to a maintained line, i.e. per merged
# backport. That is the price of release-line PRs testing their line's tip rather
# than its last release.
# Cost: one full `make build-parallel` per push to a maintained line, i.e. per
# merged backport. That is the price of release-line PRs testing their line's
# tip rather than its last release.
env:
# Same per-CI registry as pull-requests.yaml and build-main.yaml.
@@ -139,19 +139,21 @@ jobs:
DOCKER_CONFIG: ${{ runner.temp }}/.docker
- name: Build line images and publish the packages artifact
run: make build
run: make build-parallel
env:
DOCKER_CONFIG: ${{ runner.temp }}/.docker
BUILDER: ${{ steps.buildx.outputs.name }}
# amd64 only, as in build-main.yaml.
PLATFORM: linux/amd64
# READ the shared mode=max cache, never write it. CACHE_REGISTRY/<img>:
# buildcache is a single ref per image and build-main.yaml is
# deliberately its only writer, serialized, precisely so concurrent
# builds cannot race on the cache manifest (the 409 collision class
# #2711 fixed for image tags). A line build can overlap a main build, so
# writing here would reintroduce exactly that race.
WRITE_CACHE: '0'
# The line keeps a mode=max cache of its own, which its rc builds in
# tags.yaml import too: main's cache (:buildcache, written only by
# build-main.yaml) misses more with every Dockerfile main changes after
# the line branched. The concurrency group above runs one build per
# line, so this is the only writer of the line's ref, and main's ref is
# only read.
CACHE_TAG: buildcache-${{ github.ref_name }}
CACHE_FROM_TAGS: buildcache-${{ github.ref_name }} buildcache
WRITE_CACHE: '1'
# Floating per-line handle: images and the packages artifact both land
# under the branch name (e.g. :release-1.6). Versioned and :latest tags
# belong to releases (tags.yaml / finalize), never to this workflow.
+20 -15
View File
@@ -101,6 +101,9 @@ jobs:
with:
driver: docker-container
buildkitd-config: hack/buildkitd.toml
# The runner is thrown away after the job; removing the builder only
# costs time.
cleanup: false
env:
DOCKER_CONFIG: ${{ runner.temp }}/.docker
@@ -108,24 +111,20 @@ jobs:
if: steps.check_release.outputs.release_exists == 'false'
run: |
set -euo pipefail
# Assigned and checked before the loop: a build-matrix.sh failure
# inside `for unit in $(...)` would run no iteration and leave a
# green job that built nothing.
units="$(MATRIX_ARCH=arm64 hack/build-matrix.sh | jq -r '.[]')"
[ -n "$units" ]
for unit in $units; do
make -C "$unit" image
done
# The rc builds are the only arm64 builds a release line has, so they
# keep the line's arm64 cache themselves. They import main's nightly
# cache too, which is all the first rc of a line has.
line="release-$(echo "${GITHUB_REF_NAME#v}" | cut --delimiter=. --fields=1-2)"
export CACHE_TAG="buildcache-arm64-$line"
export CACHE_FROM_TAGS="buildcache-arm64-$line buildcache-arm64"
MATRIX_ARCH=arm64 hack/build-units.sh
make -C packages/core/installer image-operator
env:
DOCKER_CONFIG: ${{ runner.temp }}/.docker
BUILDER: ${{ steps.buildx.outputs.name }}
PLATFORM: linux/arm64
CACHE_REGISTRY: iad.ocir.io/idyksih5sir9/cozystack
# Read the arm64 cache build-arm64-nightly.yaml keeps warm; a release
# build never writes one.
CACHE_TAG: buildcache-arm64
WRITE_CACHE: '0'
WRITE_CACHE: '1'
IMAGE_TAG: ${{ github.ref_name }}-arm64
PUBLISH_VERSIONED: '0'
PUBLISH_FLOATING: '0'
@@ -141,8 +140,8 @@ jobs:
build-amd64:
name: Build amd64 images and assets
# Ephemeral pool, not the dedicated self-hosted runner (#2937 decommission).
# Serial `make build` + `make assets` is CPU-bound, so use the large shape —
# same as the main cache warmer (build-main.yaml).
# `make build-parallel` runs several image builds at once, so use the large
# shape, as the main cache warmer (build-main.yaml) does.
runs-on: oracle-vm-24cpu-96gb-x86-64
# The budget prepare-release had while it also built; the stitch and the
# uploads it no longer runs moved to prepare-release with their own.
@@ -300,6 +299,9 @@ jobs:
driver: docker-container
buildkitd-config: hack/buildkitd.toml
use: false
# The runner is thrown away after the job; removing the builder only
# costs time.
cleanup: false
env:
DOCKER_CONFIG: ${{ runner.temp }}/.docker
@@ -308,7 +310,7 @@ jobs:
if: steps.check_release.outputs.release_exists == 'false'
run: |
mkdir -p "${PUSHED_TAGS_LOG%/*}"
make build
make build-parallel
# The arm64 assets published below install this image, and building
# its arm64 half needs no QEMU, so it is pushed again as both arches.
make -C packages/core/talos image-talos PLATFORM=linux/amd64,linux/arm64
@@ -323,6 +325,9 @@ jobs:
# them from OCIR while pushing images to GHCR. A missing :buildcache
# ref 404s harmlessly into a cold build.
CACHE_REGISTRY: iad.ocir.io/idyksih5sir9/cozystack
# The line's own cache, which build-release.yaml writes on every push
# to the line, and main's.
CACHE_FROM_TAGS: buildcache-release-${{ steps.tag.outputs.line }} buildcache
# amd64 here; build-arm64 builds arm64 natively. This job also
# builds on the default docker driver, which handles a
# multi-platform image only on the containerd image store.