Files
mqttx/.gitea/workflows/release.yml
T
JoeAllen 2661a734ee fix(release): 修复 CI 阻断与发布链路,强制版本一致性
- sysmon 采样测试改为分平台断言:此前无条件断言 working_set > 0,非 Windows 上 cargo test 必失败,v* tag 会停在测试阶段(test job 恰好跑在 ubuntu-latest)
- CI test job 补齐 GPUI 的 Linux 系统依赖,--lib --tests 让集成测试参与编译
- meta job 校验 tag 与 gpui-app/Cargo.toml 版本一致:忘 bump 会导致新版本装完仍自报旧版,客户端反复提示同一更新
- 发布脚本:--exact-match 取 tag 并强制 semver 校验(--always 会产出 v1.0.0-4-gbc9f55c 这类客户端 release_part 截断后判定不新的版本,且该 Release 会占据 /releases/latest 遮蔽真更新);Release 创建/查询/解析失败一律 exit 1,不再让 job 变绿而 OTA 通道为空
- sysmon CPU 差分基准只在真正算出结果时前移:采样间隔过近沿用上次读数,修复手点立即刷新永远读到 0%;修正 cpu_percent 注释口径(0~100,整机占比)
- README 订正发布流程:CI 实际仅出 Linux 产物;补 Release 附件(7z/裸二进制/.sha256)这一 OTA 唯一通道与命名约定;token 需 repo 写权限
2026-09-30 10:14:18 +08:00

159 lines
6.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Gitea Actions:打 tag 时构建 release 产物并发布到 Gitea Package Registry。
#
# 依赖的仓库 Secrets/Variables(Settings → Actions → Secrets):
# GITEA_TOKEN — 包写权限令牌(package scope),用于上传 Generic 包
# 可选 GITEA_OWNER — 软件包所属用户/组织,缺省用仓库 owner
#
# 说明:Gitea Actions 语法与 GitHub Actions 兼容;若 runner 使用自定义
# label(如 `ubuntu`),请把 runs-on 改成你的 runner labels。
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
# ─── 版本与元信息 ─────────────────────────────────────────────
meta:
name: Meta
runs-on: ubuntu-latest
outputs:
version: ${{ steps.ver.outputs.version }}
owner: ${{ steps.ver.outputs.owner }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: ver
run: |
version="${GITHUB_REF_NAME}"
echo "version=${version}" >> "$GITHUB_OUTPUT"
owner="${GITEA_OWNER_OVERRIDE:-${GITHUB_REPOSITORY_OWNER}}"
echo "owner=${owner}" >> "$GITHUB_OUTPUT"
# 版本双真源校验:tag 必须与 gpui-app/Cargo.toml 一致。否则新包装完仍自报旧
# 版本号,客户端表现为"每次都提示同一个更新",装多少次都消不掉。
- name: Verify tag matches Cargo.toml version
run: |
tag="${GITHUB_REF_NAME}"
cargo_ver="$(grep -m1 '^version' gpui-app/Cargo.toml | cut -d'"' -f2)"
if [ -z "$cargo_ver" ]; then
echo "::error::无法从 gpui-app/Cargo.toml 解析版本号"
exit 1
fi
if [ "v${cargo_ver}" != "$tag" ]; then
echo "::error::tag(${tag}) 与 gpui-app/Cargo.toml(v${cargo_ver}) 不一致:请先 bump 版本再打 tag"
exit 1
fi
echo "版本一致:${tag}"
# ─── 测试 ─────────────────────────────────────────────────────
# 与 build 一样要完整编译 lib(GPUI 会链接 Linux 系统库),缺库会在链接期失败。
# 此前该 job 未安装任何依赖,叠加 sysmon 的跨平台断言缺陷,v* tag 必停在测试阶段。
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install Linux system deps (GPUI)
run: |
sudo apt-get update
sudo apt-get install -y \
libxcb1-dev libxkbcommon-dev libxkbcommon-x11-dev \
libwayland-dev libasound2-dev libfontconfig-dev \
libx11-dev libxcursor-dev libxrandr-dev libxi-dev
# --tests:让 tests/engine_live.rs 参与编译(#[ignore] 只跳过执行,不跳过编译)
- name: Unit tests
run: cargo test -p mqttx-desktop --lib --tests
# ─── 构建矩阵 ─────────────────────────────────────────────────
# 目前 Gitea 实例只注册了 ubuntu-latest 标签的 Linux runner,
# Windows 产物由本地 scripts/publish-gitea.ps1/.sh 上传补充。
build:
name: Build (${{ matrix.os }})
needs: [meta, test]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
asset: mqttx
target: x86_64-unknown-linux-gnu
# runner 就绪后可恢复 Windows 构建:
# - os: windows-latest
# asset: mqttx.exe
# target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
- name: Install Linux system deps (GPUI)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
libxcb1-dev libxkbcommon-dev libxkbcommon-x11-dev \
libwayland-dev libasound2-dev libfontconfig-dev \
libx11-dev libxcursor-dev libxrandr-dev libxi-dev
- name: Build
run: cargo build --release -p mqttx-desktop --target ${{ matrix.target }}
- name: Stage artifact
shell: bash
run: |
out="dist-${{ matrix.target }}"
mkdir -p "$out"
src="target/${{ matrix.target }}/release/${{ matrix.asset }}"
ver="${{ needs.meta.outputs.version }}"
dst="$out/mqttx-${ver}-${{ matrix.target }}-${{ matrix.asset }}"
cp "$src" "$dst"
if command -v sha256sum >/dev/null; then
sha256sum "$dst" > "$dst.sha256"
else
shasum -a 256 "$dst" > "$dst.sha256"
fi
echo "ASSET_DIR=$out" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v4
with:
name: mqttx-${{ matrix.target }}
path: ${{ env.ASSET_DIR }}/*
# ─── 发布到 Gitea Package Registry ────────────────────────────
publish:
name: Publish package
needs: [meta, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Upload to Generic Package Registry
env:
GITEA_URL: ${{ github.server_url }}
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_OWNER: ${{ needs.meta.outputs.owner }}
GITEA_PKG: mqttx
run: |
chmod +x scripts/publish-gitea.sh
files=(artifacts/*)
# 过滤掉 .sha256 侧车文件,脚本会自行生成
upload=()
for f in "${files[@]}"; do
case "$f" in *.sha256) ;; *) upload+=("$f") ;; esac
done
./scripts/publish-gitea.sh "${upload[@]}" "${{ needs.meta.outputs.version }}"