#!/bin/sh set -eu source=$1 output=$2 target_os=$3 target_arch=$4 version=$5 bundle=internal/release/bundled # An existing directory belongs to another build. Never remove or reuse it. mkdir "$bundle" trap 'rm -rf "$bundle"' EXIT trap 'exit 1' HUP INT TERM # The page renderer (renderer.tar.gz) is not bundled: the Linux runner # fetches it from its forge release (internal/release RendererForge). The # platform caps one ship at 256 MiB, and the renderer alone is ~230 MB. for name in install-manifest.json equipo-runner equipo-tool-proxy gitleaks install-v1.sh; do cp "$source/$name" "$bundle/$name" done # The Mac worker's runner, served under darwin-arm64/ (it has no tool proxy). mkdir "$bundle/darwin-arm64" for name in equipo-runner gitleaks; do cp "$source/darwin-arm64/$name" "$bundle/darwin-arm64/$name" done # Everything embedded stays well under the ship cap (a bound, not the cap). bundled=$(du -sb "$bundle" | cut -f 1) if [ "$bundled" -gt $((160 << 20)) ]; then echo "build-instance-release: the bundle is $bundled bytes, over 160 MiB" >&2 exit 1 fi # The instance serves only the tool proxy of its own build: its digest is # linked in, as it is into the runners (Makefile, RELEASE_LDFLAGS). proxy=$(sha256sum "$source/equipo-tool-proxy" | cut -d ' ' -f 1) ldflags="-s -w -X amadan.net/rastrillo/rastrillo.BuildVersion=$version -X amadan.net/oficina/equipo/internal/release.toolProxySHA256=$proxy" # Exercise the same manifest and digest checks as the download handler. EQUIPO_BUNDLE_VERSION="$version" CGO_ENABLED=0 go test -tags runnerassets -ldflags "$ldflags" ./internal/release -run '^TestBundledInstallAssets$' -count=1 CGO_ENABLED=0 GOOS="$target_os" GOARCH="$target_arch" go build -tags runnerassets -trimpath \ -ldflags "$ldflags" \ -o "$output" ./cmd/equipo