Repository navigation
192 lines (173 loc) · 9.4 KB
/
Copy pathrelease.yml
File metadata and controls
192 lines (173 loc) · 9.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Release
# One tarball, one version, and the version names a day rather than a semantic promise.
#
# CalVer — v20260909.01 — because that is what a release of this repository is: the machine
# as it stood on a date. There is no API here to promise compatibility about, and the one
# thing a version could promise — that checkpoints still resume — is decided by the
# fingerprint and not by a number anybody chose. A major version bump
# would say something this repository cannot mean.
#
# The `.01` is the run within the day, because two releases on one day is normal when a
# flag is being chased.
#
# A release is made from main and nothing else: dispatched there, it names its version, builds,
# signs and attests as release.yml@refs/heads/main - the one identity whoever takes the release
# holds its files to - and only then tags the commit. A pushed tag starts nothing.
on:
workflow_dispatch:
inputs:
version:
description: "Release version, e.g. v20260909.01. Left empty, one is generated for today."
required: false
type: string
permissions:
contents: write
# Keyless signing: cosign asks Sigstore for a short-lived certificate bound to this workflow at
# this ref, which is what a machine that takes the release holds its files to.
id-token: write
# The BuildKit cache main's lanes write (internal/build.CacheRegistry), read here and by compat,
# which a called workflow can be granted no more than its caller holds.
packages: read
# One release at a time. The version is decided at the start of a run by counting the tags
# already taken today and pushed at the end, so two runs at once both generate .01 and the
# loser finds out at `git tag`, after the whole build.
concurrency:
group: release
cancel-in-progress: false
jobs:
# A checkpoint of the release before resumes on this one, when the two have one fingerprint,
# and the fingerprint accounts for every ROM the machine maps: on the KVM runner, before
# anything is built here to publish (compat.yml says why).
compat:
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/compat.yml
release:
needs: compat
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
# A warm run reads main's BuildKit cache and takes a few minutes (2m13s, 2026-09-30). The
# ceiling is for the cold one, which compiles QEMU and the kernel, each tens of minutes.
timeout-minutes: 180
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# The whole history and the tags: the version below counts the tags already
# taken today, and a shallow clone would count zero and hand out .01 twice.
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
# spin-machine-dev built and on the PATH, so a step's exit status is the verb's (go run makes
# it 1): the verbs below are the ones a person types (docs/cli.md).
- name: spin-machine-dev
run: go tool task bin
# What main's lanes already compiled is read, not compiled again: the BuildKit caches are the
# lanes' (--cache-registry); a cold release compiles QEMU and the kernel, each tens of
# minutes, which the ceiling above is for.
#
# A builder of its own (the docker-container driver): Docker's default one cannot export its
# cache. What it reads and writes is the cache image in GitHub's registry that the build
# names (--cache-registry), so the runner itself keeps nothing between runs.
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
# The cache is one of this repository's packages, and reading it takes a login as much as
# writing it does. Without one BuildKit says it could not import the cache, carries on
# without it, and the build passes at the cold time.
- name: Log in to GitHub Packages
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Two sources, in order: what the caller typed, or a new one for today. The generated form is deliberately not `date +%s` or a commit
# hash — it has to be readable, sortable, and the same shape as one typed by hand.
# The caller's input arrives through the environment and not through ${{ }} in the
# script body. Interpolation happens before the shell sees the line, so a version
# containing a quote or a semicolon would be pasted into the script rather than
# assigned to a variable — and it is validated below, which is after that would have
# mattered.
- name: Decide the version
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
run: spin-machine-dev release version --given "$INPUT_VERSION"
# Builds all four artefacts and packs them, refusing to produce a tarball with anything
# missing. A release that installs and then fails for want of an option ROM is worse than
# no release. The caches are the ones the per-artefact workflows write on main, named by
# the build itself: a release reads what the lane on main already paid to compile, and
# writes nothing back - it is built once, and the next one reads main's newer cache.
- name: Build the release
env:
VERSION: ${{ steps.version.outputs.version }}
run: spin-machine-dev release --version "$VERSION" --jobs 4 --cache-registry --cache-export=false
# The machine's identity, and what it costs whoever holds checkpoints.
#
# The alternative is opening two release pages and comparing sixty-four hex digits by eye,
# which is a thing nobody does — so the answer to "why did every checkpoint in the fleet
# stop resuming?" is one nobody has. The notes fetch the previous release's machine.env
# and state the consequence in a sentence, at the top, where a consumer deciding whether
# to take this release reads it.
#
# The verdict never fails: a changed machine is a release this repository makes on
# purpose. The point is not to prevent it but to keep it from being quiet.
- name: What this release is, and what it breaks
id: manifest
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
run: spin-machine-dev release notes --version "$VERSION"
# v4 is the one that installs cosign v3. Dependabot moves this pin like every other `uses:`.
- name: Install cosign
uses: sigstore/cosign-installer@756fe2d284c7292c4e9b62c8a28f1e5629c59532 # v4.1.3
# Who built each file and from what - this workflow at this commit, every pin in
# versions.yaml - as SLSA provenance, beside the signature that says who made it. The
# predicate has no clock in it, so it is the same for every file of the run.
- name: Write the provenance
env:
VERSION: ${{ steps.version.outputs.version }}
run: spin-machine-dev release provenance --version "$VERSION"
# Each file is signed and attested, then each bundle checked against the identity that made
# it, file by file: a bundle nothing verifies is a step that can quietly stop working.
- name: Sign and attest what the release offers
env:
IDENTITY: ${{ github.server_url }}/${{ github.repository }}/.github/workflows/release.yml@${{ github.ref }}
run: spin-machine-dev release sign --identity "$IDENTITY"
# Tagged here, after the files are signed and before they are published, so that the next
# run's count of "tags already taken today" is right and the tarball has a commit behind it.
# A version tagged already is refused here: git push does not move a tag.
- name: Tag the commit
env:
VERSION: ${{ steps.version.outputs.version }}
GH_TOKEN: ${{ github.token }}
run: spin-machine-dev release tag --version "$VERSION"
- name: Publish
uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3.0.4
with:
tag_name: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
body: ${{ steps.manifest.outputs.notes }}
# machine.env is published on its own, and not only inside the tarball, so the
# next release can read it back in a few hundred bytes and say whether it
# strands the checkpoints taken against this one.
files: |
_output/release/*.tar.gz
_output/release/*.tar.gz.sha256
_output/release/machine.env
_output/release/*.cdx.json
_output/release/*.sigstore.json
# The release just published, booted beside the ones before it on one bench host: the goal's
# two numbers release by release, as ladder.json beside it and a table at the end of its notes.
# report.yml says why it is a job of its own, on its own runner.
report:
needs: release
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/report.yml
with:
version: ${{ needs.release.outputs.version }}
ref: ${{ needs.release.outputs.version }}
publish: true
secrets: inherit