Skip to content

Commit 1cf54e3

Browse files
committed
打 tag 时用同一条矩阵产出可发布的归档
⚠️ 不另开一个 release 工作流:一个由与测试不同的步骤构建出来的 release,是一个没有人 测过的 release。tag 触发同一条五宿主矩阵,跑完全部检查之后才附加归档。 归档命名按**索引**而不是按本仓库:xim 描述符从 ${version} 与平台/arch 对拼 URL,所以 文件名必须能由这两者推出来 —— 沿用 qemu-riscv 的 linux/darwin/win32 与 x64/arm64 拼法。 只有本工作流看得懂的名字会逼描述符去特判。 侧文件的哈希在这里从**真正被上传的那个归档**算出,而不是事后从下载物重算。 ⚠️ shasum -a 256 兜底:macOS 没有 sha256sum,而这一行的代价是在一条已经跑了四十分钟 的腿上少一次失败。
1 parent 26aa94c commit 1cf54e3

1 file changed

Lines changed: 52 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ name: five hosts
2929
on:
3030
push:
3131
branches: [main]
32+
# ⚠️ A TAG BUILDS THE SAME FIVE LEGS AND PUBLISHES THEM. The matrix is not
33+
# duplicated into a separate release workflow: a release built by different
34+
# steps from the ones that were tested is a release nobody tested.
35+
tags: ['[0-9]+.[0-9]+.[0-9]+*']
3236
pull_request:
3337
workflow_dispatch:
3438

@@ -44,6 +48,8 @@ jobs:
4448
name: qemu-system-x86_64 on ${{ matrix.label }}
4549
runs-on: ${{ matrix.os }}
4650
timeout-minutes: 90
51+
permissions:
52+
contents: write # the tag path attaches archives to the release
4753
strategy:
4854
fail-fast: false
4955
matrix:
@@ -521,8 +527,52 @@ jobs:
521527
du -sh out/* 2>/dev/null | sort -rh | head -10
522528
du -sh out/share/* 2>/dev/null | sort -rh | head -10
523529
530+
# ── The publishable archive ────────────────────────────────────────
531+
#
532+
# ⚠️ NAMED FOR THE INDEX, NOT FOR THIS REPOSITORY. `xim`'s descriptor
533+
# builds the URL from `${version}` and a platform/arch pair, so the file
534+
# name has to be derivable from those alone — `qemu-x86-<ver>-<host>.<ext>`
535+
# with the same `linux`/`darwin`/`win32` and `x64`/`arm64` spellings
536+
# `qemu-riscv` uses. A name only this workflow understands would force the
537+
# descriptor to special-case it.
538+
#
539+
# The sidecar carries the same hash the descriptor will quote, computed
540+
# here from the archive that is actually uploaded rather than recomputed
541+
# later from a download.
542+
- name: Pack the archive
543+
shell: bash
544+
run: |
545+
set -euo pipefail
546+
V="${GITHUB_REF_NAME}"
547+
case "$V" in refs/*|main) V="${QEMU_VERSION}" ;; esac
548+
NAME="qemu-x86-${V}-${{ matrix.label }}"
549+
mkdir -p dist
550+
if [ "$RUNNER_OS" = "Windows" ]; then
551+
( cd out && 7z a -tzip "../dist/${NAME}.zip" . > /dev/null )
552+
F="dist/${NAME}.zip"
553+
else
554+
tar czf "dist/${NAME}.tar.gz" -C out .
555+
F="dist/${NAME}.tar.gz"
556+
fi
557+
# ⚠️ `shasum -a 256` rather than `sha256sum`: macOS has the former and
558+
# not the latter, and a fallback chain here is one line against a leg
559+
# that would otherwise fail after a 40-minute build.
560+
if command -v sha256sum > /dev/null; then sha256sum "$F" > "$F.sha256";
561+
else shasum -a 256 "$F" > "$F.sha256"; fi
562+
ls -l dist/
563+
cat "$F.sha256"
564+
524565
- uses: actions/upload-artifact@v4
525566
with:
526-
name: qemu-system-x86_64-${{ matrix.label }}
527-
path: out
567+
name: qemu-x86-${{ matrix.label }}
568+
path: dist
528569
retention-days: 14
570+
571+
# ⚠️ ONLY ON A TAG, AND ONLY AFTER THE CHECKS ABOVE. A leg that built but
572+
# did not produce a runnable emulator must not reach a release.
573+
- name: Publish to the release
574+
if: startsWith(github.ref, 'refs/tags/')
575+
uses: softprops/action-gh-release@v2
576+
with:
577+
files: dist/*
578+
fail_on_unmatched_files: true

0 commit comments

Comments
 (0)