-
Notifications
You must be signed in to change notification settings - Fork 0
495 lines (433 loc) · 18.1 KB
/
Copy pathrelease.yml
File metadata and controls
495 lines (433 loc) · 18.1 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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
name: release
on:
push:
tags:
- "v*.*.*-r*"
permissions:
contents: write
models: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
RELEASE_NOTES_MODEL: openai/gpt-4o-mini
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: true
jobs:
prepare:
if: github.event.deleted == false
runs-on: ubuntu-24.04
outputs:
tag: ${{ steps.meta.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
build_number: ${{ steps.meta.outputs.build_number }}
sources_hash: ${{ steps.meta.outputs.sources_hash }}
steps:
- uses: actions/checkout@v6
- id: meta
shell: bash
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
if [[ ! "$tag" =~ ^v([0-9]+[.][0-9]+[.][0-9]+)-r([0-9]+)$ ]]; then
printf '::error::Release tags must match v<version>-rN, for example v0.16.0-r1\n'
exit 1
fi
version="${BASH_REMATCH[1]}"
build_number="${BASH_REMATCH[2]}"
if [[ ! -d "$version" ]]; then
printf '::error::Version directory %s does not exist\n' "$version"
exit 1
fi
sources_hash="$(
sha256sum "$version/llvm-project" "$version/zig-bootstrap" |
sha256sum |
awk '{ print $1 }'
)"
{
printf 'tag=%s\n' "$tag"
printf 'version=%s\n' "$version"
printf 'build_number=%s\n' "$build_number"
printf 'sources_hash=%s\n' "$sources_hash"
} >>"$GITHUB_OUTPUT"
build:
needs: prepare
runs-on: ${{ matrix.runner }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-linux-gnu
mcpu: baseline
runner: ubuntu-24.04
- target: x86_64-macos-none
mcpu: baseline
runner: ubuntu-24.04
- target: aarch64-macos-none
mcpu: baseline
runner: ubuntu-24.04
- target: x86_64-windows-gnu
mcpu: baseline
runner: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Cache downloaded sources
uses: actions/cache@v4
with:
path: ${{ needs.prepare.outputs.version }}/.downloads
key: downloads-${{ runner.os }}-${{ needs.prepare.outputs.version }}-${{ needs.prepare.outputs.sources_hash }}
restore-keys: downloads-${{ runner.os }}-${{ needs.prepare.outputs.version }}-
- name: Install Mach-O compact unwind header
shell: bash
run: |
set -euo pipefail
append_include_path() {
local name="$1"
local current="${!name:-}"
if [[ -n "$current" ]]; then
printf '%s=%s:%s\n' "$name" "$include_dir" "$current" >>"$GITHUB_ENV"
else
printf '%s=%s\n' "$name" "$include_dir" >>"$GITHUB_ENV"
fi
}
include_dir="$RUNNER_TEMP/mach-o-headers"
mkdir -p "$include_dir/mach-o"
curl -fsSL \
https://raw.githubusercontent.com/llvm/llvm-project/llvmorg-21.1.3/libunwind/include/mach-o/compact_unwind_encoding.h \
-o "$include_dir/mach-o/compact_unwind_encoding.h"
append_include_path CPATH
append_include_path C_INCLUDE_PATH
append_include_path CPLUS_INCLUDE_PATH
- name: Build Zig
id: build
shell: bash
run: |
set -euo pipefail
./bootstrap.sh "${{ needs.prepare.outputs.version }}" "${{ matrix.target }}" "${{ matrix.mcpu }}"
- name: Package artifact
id: package
shell: bash
run: |
set -euo pipefail
./release.sh "${{ needs.prepare.outputs.version }}" "${{ matrix.target }}" "${{ matrix.mcpu }}" \
--build-number "${{ needs.prepare.outputs.build_number }}"
- name: Upload packaged artifact
uses: actions/upload-artifact@v4
with:
name: zig-${{ needs.prepare.outputs.tag }}-${{ matrix.target }}-${{ matrix.mcpu }}
path: release/${{ needs.prepare.outputs.tag }}/zig-${{ needs.prepare.outputs.tag }}-${{ matrix.target }}-${{ matrix.mcpu }}.tar.xz
if-no-files-found: error
- name: Report skipped target
if: failure()
shell: bash
run: |
printf '::warning::Skipping %s/%s because build or packaging failed\n' \
"${{ matrix.target }}" "${{ matrix.mcpu }}"
build-large-targets:
needs: prepare
runs-on:
group: Default
continue-on-error: true
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-linux-gnu
mcpu: baseline
- target: aarch64-windows-gnu
mcpu: baseline
steps:
- uses: actions/checkout@v6
- name: Cache downloaded sources
uses: actions/cache@v4
with:
path: ${{ needs.prepare.outputs.version }}/.downloads
key: downloads-${{ runner.os }}-${{ needs.prepare.outputs.version }}-${{ needs.prepare.outputs.sources_hash }}
restore-keys: downloads-${{ runner.os }}-${{ needs.prepare.outputs.version }}-
- name: Install Mach-O compact unwind header
shell: bash
run: |
set -euo pipefail
append_include_path() {
local name="$1"
local current="${!name:-}"
if [[ -n "$current" ]]; then
printf '%s=%s:%s\n' "$name" "$include_dir" "$current" >>"$GITHUB_ENV"
else
printf '%s=%s\n' "$name" "$include_dir" >>"$GITHUB_ENV"
fi
}
include_dir="$RUNNER_TEMP/mach-o-headers"
mkdir -p "$include_dir/mach-o"
curl -fsSL \
https://raw.githubusercontent.com/llvm/llvm-project/llvmorg-21.1.3/libunwind/include/mach-o/compact_unwind_encoding.h \
-o "$include_dir/mach-o/compact_unwind_encoding.h"
append_include_path CPATH
append_include_path C_INCLUDE_PATH
append_include_path CPLUS_INCLUDE_PATH
- name: Build Zig
id: build
shell: bash
run: |
set -euo pipefail
./bootstrap.sh "${{ needs.prepare.outputs.version }}" "${{ matrix.target }}" "${{ matrix.mcpu }}"
- name: Package artifact
id: package
shell: bash
run: |
set -euo pipefail
./release.sh "${{ needs.prepare.outputs.version }}" "${{ matrix.target }}" "${{ matrix.mcpu }}" \
--build-number "${{ needs.prepare.outputs.build_number }}"
- name: Upload packaged artifact
uses: actions/upload-artifact@v4
with:
name: zig-${{ needs.prepare.outputs.tag }}-${{ matrix.target }}-${{ matrix.mcpu }}
path: release/${{ needs.prepare.outputs.tag }}/zig-${{ needs.prepare.outputs.tag }}-${{ matrix.target }}-${{ matrix.mcpu }}.tar.xz
if-no-files-found: error
- name: Report skipped target
if: failure()
shell: bash
run: |
printf '::warning::Skipping %s/%s because build or packaging failed\n' \
"${{ matrix.target }}" "${{ matrix.mcpu }}"
release:
needs:
- prepare
- build
- build-large-targets
if: always() && needs.prepare.result == 'success'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download packaged artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Find previous release tag
id: previous-tag
shell: bash
run: |
set -euo pipefail
current="${{ needs.prepare.outputs.tag }}"
previous="$(
git tag --list 'v*.*.*-r*' --sort=-v:refname |
awk -v current="$current" '
$0 == current { seen = 1; next }
seen { print; exit }
'
)"
printf 'base_ref=%s\n' "$previous" >>"$GITHUB_OUTPUT"
- name: Validate release notes inputs
shell: bash
run: |
set -euo pipefail
if [[ -z "${{ steps.previous-tag.outputs.base_ref }}" ]]; then
printf '::error::Previous v<version>-rN tag is required for release notes base-ref\n'
exit 1
fi
- name: Prepare grouped release note inputs
shell: bash
run: |
set -euo pipefail
base_ref="${{ steps.previous-tag.outputs.base_ref }}"
head_ref="${{ needs.prepare.outputs.tag }}"
version_dir="${{ needs.prepare.outputs.version }}"
context_dir="dist/release-context"
mkdir -p "$context_dir"
release_note_paths=(
.github/workflows/release.yml
release.sh
README.md
AGENTS.md
RELEASE.md
.gitignore
bootstrap.sh
"$version_dir/README.md"
"$version_dir/regression/README.md"
"$version_dir/.gitignore"
"$version_dir/llvm-project"
"$version_dir/zig-bootstrap"
"$version_dir/patches"
"$version_dir/regression/run.sh"
"$version_dir/regression/cases"
)
git log --no-merges --format='- %s (%h)' "$base_ref..$head_ref" >"$context_dir/commits.md"
git diff --name-status "$base_ref..$head_ref" -- "${release_note_paths[@]}" >"$context_dir/files.txt"
git diff --stat "$base_ref..$head_ref" -- "${release_note_paths[@]}" >"$context_dir/diff-stat.txt"
write_group_prompt() {
local group="$1"
local title="$2"
shift 2
local prompt="$context_dir/${group}.prompt.md"
local diff_file="$context_dir/${group}.diff"
git diff --unified=20 "$base_ref..$head_ref" -- "$@" >"$diff_file" || true
{
printf 'You are preparing one section of release notes for esp-zig-bootstrap.\n'
printf 'Summarize only user-relevant changes in this group. Ignore noisy mechanical patch context unless it changes behavior.\n'
printf 'Use concise markdown bullets. Do not mention files that did not change.\n'
printf 'Do not wrap the response in a markdown code fence.\n'
if [[ "$group" == "regression-tests" ]]; then
printf 'Regression tests are supporting validation, not the main product. Summarize test coverage areas in at most three bullets; do not list individual test case names.\n'
elif [[ "$group" == "xtensa-patches" ]]; then
printf 'Focus on shipped Xtensa compiler/toolchain behavior, not patch file mechanics.\n'
elif [[ "$group" == "ci-release" ]]; then
printf 'Focus on release automation behavior visible to maintainers and users.\n'
fi
printf '\n'
printf 'Release range: `%s..%s`\n' "$base_ref" "$head_ref"
printf 'Group: %s\n\n' "$title"
printf 'Changed files in this group:\n'
git diff --name-status "$base_ref..$head_ref" -- "$@" || true
printf '\nOverall commit log:\n'
cat "$context_dir/commits.md"
printf '\nDiff for this group, truncated if necessary:\n'
python3 -c 'import pathlib, sys; data = pathlib.Path(sys.argv[1]).read_text(errors="replace"); limit = 120000; sys.stdout.write(data if len(data) <= limit else data[:limit] + "\n\n[diff truncated]\n")' "$diff_file"
} >"$prompt"
}
write_group_prompt ci-release "CI and release automation" \
.github/workflows/release.yml release.sh
write_group_prompt docs "Documentation" \
README.md AGENTS.md RELEASE.md "$version_dir/README.md" "$version_dir/regression/README.md"
write_group_prompt version-inputs "Version inputs and bootstrap support" \
.gitignore bootstrap.sh "$version_dir/.gitignore" "$version_dir/llvm-project" "$version_dir/zig-bootstrap"
write_group_prompt xtensa-patches "Xtensa downstream patch set" \
"$version_dir/patches"
write_group_prompt regression-tests "Xtensa regression tests" \
"$version_dir/regression/run.sh" "$version_dir/regression/cases"
- name: Summarize CI and release changes
id: notes-ci-release
uses: actions/ai-inference@v1
with:
prompt-file: dist/release-context/ci-release.prompt.md
model: ${{ env.RELEASE_NOTES_MODEL }}
max-tokens: 700
- name: Summarize documentation changes
id: notes-docs
uses: actions/ai-inference@v1
with:
prompt-file: dist/release-context/docs.prompt.md
model: ${{ env.RELEASE_NOTES_MODEL }}
max-tokens: 700
- name: Summarize version input changes
id: notes-version-inputs
uses: actions/ai-inference@v1
with:
prompt-file: dist/release-context/version-inputs.prompt.md
model: ${{ env.RELEASE_NOTES_MODEL }}
max-tokens: 700
- name: Summarize Xtensa patch changes
id: notes-xtensa-patches
uses: actions/ai-inference@v1
with:
prompt-file: dist/release-context/xtensa-patches.prompt.md
model: ${{ env.RELEASE_NOTES_MODEL }}
max-tokens: 900
- name: Summarize regression test changes
id: notes-regression-tests
uses: actions/ai-inference@v1
with:
prompt-file: dist/release-context/regression-tests.prompt.md
model: ${{ env.RELEASE_NOTES_MODEL }}
max-tokens: 700
- name: Prepare final release notes prompt
shell: bash
run: |
set -euo pipefail
{
printf 'You are writing final release notes for esp-zig-bootstrap.\n'
printf 'This is a Zig %s toolchain release with downstream ESP Xtensa support.\n' "${{ needs.prepare.outputs.version }}"
printf 'Turn the grouped summaries into concise user-facing markdown.\n'
printf 'Keep meaningful technical details, but remove duplication and internal workflow noise.\n'
printf 'Use these sections exactly: "## Highlights", "## Changes", "## Notes".\n'
printf 'The first non-empty line must be "## Highlights". Do not wrap the response in a markdown code fence.\n'
printf 'Prioritize, in order: shipped toolchain/version support, Xtensa compiler/backend changes, release automation, validation coverage.\n'
printf 'Mention regression tests only as validation coverage; do not list individual regression test files or case names.\n'
printf 'Do not include artifacts; they are appended separately.\n\n'
printf 'Release: `%s`\n' "${{ needs.prepare.outputs.tag }}"
printf 'Source commit: `%s`\n\n' "$GITHUB_SHA"
printf 'Commit log:\n'
cat dist/release-context/commits.md
printf '\nChanged files:\n'
cat dist/release-context/files.txt
printf '\nDiff stat:\n'
cat dist/release-context/diff-stat.txt
printf '\n\nGrouped AI summaries:\n\n'
printf '### CI and release automation\n'
cat "${{ steps.notes-ci-release.outputs.response-file }}"
printf '\n\n### Documentation\n'
cat "${{ steps.notes-docs.outputs.response-file }}"
printf '\n\n### Version inputs and bootstrap support\n'
cat "${{ steps.notes-version-inputs.outputs.response-file }}"
printf '\n\n### Xtensa downstream patch set\n'
cat "${{ steps.notes-xtensa-patches.outputs.response-file }}"
printf '\n\n### Xtensa regression tests\n'
cat "${{ steps.notes-regression-tests.outputs.response-file }}"
printf '\n'
} >dist/release-context/final.prompt.md
- name: Generate final release notes
id: final-notes
uses: actions/ai-inference@v1
with:
prompt-file: dist/release-context/final.prompt.md
model: ${{ env.RELEASE_NOTES_MODEL }}
max-tokens: 1400
- name: Prepare release payload
env:
FINAL_RELEASE_NOTES_FILE: ${{ steps.final-notes.outputs.response-file }}
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
artifacts=(dist/*.tar.xz)
if [[ ${#artifacts[@]} -eq 0 ]]; then
printf '::error::No release artifacts were downloaded\n'
exit 1
fi
(
cd dist
sha256sum *.tar.xz >SHA256SUMS
)
cleaned_notes="dist/AI_RELEASE_NOTES.md"
python3 - "$FINAL_RELEASE_NOTES_FILE" "$cleaned_notes" <<'PY'
import pathlib
import re
import sys
source = pathlib.Path(sys.argv[1])
target = pathlib.Path(sys.argv[2])
notes = source.read_text(errors="replace").strip()
notes = re.sub(r"\A```(?:markdown|md)?\s*\n", "", notes, flags=re.IGNORECASE)
notes = re.sub(r"\n```\s*\Z", "", notes).strip()
target.write_text(notes + "\n")
PY
if [[ ! -s "$cleaned_notes" ]]; then
printf '::error::AI release notes output is empty\n'
exit 1
fi
{
printf 'Automated release for `%s`.\n\n' "${{ needs.prepare.outputs.tag }}"
printf 'Source commit: `%s`\n\n' "$GITHUB_SHA"
cat "$cleaned_notes"
printf '\n\n## Artifacts\n\n'
for artifact in "${artifacts[@]}"; do
printf -- '- `%s`\n' "$(basename "$artifact")"
done
} >dist/RELEASE_NOTES.md
- name: Replace GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
shell: bash
run: |
set -euo pipefail
tag="${{ needs.prepare.outputs.tag }}"
if gh release view "$tag" >/dev/null 2>&1; then
gh release delete "$tag" --yes
fi
gh release create "$tag" \
dist/*.tar.xz \
dist/SHA256SUMS \
--title "$tag" \
--notes-file dist/RELEASE_NOTES.md