Skip to content

feat: add Homebrew formula and Scoop manifest with automated release workflow - #1

Open
NanamiMio wants to merge 2 commits into
pt-plugins:masterfrom
NanamiMio:master
Open

feat: add Homebrew formula and Scoop manifest with automated release workflow#1
NanamiMio wants to merge 2 commits into
pt-plugins:masterfrom
NanamiMio:master

Conversation

@NanamiMio

Copy link
Copy Markdown

Summary

This PR adds native package manager support for Homebrew (macOS / Linux) and Scoop (Windows), along with automated manifest updates in the GitHub Actions release workflow.

1. Homebrew Formula (Formula/ptd-cli.rb)

  • Pre-compiled binary distribution for 4 target architectures:
    • macOS: aarch64-apple-darwin (Apple Silicon), x86_64-apple-darwin (Intel)
    • Linux: aarch64-unknown-linux-gnu (ARM64), x86_64-unknown-linux-gnu (x86_64)
  • Zero build dependencies (rust/llvm not required), instant installation in < 1s.
  • Installs both ptd and ptd-host.
  • Written using an idiomatic SHA256S Map structure.

2. Scoop Manifest (bucket/ptd-cli.json)

  • Direct binary zip distribution for Windows x86_64-pc-windows-msvc.
  • Includes autoupdate and checkver configuration.

3. Automated Release Workflow (.github/workflows/release.yml)

  • Automatically computes SHA256 checksums for all 5 release artifacts upon release / tag push.
  • In-place updates Formula/ptd-cli.rb and bucket/ptd-cli.json with the new version and SHA256 hashes.
  • Commits and pushes both manifest updates in a single atomic commit [skip ci].
  • Keeps source files as the single source of truth without duplicating templates.

4. Documentation

  • Updated README.md and README.en.md with installation commands:
    # Homebrew
    brew tap pt-plugins/ptd-cli https://github.com/pt-plugins/ptd-cli
    brew install ptd-cli
    
    # Scoop
    scoop bucket add ptd-cli https://github.com/pt-plugins/ptd-cli
    scoop install ptd-cli

概述(中文)

本 PR 为 ptd-cli 增加了 Homebrew (macOS/Linux)Scoop (Windows) 包管理器支持,并集成了 Release CI 自动更新机制:

  1. Homebrew Formula (Formula/ptd-cli.rb):支持 macOS 及 Linux 的 ARM64 与 x86_64 预编译二进制分发,0 构建依赖,秒级安装。
  2. Scoop Manifest (bucket/ptd-cli.json):支持 Windows 64位预编译 Zip 安装与自动更新检测。
  3. Release CI 自动化 (.github/workflows/release.yml):发版时自动计算各平台 SHA256,原地更新 Formula 与 Scoop Manifest,并在单次原子 Commit 内推回主分支。
  4. 文档更新:更新中英文 README 中的安装指南。

@Rhilip
Rhilip requested a review from LeiShi1313 August 21, 2026 12:14
@NanamiMio
NanamiMio marked this pull request as draft August 24, 2026 08:24
Add Homebrew and Scoop packaging, make native host manifests use package-manager-stable paths, and publish all supported binaries through a single manually dispatched release workflow.

Co-authored-by: Codex <codex@openai.com>

@LeiShi1313 LeiShi1313 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for five blocking issues: Linux binary compatibility, the bootstrap release mismatch, non-retryable publishing, workflow token scope, and the release-trigger regression. Verification completed: Rust tests and actionlint passed; all seeded hashes match v0.1.0; the Homebrew formula installed but its runtime test failed with GLIBC_2.39 not found; GitHub reports no CI checks.

Comment thread .github/workflows/release.yml Outdated

- name: Build
run: cargo build --release --target ${{ matrix.target }}
run: cargo build --release --target "${{ matrix.target }}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical: The Linux artifact built by this job is not portable to Ubuntu 22.04. I installed the checked-in formula in Homebrew's official Ubuntu 22.04 container; brew test failed because the v0.1.0 executable requires GLIBC_2.39, while that environment provides 2.35. Building the GNU targets on ubuntu-latest (currently Ubuntu 24.04) preserves that compatibility floor. Please build Linux artifacts against an explicit supported baseline or use musl/static targets, then add a smoke test that runs the extracted binary and brew test on the oldest supported Linux environment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 48e3783. Both GNU Linux targets now build on explicit ubuntu-22.04 runners instead of ubuntu-latest. The compatibility job also runs the extracted x86_64 package on Ubuntu 22.04, installs the rendered formula through a temporary Homebrew tap, and runs brew test. The complete real release run passed here: https://github.com/NanamiMio/ptd-cli-release-test/actions/runs/32728854010

Comment thread Formula/ptd-cli.rb Outdated
class PtdCli < Formula
desc "CLI for PT-Depiler browser extension via Native Messaging"
homepage "https://github.com/pt-plugins/ptd-cli"
version "0.1.0"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both new package manifests bootstrap from v0.1.0, but that tag points at the PR base (98fab8b) and predates the PTD_NATIVE_HOST_PATH handling added by this PR. The first Homebrew/Scoop-installed binary therefore ignores the stable path supplied by the package manager and records its canonicalized, version-specific installation path; after an upgrade and cleanup, the browser manifest can point at a removed ptd-host. Please stage this rollout so the stable-path code is released first and the package definitions/docs target that release, or provide a package-level stable launcher that does not depend on the new binary behavior. Verify install -> register -> upgrade -> cleanup and confirm the recorded host still exists.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 48e3783 by staging the rollout. The public v0.1.0 formula and Scoop manifest were removed; only non-public templates are checked in, and public manifests are generated after a new release has uploaded and verified all assets. The formula records opt_libexec/ptd-host, while Scoop expands $dir after link_current, so it records the stable apps/ptd-cli/current/ptd-host.exe junction. PTD_NATIVE_HOST_PATH is preserved rather than canonicalized, so upgrade cleanup does not turn it into a removed version directory. The standalone RC release successfully generated and installed the staged Homebrew formula: https://github.com/NanamiMio/ptd-cli-release-test/releases/tag/v0.1.4-rc.1

git config user.email "github-actions[bot]@users.noreply.github.com"
git add Cargo.toml Cargo.lock Formula/ptd-cli.rb bucket/ptd-cli.json
git commit -m "chore(release): prepare ${TAG} [skip ci]"
git push origin HEAD:${{ github.event.repository.default_branch }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sequence is not atomic or safely retryable. Once this push succeeds, a later tag or release failure leaves public manifests pointing to assets that do not exist. If the tag push succeeds but gh release create fails or uploads only some assets, the next run is rejected by the existing-tag check and requires manual repair. Please make each external write idempotent and avoid publishing manifest URLs until all release assets have been verified. Verification should inject a failure after each branch/tag/release mutation and show that rerunning reaches a complete release without manual cleanup.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 48e3783. The workflow no longer creates or rejects an existing tag: it starts from the existing GitHub Release, uploads every asset with --clobber, verifies every expected asset name, and only then renders and pushes the public manifests. A failure before the manifest commit leaves no public package URL; a failure after any asset upload is recoverable by rerunning. I ran the complete release once and then reran the same workflow without deleting the tag, release, assets, or manifests; both attempts completed successfully: https://github.com/NanamiMio/ptd-cli-release-test/actions/runs/32728854010

steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.source_sha }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security: contents: write is currently workflow-wide, and checkout v4 persists the token by default. This means every matrix build runs Cargo dependencies and build scripts with push-capable Git credentials even though only publish needs to mutate the repository. Please default the workflow to contents: read, add persist-credentials: false to the prepare/build checkouts, and grant contents: write only to the publish job. Verify that an authenticated push from a build job is rejected while publishing still succeeds.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 48e3783. Workflow-level permissions now default to contents: read; prepare, build, and compatibility checkouts use persist-credentials: false; only the publish job receives contents: write. The standalone end-to-end release run confirms that the restricted build jobs complete and the job-scoped publisher can still upload assets and push the manifest commit: https://github.com/NanamiMio/ptd-cli-release-test/actions/runs/32728854010

on:
release:
types: [created]
workflow_dispatch:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the existing release.created entry point and adds neither a release nor tag trigger, so creating a GitHub release through the previous workflow no longer builds or uploads anything. It also conflicts with the PR description's claim that updates happen on release/tag pushes. Please retain a compatible trigger, or obtain explicit maintainer consent for the breaking release-process migration and update the PR/release documentation accordingly. Verify the selected release event actually starts the workflow.

@NanamiMio NanamiMio Aug 25, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 48e3783. The compatible release.created trigger is restored, while manual dispatch remains build/test-only. I verified the event independently in the standalone release-test repository with a minimal workflow on its temporary default branch; the log records action=created and completed successfully: https://github.com/NanamiMio/ptd-cli-release-test/actions/runs/32801398025

Co-authored-by: Codex <codex@openai.com>
@NanamiMio

NanamiMio commented Aug 25, 2026

Copy link
Copy Markdown
Author

Addressed all five blocking review items in 48e3783:

  1. Linux GNU artifacts now build on Ubuntu 22.04, with packaged-binary and Homebrew install/test coverage on that baseline.
  2. The v0.1.0 bootstrap manifests are no longer public. Formula/Scoop files are rendered only after the first compatible release, and both use stable Native Host paths.
  3. Publishing is recoverable: assets are uploaded with --clobber and verified before manifests become public; rerunning the same release succeeds without manual cleanup.
  4. The workflow defaults to contents: read, build checkouts do not persist credentials, and write access is scoped to the publish job.
  5. release.created is restored and was independently verified in the standalone release-test repository.

Verification:

@NanamiMio
NanamiMio marked this pull request as ready for review August 25, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants