oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1#!/bin/sh
2# make release: build every release artifact from one fixed commit, in a
3# tree of its own, and record provenance only if that is what was built.
4#
5# scripts/release-isolated.sh <goos> <goarch>
6#
7# The checkout you run this from is only asked which commit HEAD is. The
8# build happens in a fresh clone checked out at exactly that commit, under
9# $TMPDIR, so an edit made here while it runs cannot reach a binary. (A
10# clone, not a git worktree: go stamps a binary with its commit only where
11# .git is a directory.) The
12# build tree must be clean and at that commit before the build and again
13# after it, and every binary must say so itself (go version -m:
14# vcs.revision is the commit, vcs.modified is false) before
15# scripts/staged-artifacts.py writes the provenance manifest. Anything
16# else refuses, and nothing is copied into releases/.
17set -eu
18goos=$1
19goarch=$2
20refuse() {
21 echo "refusing to release: $1" >&2
22 exit 1
23}
24commit=$(git rev-parse HEAD)
25version=$(git rev-parse --short HEAD)
26[ -z "$(git status --porcelain)" ] || refuse "refusing to build a release from a dirty tree"
27base=${TMPDIR:-${XDG_CACHE_HOME:-$HOME/.cache}/equipo}
28mkdir -p "$base"
29scratch=$(mktemp -d "$base/equipo-release.XXXXXX")
30tree=$scratch/src
31trap 'rm -rf "$scratch"' EXIT
32trap 'exit 1' HUP INT TERM
33git clone --quiet --no-hardlinks . "$tree"
34(cd "$tree" && git checkout --quiet --detach "$commit")
35# The build tree: at the commit, nothing changed, nothing untracked.
36# Build output (releases/, the instance's bundle) is ignored by git.
37pristine() {
38 (cd "$tree" && [ "$(git rev-parse HEAD)" = "$commit" ] && [ -z "$(git status --porcelain)" ])
39}
40pristine || refuse "the build tree is not a clean checkout of $commit"
41make -C "$tree" --no-print-directory release-in-tree RELEASE_GOOS="$goos" RELEASE_GOARCH="$goarch"
42pristine || refuse "the build tree changed during the build"
43# This checkout may have moved on meanwhile; a release of the commit it
44# named is still wanted only if it still names it, unchanged.
45[ "$(git rev-parse HEAD)" = "$commit" ] && git diff --quiet HEAD || refuse "this checkout changed during the build"
46(cd "$tree" && python3 scripts/staged-artifacts.py manifest "$version" --instance "releases/equipo-$goos-$goarch-$version")
47mkdir -p releases
48cp -R "$tree/releases/." releases/
49echo "built releases/equipo-$goos-$goarch-$version from $commit"
50echo "stage it first (scripts/staging-thin.py build/deploy/runner/suite), then deploy only"
51echo "the exact bytes staging passed, through the drained cutover:"
52echo " make staged-check && scripts/cutover-thin.sh $version"
53