Skip to content

Commit 900485f

Browse files
committed
Release v1.2.0 with single-repo packaging
1 parent 972685a commit 900485f

11 files changed

Lines changed: 452 additions & 219 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,17 @@ jobs:
6666
generate_release_notes: true
6767
files: dist/artifacts/*
6868

69-
sync-homebrew-tap:
69+
refresh-homebrew-formula:
7070
if: startsWith(github.ref, 'refs/tags/v')
7171
needs: package-macos
7272
runs-on: macos-14
7373
permissions:
74-
contents: read
74+
contents: write
7575
steps:
76-
- name: Checkout
76+
- name: Checkout Main
7777
uses: actions/checkout@v4
78+
with:
79+
ref: main
7880

7981
- name: Resolve Version
8082
id: version
@@ -87,53 +89,21 @@ jobs:
8789
curl -L -o "/tmp/mtop-${VERSION}-source.tar.gz" "https://github.com/lxrzlyr/mtop/releases/download/v${VERSION}/mtop-${VERSION}-source.tar.gz"
8890
echo "value=$(shasum -a 256 /tmp/mtop-${VERSION}-source.tar.gz | awk '{print $1}')" >> "$GITHUB_OUTPUT"
8991
90-
- name: Start SSH Agent
91-
uses: webfactory/ssh-agent@v0.9.0
92-
with:
93-
ssh-private-key: ${{ secrets.HOMEBREW_TAP_SSH_KEY }}
94-
95-
- name: Trust GitHub Host Key
96-
run: |
97-
mkdir -p ~/.ssh
98-
ssh-keyscan github.com >> ~/.ssh/known_hosts
99-
100-
- name: Clone Homebrew Tap
101-
run: git clone git@github.com:lxrzlyr/homebrew-mtop.git /tmp/homebrew-mtop
102-
103-
- name: Generate Formula
92+
- name: Update Formula
10493
run: |
105-
./scripts/generate_homebrew_formula.sh \
94+
python3 ./scripts/update_homebrew_formula.py \
95+
./Formula/mtop.rb \
10696
"${{ steps.version.outputs.value }}" \
107-
"${{ steps.sha.outputs.value }}" \
108-
/tmp/homebrew-mtop/Formula/mtop.rb
97+
"${{ steps.sha.outputs.value }}"
10998
110-
- name: Commit And Push
99+
- name: Commit Formula Refresh
111100
run: |
112-
cd /tmp/homebrew-mtop
113101
git config user.name "github-actions[bot]"
114102
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
115103
git add Formula/mtop.rb
116104
if git diff --cached --quiet; then
117-
echo "No tap changes to commit"
105+
echo "Formula already matches release"
118106
exit 0
119107
fi
120-
git commit -m "Update mtop formula to v${{ steps.version.outputs.value }}"
121-
git push origin main
122-
123-
- name: Verify Tap Update
124-
run: |
125-
rm -rf /tmp/homebrew-mtop-verify
126-
git clone git@github.com:lxrzlyr/homebrew-mtop.git /tmp/homebrew-mtop-verify
127-
EXPECTED_VERSION="${{ steps.version.outputs.value }}"
128-
ACTUAL_VERSION=$(python3 - <<'PY'
129-
from pathlib import Path
130-
import re
131-
text = Path('/tmp/homebrew-mtop-verify/Formula/mtop.rb').read_text()
132-
match = re.search(r'/releases/download/v([^/]+)/mtop-([^/]+)-source\.tar\.gz', text)
133-
print(match.group(1) if match else '')
134-
PY
135-
)
136-
if [[ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]]; then
137-
echo "Tap verification failed: expected v${EXPECTED_VERSION}, got v${ACTUAL_VERSION}" >&2
138-
exit 1
139-
fi
108+
git commit -m "Refresh Formula for v${{ steps.version.outputs.value }}"
109+
git push origin HEAD:main

.github/workflows/update-homebrew-tap.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ compile_commands.json
1313
微信图片_*.png
1414
REBUILD_PLAN.md
1515
UPGRADE_PLAN.md
16+
RELEASE_PROCESS.md

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ install(TARGETS mtop RUNTIME DESTINATION bin)
3434

3535
set(CPACK_GENERATOR "TGZ")
3636
set(CPACK_PACKAGE_NAME "mtop")
37-
set(CPACK_PACKAGE_VERSION "1.0.1")
37+
set(CPACK_PACKAGE_VERSION "1.2.0")
3838
include(CPack)
3939

4040
enable_testing()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class Mtop < Formula
22
desc "Apple Silicon terminal monitor for macOS"
33
homepage "https://github.com/lxrzlyr/mtop"
4-
url "https://github.com/lxrzlyr/mtop/releases/download/v1.0.1/mtop-1.0.1-source.tar.gz"
5-
sha256 "d73e5bc8bea54f360bb83994b04d5904aa7392237d7ab7fd9a4f658075853013"
4+
url "https://github.com/lxrzlyr/mtop/releases/download/v1.2.0/mtop-1.2.0-source.tar.gz"
5+
sha256 "1f56fc7f55ae0ba00fd964d103a643b4203a6656ddbeb69dfa5b8cf266f2ac41"
66
license "GPL-3.0-or-later"
77

88
depends_on "cmake" => :build
@@ -14,6 +14,6 @@ def install
1414
end
1515

1616
test do
17-
system "#{bin}/mtop", "--demo"
17+
system "#{bin}/mtop", "--version"
1818
end
1919
end

README.md

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ With root:
8080
- estimated SoC subsystem power from `powermetrics`
8181
- GPU power / frequency enrichment
8282
- process core-class mix derived from `powermetrics`
83+
- process IO and energy-impact columns derived from `powermetrics`
84+
85+
## Process Extension Columns
86+
87+
In root mode, the process table can show three extra columns sourced from `powermetrics`:
88+
89+
- `MIX`: estimated core-class mix for the sampled window, such as `S:12% P:88%`
90+
- `IO`: per-process `Bytes Read / Bytes Written` activity during the sample window, such as `3.9K/7.8K`
91+
- `PWR`: per-process Energy Impact from `powermetrics`
92+
93+
These columns are best-effort and sample-window based, so they should be read with a few caveats:
94+
95+
- `0B/0B` or `0` means the metric was available and the sampled value was zero
96+
- `n/a` means root sampling succeeded, but `powermetrics` did not provide a usable value for that process in that sample
97+
- `wait` means root sampling has not delivered its first background sample yet
98+
- `root` means the column requires `sudo ./build/mtop`
8399

84100
## A Note About `SOC` Power
85101

@@ -216,10 +232,10 @@ This will:
216232
- install into `dist/install`
217233
- produce a `.tar.gz` package through `cpack`
218234

219-
There is also a Homebrew formula stub at:
235+
The repository also includes a Homebrew formula at:
220236

221237
```text
222-
packaging/homebrew/mtop.rb
238+
Formula/mtop.rb
223239
```
224240

225241
## GitHub Actions
@@ -242,38 +258,32 @@ Current workflow file:
242258
Recommended release flow:
243259

244260
1. Push normal commits and use the workflow artifacts to verify packaging.
245-
2. Create a version tag such as `v1.0.1`.
261+
2. Create a version tag such as `v1.2.0`.
246262
3. Push the tag.
247263
4. GitHub Actions will build and attach the package to the release.
248-
5. The same release workflow will update the Homebrew tap and verify the formula matches the new version.
249-
250-
## Homebrew Tap Relationship
251264

252-
`mtop` and `homebrew-mtop` should remain separate repositories.
265+
## Homebrew
253266

254-
- `mtop` is the source repository
255-
- `homebrew-mtop` is the Homebrew tap repository
267+
`mtop` now uses a single-repository Homebrew layout.
256268

257-
That separation is intentional:
269+
- source code, release artifacts, and the Homebrew formula all live in this repository
270+
- the checked-in formula is located at `Formula/mtop.rb`
258271

259-
- some users want to build from source manually
260-
- some users want to install with Homebrew
261-
- the tap should only carry the formula, not the whole source history
272+
This keeps the release flow simpler:
262273

263-
This repository includes a formula generator and a tap sync workflow:
274+
- one release repository to version and debug
275+
- no cross-repository sync job
276+
- no extra deploy key or tap-specific secret
264277

265-
- [scripts/generate_homebrew_formula.sh](./scripts/generate_homebrew_formula.sh)
266-
- [.github/workflows/update-homebrew-tap.yml](./.github/workflows/update-homebrew-tap.yml)
278+
If you want to install from this repository with Homebrew, use:
267279

268-
The tag-based release workflow also performs the tap update and verification step, so the release job fails if the tap does not match the published version.
269-
270-
`update-homebrew-tap.yml` remains available as a manual repair path if a release needs the tap formula to be resynced explicitly.
271-
272-
To enable automatic tap updates, add this secret to the `mtop` GitHub repository:
280+
```bash
281+
brew install lxrzlyr/mtop/mtop
282+
```
273283

274-
- `HOMEBREW_TAP_SSH_KEY`
284+
To refresh the formula for a new version locally, regenerate or update `Formula/mtop.rb` so that its `url` and `sha256` match the new source release asset.
275285

276-
That key should be a deploy key or SSH key with write access to `lxrzlyr/homebrew-mtop`.
286+
The release workflow now only builds, packages, and uploads artifacts for this repository.
277287

278288
## Project Layout
279289

@@ -282,6 +292,7 @@ include/ public headers
282292
src/ C++ / Objective-C++ implementation
283293
docs/ design and platform notes
284294
tests/ test planning and future test code
295+
Formula/ Homebrew formula
285296
packaging/ package metadata
286297
scripts/ helper scripts
287298
```

README.zh-CN.md

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ root 增强模式下:
8080
- 来自 `powermetrics` 的估算 SoC 子系统功耗
8181
- GPU 功率 / 频率增强信息
8282
- 基于 `powermetrics` 推导的进程核心类别混合信息
83+
- 基于 `powermetrics` 的进程 IO 与 Energy Impact 列
84+
85+
## 进程扩展列说明
86+
87+
在 root 模式下,进程表会尝试显示三列来自 `powermetrics` 的扩展信息:
88+
89+
- `MIX`:采样窗口内的核心类别混合估计,例如 `S:12% P:88%`
90+
- `IO`:采样窗口内的进程 `Bytes Read / Bytes Written`,例如 `3.9K/7.8K`
91+
- `PWR`:来自 `powermetrics` 的进程 Energy Impact
92+
93+
这些列都属于 best-effort 的采样窗口指标,阅读时需要注意:
94+
95+
- `0B/0B``0` 表示该指标可用,但本次采样值为零
96+
- `n/a` 表示 root 采样已经成功,但 `powermetrics` 在本次采样里没有给这个进程提供可用值
97+
- `wait` 表示 root 后台采样线程还没有产出第一帧结果
98+
- `root` 表示这一列需要通过 `sudo ./build/mtop` 才能获得
8399

84100
## 关于 `SOC` 功耗
85101

@@ -216,10 +232,10 @@ cmake --install build --prefix /usr/local
216232
- 安装到 `dist/install`
217233
-`cpack` 生成 `.tar.gz`
218234

219-
Homebrew formula stub 在
235+
仓库里也包含 Homebrew formula,位置在
220236

221237
```text
222-
packaging/homebrew/mtop.rb
238+
Formula/mtop.rb
223239
```
224240

225241
## GitHub Actions
@@ -242,33 +258,32 @@ packaging/homebrew/mtop.rb
242258
推荐发布流程:
243259

244260
1. 正常 push 代码,用 workflow artifacts 检查打包结果。
245-
2. 创建版本 tag,例如 `v1.0.1`
261+
2. 创建版本 tag,例如 `v1.2.0`
246262
3. push 这个 tag。
247263
4. GitHub Actions 会自动构建并把包挂到 Release 上。
248264

249-
## Homebrew Tap 的关系
265+
## Homebrew
250266

251-
`mtop` `homebrew-mtop` 应该保持为两个独立仓库
267+
`mtop` 现在采用单仓库的 Homebrew 布局
252268

253-
- `mtop` 是源码仓库
254-
- `homebrew-mtop` 是 Homebrew tap 仓库
269+
- 源码、release 产物和 Homebrew formula 都放在这个仓库里
270+
- 当前公式文件位于 `Formula/mtop.rb`
255271

256-
这样做是有意为之
272+
这样发布链路会更简单
257273

258-
- 有些用户会手动从源码构建
259-
- 有些用户只想通过 Homebrew 安装
260-
- tap 仓库只维护 formula,不需要承载完整源码历史
274+
- 只维护一个 release 仓库
275+
- 不再需要跨仓库同步 workflow
276+
- 不再需要额外 deploy key 或 tap secret
261277

262-
主仓库里已经包含了公式生成脚本和 tap 同步工作流
278+
如果你想直接从这个仓库通过 Homebrew 安装,可以使用
263279

264-
- [scripts/generate_homebrew_formula.sh](./scripts/generate_homebrew_formula.sh)
265-
- [.github/workflows/update-homebrew-tap.yml](./.github/workflows/update-homebrew-tap.yml)
266-
267-
如果你希望在打 tag 后自动更新 tap,需要在 `mtop` 仓库中配置这个 secret:
280+
```bash
281+
brew install lxrzlyr/mtop/mtop
282+
```
268283

269-
- `HOMEBREW_TAP_SSH_KEY`
284+
如果要为新版本更新公式,只需要同步修改 `Formula/mtop.rb` 中的 `url``sha256`,让它们对应新的 source release asset。
270285

271-
这个 key 需要对 `lxrzlyr/homebrew-mtop` 有写权限
286+
当前 release workflow 只负责本仓库的构建、打包和 release 资产上传
272287

273288
## 项目结构
274289

@@ -277,6 +292,7 @@ include/ 公共头文件
277292
src/ C++ / Objective-C++ 实现
278293
docs/ 设计与平台说明
279294
tests/ 测试与测试计划
295+
Formula/ Homebrew formula
280296
packaging/ 打包相关元数据
281297
scripts/ 辅助脚本
282298
```

include/monitor/snapshot.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ struct ProcessSnapshot {
3737
char state = '?';
3838
bool gpu_active = false;
3939
std::string core_mix = "-";
40+
std::string io = "-";
41+
std::string power = "-";
4042
};
4143

4244
struct CapabilitySnapshot {

0 commit comments

Comments
 (0)