Repository navigation
316 lines (290 loc) · 13.9 KB
/
Copy pathrelease.yml
File metadata and controls
316 lines (290 loc) · 13.9 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: Release
on:
workflow_dispatch:
inputs:
recover_tag:
description: Recover a verified release without moving its tag
required: true
type: choice
options:
- v9.2.0
- v9.3.0
- v9.5.0
push:
branches:
- main
tags:
- 'v*'
permissions:
contents: read
jobs:
decide:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
publish: ${{ steps.resolve.outputs.publish }}
tag: ${{ steps.resolve.outputs.tag }}
recovery: ${{ steps.resolve.outputs.recovery }}
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Resolve release tag
id: resolve
shell: bash
env:
RECOVERY_TAG: ${{ inputs.recover_tag }}
run: |
set -euo pipefail
version="$(node -p "require('./package.json').version")"
tag="v${version}"
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
if [[ "${GITHUB_REF}" != "refs/heads/main" || "${RECOVERY_TAG}" != "${tag}" || ( "${RECOVERY_TAG}" != "v9.2.0" && "${RECOVERY_TAG}" != "v9.3.0" && "${RECOVERY_TAG}" != "v9.5.0" ) ]]; then
echo "::error::Release recovery requires main and a pinned exact release tag."
exit 1
fi
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "recovery=true" >> "$GITHUB_OUTPUT"
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
if [[ "${GITHUB_REF_NAME}" != "${tag}" ]]; then
echo "::error::Release tag/version mismatch: tag=${GITHUB_REF_NAME}, package.json=${version}."
exit 1
fi
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "recovery=false" >> "$GITHUB_OUTPUT"
else
echo "publish=false" >> "$GITHUB_OUTPUT"
echo "recovery=false" >> "$GITHUB_OUTPUT"
fi
verify-main-and-tag:
needs: decide
runs-on: ubuntu-latest
timeout-minutes: 30
env:
FLOW_RELEASE_PUBLISH: ${{ needs.decide.outputs.publish }}
FLOW_RELEASE_RECOVERY_TAG: ${{ needs.decide.outputs.recovery == 'true' && needs.decide.outputs.tag || '' }}
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26
package-manager-cache: false
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.0
- name: Install dependencies
timeout-minutes: 5
run: bun install --frozen-lockfile
- name: Run deterministic checks
timeout-minutes: 10
run: bun run check
- name: Rebuild release candidate
timeout-minutes: 2
shell: bash
run: |
set -euo pipefail
version="$(node -p "require('./package.json').version")"
if [[ "$version" == "9.4.0" ]]; then
bun run scripts/prepare-qualified-release-940.ts --out "opencode-plugin-flow-${version}.tgz"
else
bun pm pack --destination .
if [[ -n "${FLOW_RELEASE_RECOVERY_TAG}" || "$version" == "9.5.0" || "$version" == "9.6.0" ]]; then
case "${FLOW_RELEASE_RECOVERY_TAG:-v${version}}" in
v9.2.0)
sealed="evals/qualification/bundles/qb1-d281a9952f3267c9dad8071bb2add667679bf741f2d1357e7b18d2e325e75349/objects/sha256-0af07377229cd23d5f1ec7fd666666bc58ffda94348fce4d0070af0a05d6f80b"
digest="sha256:0af07377229cd23d5f1ec7fd666666bc58ffda94348fce4d0070af0a05d6f80b"
;;
v9.3.0)
sealed="evals/qualification/bundles/qb1-eec4c369d749432abd26cd5e9197124761463c8d6460908a95fc9dd887d38e75/objects/sha256-5635502fd5f56ff160edcb78bc8b1d34fb2545e3aaf20fac4f25272f7cdbed9f"
digest="sha256:5635502fd5f56ff160edcb78bc8b1d34fb2545e3aaf20fac4f25272f7cdbed9f"
;;
v9.5.0)
qualified="$(bun scripts/materialize-qualification.ts --descriptor evals/qualification/archives/9.5.0.json --out "${RUNNER_TEMP}/flow-qualified-950")"
sealed="${qualified}/objects/sha256-03970e413588b9b32fb2c38ab859352c8c56c8a1937c64c6ca5d440cc96371cd"
digest="sha256:03970e413588b9b32fb2c38ab859352c8c56c8a1937c64c6ca5d440cc96371cd"
;;
v9.6.0)
qualified="$(bun scripts/materialize-qualification.ts --descriptor evals/qualification/archives/9.6.0.json --out "${RUNNER_TEMP}/flow-qualified-960")"
sealed="${qualified}/objects/sha256-71ad6adcbdb6f0650a230a9494242d346e9c344c7c3e84d8ae32cb8e5c7bc7ec"
digest="sha256:71ad6adcbdb6f0650a230a9494242d346e9c344c7c3e84d8ae32cb8e5c7bc7ec"
;;
*) exit 1 ;;
esac
bun run scripts/restore-exact-release-artifact.ts \
"opencode-plugin-flow-${version}.tgz" "$sealed" "$digest"
fi
fi
if [[ "${FLOW_RELEASE_PUBLISH:-false}" == "true" ]] && node -e 'process.exit(Number(process.argv[1].split(".")[0]) >= 10 ? 0 : 1)' "$version" && [[ -f "evals/qualification/archives/${version}.json" ]]; then
qualified="$(bun scripts/materialize-qualification.ts --descriptor "evals/qualification/archives/${version}.json" --out "${RUNNER_TEMP}/flow-qualified-${version}")"
bun run scripts/restore-exact-release-artifact.ts \
"opencode-plugin-flow-${version}.tgz" --bundle "$qualified" "$version"
fi
- name: Report release evidence readiness without publishing
timeout-minutes: 5
shell: bash
run: |
set -euo pipefail
version="$(node -p "require('./package.json').version")"
tarball="$(ls opencode-plugin-flow-*.tgz)"
bun run release:metadata -- --artifact "$tarball"
if [[ "$version" == "9.4.0" && -f "evals/qualification/archives/${version}.json" ]]; then
bun run release:metadata -- --tag "v${version}" --artifact "$tarball" --canary "evals/canary/${version}.json"
bun run eval:canary -- verify --artifact "$tarball" --mode strict
elif [[ -n "${FLOW_RELEASE_RECOVERY_TAG}" ]]; then
bun run release:metadata -- --tag "$FLOW_RELEASE_RECOVERY_TAG" --artifact "$tarball" --canary "evals/canary/${FLOW_RELEASE_RECOVERY_TAG#v}.json"
bun run eval:canary -- verify --artifact "$tarball" --mode strict
else
bun run eval:canary -- verify --artifact "$tarball" --mode dry-run
fi
release:
needs: [decide, verify-main-and-tag]
if: needs.decide.outputs.publish == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
env:
FLOW_RELEASE_RECOVERY_TAG: ${{ needs.decide.outputs.recovery == 'true' && needs.decide.outputs.tag || '' }}
concurrency:
group: release-publication
cancel-in-progress: false
permissions:
contents: write
actions: read
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false
- name: Set up npm trusted publishing support
timeout-minutes: 5
run: |
npm install --global npm@11.18.0
node --version
npm --version
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.0
- name: Install dependencies
timeout-minutes: 5
run: bun install --frozen-lockfile
- name: Run checks
timeout-minutes: 10
run: bun run check
- name: Run pinned live OpenCode smoke
timeout-minutes: 5
run: bun run smoke:live
- name: Replay recorded decisions without models
run: bun run replay
- name: Prepare package
timeout-minutes: 2
shell: bash
run: |
set -euo pipefail
version="$(node -p "require('./package.json').version")"
if [[ "$version" == "9.4.0" ]]; then
bun run scripts/prepare-qualified-release-940.ts --out "opencode-plugin-flow-${version}.tgz"
else
bun pm pack --destination .
if [[ -n "${FLOW_RELEASE_RECOVERY_TAG}" || "$version" == "9.5.0" || "$version" == "9.6.0" ]]; then
case "${FLOW_RELEASE_RECOVERY_TAG:-v${version}}" in
v9.2.0)
sealed="evals/qualification/bundles/qb1-d281a9952f3267c9dad8071bb2add667679bf741f2d1357e7b18d2e325e75349/objects/sha256-0af07377229cd23d5f1ec7fd666666bc58ffda94348fce4d0070af0a05d6f80b"
digest="sha256:0af07377229cd23d5f1ec7fd666666bc58ffda94348fce4d0070af0a05d6f80b"
;;
v9.3.0)
sealed="evals/qualification/bundles/qb1-eec4c369d749432abd26cd5e9197124761463c8d6460908a95fc9dd887d38e75/objects/sha256-5635502fd5f56ff160edcb78bc8b1d34fb2545e3aaf20fac4f25272f7cdbed9f"
digest="sha256:5635502fd5f56ff160edcb78bc8b1d34fb2545e3aaf20fac4f25272f7cdbed9f"
;;
v9.5.0)
qualified="$(bun scripts/materialize-qualification.ts --descriptor evals/qualification/archives/9.5.0.json --out "${RUNNER_TEMP}/flow-qualified-950")"
sealed="${qualified}/objects/sha256-03970e413588b9b32fb2c38ab859352c8c56c8a1937c64c6ca5d440cc96371cd"
digest="sha256:03970e413588b9b32fb2c38ab859352c8c56c8a1937c64c6ca5d440cc96371cd"
;;
v9.6.0)
qualified="$(bun scripts/materialize-qualification.ts --descriptor evals/qualification/archives/9.6.0.json --out "${RUNNER_TEMP}/flow-qualified-960")"
sealed="${qualified}/objects/sha256-71ad6adcbdb6f0650a230a9494242d346e9c344c7c3e84d8ae32cb8e5c7bc7ec"
digest="sha256:71ad6adcbdb6f0650a230a9494242d346e9c344c7c3e84d8ae32cb8e5c7bc7ec"
;;
*) exit 1 ;;
esac
bun run scripts/restore-exact-release-artifact.ts \
"opencode-plugin-flow-${version}.tgz" "$sealed" "$digest"
fi
fi
if node -e 'process.exit(Number(process.argv[1].split(".")[0]) >= 10 ? 0 : 1)' "$version" && [[ ! -f "evals/qualification/patches/${version}.json" && ! -f "evals/qualification/features/${version}.json" ]]; then
qualified="$(bun scripts/materialize-qualification.ts --descriptor "evals/qualification/archives/${version}.json" --out "${RUNNER_TEMP}/flow-qualified-${version}")"
bun run scripts/restore-exact-release-artifact.ts \
"opencode-plugin-flow-${version}.tgz" --bundle "$qualified" "$version"
fi
- name: Restore release record from this workflow run
id: restore
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
count="$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts?per_page=100" --jq 'if .total_count > 100 then error("Artifact inventory exceeds limit") else [.artifacts[] | select(.name == "release-state" and .expired == false)] | length end')"
if [ "$count" = 1 ]; then
gh run download "$GITHUB_RUN_ID" --name release-state --dir .release-state
echo "restored=true" >> "$GITHUB_OUTPUT"
elif [ "$count" != 0 ]; then
echo "::error::Ambiguous release-state artifact."
exit 1
elif [ "$GITHUB_RUN_ATTEMPT" != 1 ]; then
echo "::error::Prior release record is unavailable. Inspect the previous attempt before creating a new record."
exit 1
fi
- name: Verify selected release evidence
timeout-minutes: 5
shell: bash
run: |
set -euo pipefail
version="$(node -p "require('./package.json').version")"
tarball="$(ls opencode-plugin-flow-*.tgz)"
evidence=(--canary "evals/canary/${version}.json")
if [ -f "evals/qualification/features/${version}.json" ]; then
if [ -f "evals/qualification/patches/${version}.json" ]; then
echo "::error::Conflicting offline qualification records."
exit 1
fi
evidence=(--feature "evals/qualification/features/${version}.json")
elif [ -f "evals/qualification/patches/${version}.json" ]; then
evidence=(--patch "evals/qualification/patches/${version}.json")
fi
commit="${GITHUB_SHA}"
if [[ -n "${FLOW_RELEASE_RECOVERY_TAG}" ]]; then
commit="$(git rev-parse "${FLOW_RELEASE_RECOVERY_TAG}^{commit}")"
fi
bun run scripts/release.ts init .release-state \
--artifact "$tarball" \
"${evidence[@]}" \
--commit "$commit"
- name: Persist release record before publication
if: steps.restore.outputs.restored != 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-state
path: .release-state/
include-hidden-files: true
if-no-files-found: error
retention-days: 90
- name: Resume verified publication
timeout-minutes: 20
env:
GH_TOKEN: ${{ github.token }}
run: bun run scripts/release.ts resume .release-state
- name: Report release state
if: always()
run: bun run scripts/release.ts status .release-state