mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-09-21 14:04:19 +00:00
feat: add npm distribution wrapper for idx-cli
Add an npm wrapper (package.json + postinstall downloader) so the Rust binary can be installed via npm/npx. Include a local smoke test, a GitHub Release cross-compile workflow, and nodejs in the dev shell. - package.json: idx-cli v0.2.3, bin idx, engines node>=16 - scripts/install.js: dependency-free postinstall that downloads the platform-specific GitHub Release asset (or IDX_BINARY_URL override) - scripts/idx.js: binary launcher preserving exit codes/signals - scripts/npm-smoke.sh: npm pack -> install tarball -> run idx --help and idx config --help, locale, no publish required - .github/workflows/release.yml: cross-compile linux-x64/arm64 and darwin-arm64 releases and attach binaries to the version tag - flake.nix: add nodejs_22 to the dev shell - docs/NPM_DISTRIBUTION.md: usage, local test, and release flow
This commit is contained in:
parent
603c0e49c1
commit
221dc01397
7 changed files with 463 additions and 0 deletions
77
.github/workflows/release.yml
vendored
Normal file
77
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ matrix.asset }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
asset: linux-x64
|
||||
- os: ubuntu-latest
|
||||
target: aarch64-unknown-linux-gnu
|
||||
asset: linux-arm64
|
||||
- os: macos-14
|
||||
target: aarch64-apple-darwin
|
||||
asset: darwin-arm64
|
||||
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust toolchain and target
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install Linux ARM64 linker
|
||||
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
||||
run: sudo apt-get update && sudo apt-get install --yes gcc-aarch64-linux-gnu
|
||||
|
||||
- name: Build release binary
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
|
||||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
|
||||
fi
|
||||
cargo build --release --locked --target "${{ matrix.target }}"
|
||||
cp "target/${{ matrix.target }}/release/idx" "idx-${{ matrix.asset }}"
|
||||
chmod 0755 "idx-${{ matrix.asset }}"
|
||||
|
||||
- name: Upload target artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: idx-${{ matrix.asset }}
|
||||
path: idx-${{ matrix.asset }}
|
||||
if-no-files-found: error
|
||||
|
||||
publish:
|
||||
name: Attach binaries to release
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download target artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: idx-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Attach binaries to the version tag
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
files: |
|
||||
idx-linux-x64
|
||||
idx-linux-arm64
|
||||
idx-darwin-arm64
|
||||
Loading…
Add table
Add a link
Reference in a new issue