Skip to content

Conversation

@kjanat
Copy link
Owner

@kjanat kjanat commented Nov 4, 2025

This pull request adds automated publishing workflows and package metadata to support distribution of the bun-docs-mcp-proxy via crates.io, npm, and Arch Linux (AUR). It also introduces a cross-platform npm package with a post-install script that downloads pre-built binaries for various platforms, and improves documentation and metadata for easier installation and discovery.

Automated publishing and packaging:

  • Added GitHub Actions workflows to automatically publish the Rust crate to crates.io and the npm package to npmjs.org when a new tag is pushed. This ensures releases are distributed to both Rust and Node.js users seamlessly.

npm package support:

  • Introduced a new npm/package.json defining the npm package, including metadata, binary entry point, and a postinstall script for downloading platform-specific binaries.
  • Added a robust cross-platform npm/scripts/install.js script that automatically downloads and extracts the correct binary for the user's OS/architecture during npm install, with fallback instructions for unsupported platforms.
  • Created npm/.npmignore to exclude native binaries from the npm package, ensuring only the wrapper and installer scripts are shipped.
  • Added a comprehensive npm/README.md with installation instructions, usage, supported platforms, and alternative installation methods.

Rust crate metadata and packaging:

  • Enhanced Cargo.toml with repository, homepage, keywords, categories, and metadata for cargo-binstall, improving discoverability and enabling binary distribution via cargo-binstall. [1] [2]

Arch Linux packaging:

  • Added a PKGBUILD file for Arch Linux users, enabling installation from the AUR and providing build, test, and packaging steps for the proxy.

- Add crates.io metadata (repository, keywords, categories) to Cargo.toml
- Add cargo-binstall support for fast binary installation
- Create PKGBUILD for Arch Linux (AUR) distribution
- Create npm wrapper package with automatic binary downloader
- Update .gitignore to include npm/bin directory

Publishing options now available:
- cargo install bun-docs-mcp-proxy (from source)
- cargo binstall bun-docs-mcp-proxy (pre-built binaries)
- npm install -g bun-docs-mcp-proxy (Node.js users)
- yay -S bun-docs-mcp-proxy (Arch Linux)
- Add publish-npm job that runs after GitHub release is created
- Update npm install.js to use correct archive naming from releases
- Add support for Windows zip extraction via PowerShell
- Add .npmignore to exclude binaries (downloaded via postinstall)
- npm package downloads appropriate binary during postinstall

When a tag is pushed, the workflow will:
1. Build binaries for all platforms
2. Create GitHub Release with binaries
3. Publish to crates.io
4. Publish to npm (package downloads from GitHub Releases)
@kjanat kjanat self-assigned this Nov 4, 2025
@kjanat kjanat added the enhancement New feature or request label Nov 4, 2025
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@claude

This comment was marked as outdated.

@claude

This comment was marked as outdated.

@kjanat
Copy link
Owner Author

kjanat commented Nov 4, 2025

@claude what about:

@claude
Copy link

claude bot commented Nov 4, 2025

Claude finished @kjanat's task —— View job


Analysis of Additional Packaging Tools

Great question! Let me analyze how these tools would fit with your current PR:

  • Research cargo-bundle
  • Research cargo-deb
  • Research cargo-aur
  • Evaluate fit with current PR
  • Provide recommendation

Tool Analysis

1. cargo-bundle (crates.io)

Purpose: Creates platform-specific application bundles (macOS .app, Windows installers, Linux .deb/.rpm)

Pros:

  • Creates native macOS .app bundles with proper metadata
  • Can generate Windows installers (MSI)
  • Handles Linux packages (.deb, .rpm)

Cons:

  • Last updated 2+ years ago - maintenance concerns
  • Overlaps significantly with your current GitHub Actions workflow
  • Your current approach (pre-built binaries via GitHub Releases) is more lightweight and flexible

Recommendation: ❌ Skip - Your GitHub Actions workflow already provides cross-platform binaries. cargo-bundle adds complexity without significant benefit for a CLI tool.


2. cargo-deb (crates.io)

Purpose: Creates Debian/Ubuntu .deb packages directly from Cargo.toml

Pros:

  • Actively maintained (updated regularly)
  • Well-integrated with Cargo - metadata in Cargo.toml
  • Simpler than manual dpkg-buildpackage
  • Native installation for Debian/Ubuntu users (apt install)
  • Professional distribution channel for Debian-based distros

Cons:

  • Adds build complexity to CI
  • Requires additional metadata in Cargo.toml
  • Only benefits Debian/Ubuntu users

Recommendation: ✅ Consider adding - This would provide a professional installation path for Debian/Ubuntu users. It's complementary to your existing solutions:

  • npm: For Node.js ecosystem
  • cargo-binstall: For Rust users wanting quick binary installs
  • cargo-deb: For Debian/Ubuntu native package management
  • PKGBUILD: For Arch users

3. cargo-aur (crates.io)

Purpose: Automates AUR package generation and submission for Arch Linux

Pros:

  • Automates PKGBUILD generation from Cargo.toml
  • Can automatically submit to AUR
  • Reduces manual maintenance of PKGBUILD

Cons:

  • You already have a manual PKGBUILD in this PR
  • Last significant update was 1+ year ago
  • Manual PKGBUILD gives you more control
  • AUR submission should be deliberate, not automated

Recommendation: ⚠️ Skip for now - Your manual PKGBUILD (already in this PR) is better for the following reasons:

  1. You have full control over the package structure
  2. Manual PKGBUILD is the standard for AUR packages
  3. AUR maintainers generally prefer manually maintained PKGBUILDs
  4. cargo-aur automation could cause issues if it generates incorrect metadata

Summary & Recommendations

Tool Status Reason
cargo-bundle ❌ Skip Redundant with GitHub Actions workflow, unmaintained
cargo-deb ✅ Consider Adds professional Debian/Ubuntu support, actively maintained
cargo-aur ❌ Skip Manual PKGBUILD (already in PR) is preferred

Implementation Suggestion

If you want to add cargo-deb, here's what you'd need:

  1. Add metadata to Cargo.toml:
[package.metadata.deb]
maintainer = "Your Name <your.email@example.com>"
copyright = "2025, Your Name <your.email@example.com>"
depends = "$auto"
section = "utility"
priority = "optional"
assets = [
    ["target/release/bun-docs-mcp-proxy", "usr/bin/", "755"],
    ["README.md", "usr/share/doc/bun-docs-mcp-proxy/", "644"],
    ["LICENSE", "usr/share/doc/bun-docs-mcp-proxy/", "644"],
]
  1. Add to release workflow (.github/workflows/release.yml):
- name: Install cargo-deb
  run: cargo install cargo-deb

- name: Build .deb package
  run: cargo deb --target x86_64-unknown-linux-gnu

- name: Upload .deb to release
  # Add to release artifacts
  1. Benefits:
    • Debian/Ubuntu users can install via dpkg -i or add to their own APT repository
    • Professional distribution for enterprise Linux environments
    • Proper dependency tracking (though this project has minimal deps)

Final Recommendation

For this PR: Keep it as-is with the current scope (crates.io, npm, AUR via PKGBUILD, cargo-binstall). This already provides excellent multi-platform coverage.

Future enhancement: Consider adding cargo-deb in a separate PR if you get requests from Debian/Ubuntu users who prefer native .deb packages over direct binary downloads.

Skip: cargo-bundle (unmaintained, redundant) and cargo-aur (manual PKGBUILD is better).


- Add cargo-deb metadata to Cargo.toml for .deb package generation
- Add cargo-aur metadata to Cargo.toml for AUR package generation
- Create package-deb job in release workflow (x86_64 and ARM64)
- Create package-aur job to generate PKGBUILD and source tarball
- Update release job to include .deb packages and AUR artifacts
- Update release notes with package manager installation options

Distribution options now include:
- Debian/Ubuntu: .deb packages for x86_64 and ARM64
- Arch Linux: Auto-generated PKGBUILD and source tarball
- All packages include attestations and checksums

Users can install with:
- cargo install bun-docs-mcp-proxy (from source)
- cargo binstall bun-docs-mcp-proxy (pre-built)
- npm install -g bun-docs-mcp-proxy (Node.js)
- sudo dpkg -i bun-docs-mcp-proxy_x86_64.deb (Debian/Ubuntu)
- makepkg -si (Arch Linux, using included PKGBUILD)
@claude

This comment was marked as outdated.

CRITICAL SECURITY FIXES:
- Add SHA256 checksum verification to npm install script (npm/scripts/install.js:98-153)
  * Downloads SHA256SUMS file from release
  * Calculates checksum of downloaded archive
  * Verifies before extraction to prevent supply chain attacks
- Remove manual PKGBUILD with sha256sums=('SKIP')
  * cargo-aur auto-generates PKGBUILD with proper checksums
  * Eliminates conflicting sources of truth

HIGH PRIORITY FIXES:
- Fix cargo-binstall URL template mismatch (Cargo.toml:70-94)
  * Add platform-specific overrides to match actual release naming
  * e.g., linux-x86_64 instead of x86_64-unknown-linux-gnu
  * Ensures `cargo binstall` can correctly locate binaries
- Add verification step before npm publish (release.yml:310-324)
  * Waits 30s for release asset propagation
  * Verifies SHA256SUMS and key binaries are accessible
  * Prevents race condition where npm package publishes before binaries are available

IMPROVEMENTS:
- Update Node.js engine requirement from >=14 to >=18 (Node 14 EOL April 2023)
- Improve error handling in extract functions
  * Separate try/catch blocks for extraction vs binary location
  * More specific error messages for each failure mode
  * Better guidance for users when errors occur

Security verification workflow:
1. Download archive from GitHub Release
2. Download SHA256SUMS file
3. Calculate actual checksum of archive
4. Compare and fail if mismatch
5. Only extract if verification succeeds

This addresses all critical security concerns from PR review.
@claude
Copy link

claude bot commented Nov 4, 2025

Pull Request Review: Multi-Platform Publishing Support

Summary

This PR adds comprehensive publishing infrastructure for crates.io, npm, Debian/Ubuntu, and Arch Linux. Well-structured with good security practices.

Code Quality: Excellent ✅

Strengths:

  • Clean npm package structure with clear separation of concerns
  • Comprehensive error handling with fallback instructions
  • Thorough cross-platform support for all major OS/arch combinations
  • Good documentation

Minor Issues:

  1. Unused import (npm/scripts/install.js:10): streamPipeline is never used
  2. Command injection risk (lines 158, 184): Consider pure-JS libraries (tar, adm-zip) instead of execSync for extraction

Security: Strong ✅

Excellent practices:

  • SHA256 checksum verification before extraction (lines 232-233)
  • HTTPS-only downloads
  • Proper Unix permissions (0o755)
  • No arbitrary code execution

Recommendations:

  • Add download timeouts to prevent hanging
  • Add retry logic for network failures
  • Verify binary directory creation before download

Performance: Good ✅

  • Early exit if binary exists (line 220-222)
  • Efficient streaming for downloads and hashing
  • Proper cleanup of temporary archives

GitHub Actions: Well Designed ✅

Strengths:

  • Proper job dependencies with needs clauses
  • Artifact attestation for supply chain security
  • Tag-based conditional execution

Concerns:

  1. Race condition risk: 30s sleep before npm publish may be insufficient. Use retry loop instead
  2. Missing validation: Check NPM_TOKEN exists before publish
  3. Verify cargo-aur: Less common tool, ensure it works as expected

Test Coverage: Gap Identified ⚠️

Critical: No automated tests for 260-line npm install script

Needed:

  • Unit tests for platform detection and checksum verification
  • Integration tests with mocked GitHub releases
  • CI test that runs npm install

Add to CI:

- name: Test npm package installation
  run: |
    cd npm
    npm install
    node bin/bun-docs-mcp-proxy.js --help

Cargo.toml Metadata: Excellent ✅

  • Complete cargo-binstall metadata with all platform overrides
  • Proper Debian package metadata
  • Good categorization

Minor: Consider adding readme = "README.md" to [package]

Priority Recommendations

High:

  1. Add retry logic to npm publish (replace sleep)
  2. Add npm package installation test to CI
  3. Verify cargo-aur works

Medium:
4. Remove unused streamPipeline import
5. Add download timeout
6. Add NPM_TOKEN validation

Low:
7. Use pure-JS extraction libraries
8. Add download progress indicators
9. Add readme field to Cargo.toml

Overall Assessment

Rating: 9/10 - Excellent

Well-crafted PR with strong security and comprehensive cross-platform support. Main gaps are lack of npm install tests and potential race condition in publishing workflow.

Status: Ready to merge (recommend adding npm tests for increased confidence)

Great work on this distribution infrastructure! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants