From 14702cc9f5341b8ab20765c8a7c1a95778f38308 Mon Sep 17 00:00:00 2001 From: Liran Cohen Date: Tue, 23 Jun 2026 16:14:01 +0000 Subject: [PATCH] fix installer package install path --- .changeset/fix-curl-install.md | 10 ++ .github/workflows/npm-release.yml | 84 ---------------- .github/workflows/release.yml | 80 ++------------- README.md | 7 +- install.sh | 162 ++++++++++-------------------- 5 files changed, 76 insertions(+), 267 deletions(-) create mode 100644 .changeset/fix-curl-install.md diff --git a/.changeset/fix-curl-install.md b/.changeset/fix-curl-install.md new file mode 100644 index 0000000..b81f420 --- /dev/null +++ b/.changeset/fix-curl-install.md @@ -0,0 +1,10 @@ +--- +'@enbox/gitd': patch +--- + +fix: install gitd through the Bun package path + +The curl installer now installs the published `@enbox/gitd` package with Bun +and links wrappers into `~/.gitd/bin`. Standalone release artifacts are disabled +until gitd no longer depends on native packages that need platform-local +installation. diff --git a/.github/workflows/npm-release.yml b/.github/workflows/npm-release.yml index d76ec84..8c14017 100644 --- a/.github/workflows/npm-release.yml +++ b/.github/workflows/npm-release.yml @@ -51,87 +51,3 @@ jobs: commit: 'chore: version packages' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - build-artifacts: - name: Build ${{ matrix.target }} - needs: release - if: needs.release.outputs.published == 'true' - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - target: bun-linux-x64 - os: linux - arch: x64 - ext: tar.gz - - target: bun-linux-arm64 - os: linux - arch: arm64 - ext: tar.gz - - target: bun-darwin-x64 - os: darwin - arch: x64 - ext: tar.gz - - target: bun-darwin-arm64 - os: darwin - arch: arm64 - ext: tar.gz - - target: bun-windows-x64 - os: windows - arch: x64 - ext: zip - - target: bun-linux-x64-musl - os: linux - arch: x64-musl - ext: tar.gz - - target: bun-linux-arm64-musl - os: linux - arch: arm64-musl - ext: tar.gz - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Determine version - id: version - run: | - version=$(node -p "require('./package.json').version") - echo "version=v${version}" >> "$GITHUB_OUTPUT" - - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - with: - bun-version: latest - - - name: Install dependencies - run: bun install --frozen-lockfile - - - name: Build release binaries - run: | - mkdir -p dist/release - out_suffix="" - if [ "${{ matrix.os }}" = "windows" ]; then - out_suffix=".exe" - fi - - bun build src/cli/main.ts --compile --target "${{ matrix.target }}" --outfile "dist/release/gitd${out_suffix}" - bun build src/git-remote/main.ts --compile --target "${{ matrix.target }}" --outfile "dist/release/git-remote-did${out_suffix}" - bun build src/git-remote/credential-main.ts --compile --target "${{ matrix.target }}" --outfile "dist/release/git-remote-did-credential${out_suffix}" - - - name: Package artifact - run: | - artifact="gitd-${{ matrix.os }}-${{ matrix.arch }}.${{ matrix.ext }}" - if [ "${{ matrix.ext }}" = "zip" ]; then - (cd dist/release && zip -q "../../${artifact}" gitd.exe git-remote-did.exe git-remote-did-credential.exe) - else - (cd dist/release && tar -czf "../../${artifact}" gitd git-remote-did git-remote-did-credential) - fi - echo "artifact=${artifact}" >> "$GITHUB_ENV" - - - name: Upload artifact to release - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ steps.version.outputs.version }} - files: ${{ env.artifact }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1fc8c8e..bee5f3d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,80 +13,12 @@ permissions: contents: write jobs: - build-and-upload: - name: Build ${{ matrix.target }} + disabled: + name: Standalone artifacts disabled runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - target: bun-linux-x64 - os: linux - arch: x64 - ext: tar.gz - - target: bun-linux-arm64 - os: linux - arch: arm64 - ext: tar.gz - - target: bun-darwin-x64 - os: darwin - arch: x64 - ext: tar.gz - - target: bun-darwin-arm64 - os: darwin - arch: arm64 - ext: tar.gz - - target: bun-windows-x64 - os: windows - arch: x64 - ext: zip - - target: bun-linux-x64-musl - os: linux - arch: x64-musl - ext: tar.gz - - target: bun-linux-arm64-musl - os: linux - arch: arm64-musl - ext: tar.gz - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.tag || github.ref }} - - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - with: - bun-version: latest - - - name: Install dependencies - run: bun install --frozen-lockfile - - - name: Build release binaries + - name: Explain why artifacts are disabled run: | - mkdir -p dist/release - out_suffix="" - if [ "${{ matrix.os }}" = "windows" ]; then - out_suffix=".exe" - fi - - bun build src/cli/main.ts --compile --target "${{ matrix.target }}" --outfile "dist/release/gitd${out_suffix}" - bun build src/git-remote/main.ts --compile --target "${{ matrix.target }}" --outfile "dist/release/git-remote-did${out_suffix}" - bun build src/git-remote/credential-main.ts --compile --target "${{ matrix.target }}" --outfile "dist/release/git-remote-did-credential${out_suffix}" - - - name: Package artifact - run: | - artifact="gitd-${{ matrix.os }}-${{ matrix.arch }}.${{ matrix.ext }}" - if [ "${{ matrix.ext }}" = "zip" ]; then - (cd dist/release && zip -q "../../${artifact}" gitd.exe git-remote-did.exe git-remote-did-credential.exe) - else - (cd dist/release && tar -czf "../../${artifact}" gitd git-remote-did git-remote-did-credential) - fi - echo "artifact=${artifact}" >> "$GITHUB_ENV" - - - name: Upload artifact to release - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ github.event.inputs.tag || github.event.release.tag_name }} - files: ${{ env.artifact }} + echo "Standalone Bun-compiled artifacts are disabled." + echo "gitd depends on native packages that must be installed on the user's platform." + echo "Use install.sh or bun add -g @enbox/gitd until native-free artifacts are implemented." diff --git a/README.md b/README.md index 25ce74f..020dfd3 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,16 @@ gitd pr merge a1b2c3d curl -fsSL https://gitd.sh/install | bash ``` -Or via bun / npm: +The installer installs the published `@enbox/gitd` package with Bun, and +bootstraps Bun first if it is not already available. + +Or install directly with Bun: ```bash bun add -g @enbox/gitd ``` -This installs three binaries: +This installs three commands: | Binary | Purpose | |---|---| diff --git a/install.sh b/install.sh index 8a1a533..b51441d 100755 --- a/install.sh +++ b/install.sh @@ -3,18 +3,10 @@ set -euo pipefail APP='gitd' -REPO='enboxorg/gitd' +PACKAGE='@enbox/gitd' INSTALL_DIR="${HOME}/.${APP}/bin" REQUESTED_VERSION="${VERSION:-}" NO_MODIFY_PATH=false -TMP_DIR='' - -cleanup() { - if [ -n "$TMP_DIR" ] && [ -d "$TMP_DIR" ]; then - rm -rf "$TMP_DIR" - fi -} -trap cleanup EXIT INT TERM usage() { cat <<'EOF' @@ -24,12 +16,12 @@ Usage: install.sh [options] Options: -h, --help Show this help message - -v, --version Install a specific version (example: 0.0.1) + -v, --version Install a specific version (example: 0.9.6) --no-modify-path Do not modify shell profile files Examples: curl -fsSL https://gitd.sh/install | bash - curl -fsSL https://gitd.sh/install | bash -s -- --version 0.0.1 + curl -fsSL https://gitd.sh/install | bash -s -- --version 0.9.6 EOF } @@ -56,90 +48,65 @@ http_get() { fail 'curl or wget is required' } -download_file() { - local url="$1" - local out="$2" - - if has_command curl; then - curl -fsSL "$url" -o "$out" - return - fi - - if has_command wget; then - wget -q "$url" -O "$out" - return - fi - - fail 'curl or wget is required' -} - detect_os() { case "$(uname -s)" in Linux) printf 'linux' ;; Darwin) printf 'darwin' ;; - CYGWIN*|MINGW*|MSYS*) printf 'windows' ;; *) fail 'unsupported operating system' ;; esac } -detect_arch() { - case "$(uname -m)" in - x86_64|amd64) printf 'x64' ;; - aarch64|arm64) printf 'arm64' ;; - *) fail 'unsupported CPU architecture' ;; - esac -} - -detect_libc() { - if [ "$(detect_os)" != 'linux' ]; then +resolve_package_version() { + if [ -z "$REQUESTED_VERSION" ]; then + printf 'latest' return fi - if has_command ldd; then - case "$(ldd --version 2>&1)" in - *musl*) printf '-musl' ; return ;; - esac - fi + case "$REQUESTED_VERSION" in + v*) printf '%s' "${REQUESTED_VERSION#v}" ;; + *) printf '%s' "$REQUESTED_VERSION" ;; + esac +} - if [ -f /etc/alpine-release ]; then - printf '-musl' +ensure_bun() { + if has_command bun; then return fi -} -latest_tag() { - http_get "https://api.github.com/repos/${REPO}/releases/latest" | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1 -} + export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}" + printf '==> Bun is required; installing Bun to %s\n' "$BUN_INSTALL" + http_get 'https://bun.sh/install' | bash -resolve_tag() { - if [ -z "$REQUESTED_VERSION" ]; then - latest_tag - return + export PATH="${BUN_INSTALL}/bin:$PATH" + if ! has_command bun; then + fail "Bun installed, but ${BUN_INSTALL}/bin/bun is not available" fi +} - case "$REQUESTED_VERSION" in - v*) printf '%s' "$REQUESTED_VERSION" ;; - *) printf 'v%s' "$REQUESTED_VERSION" ;; - esac +shell_quote() { + printf '%q' "$1" } -extract_archive() { - local archive="$1" - local out_dir="$2" - local os="$3" +write_wrapper() { + local name="$1" + local source="$2" + local bun_path="$3" + local out="${INSTALL_DIR}/${name}" - if [ "$os" = 'windows' ]; then - if ! has_command unzip; then - fail 'unzip is required for Windows artifacts' - fi - unzip -q "$archive" -d "$out_dir" - return + if [ ! -e "$source" ]; then + fail "bun did not install ${name}" fi - if ! has_command tar; then - fail 'tar is required' - fi - tar -xzf "$archive" -C "$out_dir" + local quoted_bun + quoted_bun="$(shell_quote "$bun_path")" + local quoted_source + quoted_source="$(shell_quote "$source")" + + { + printf '#!/usr/bin/env bash\n' + printf 'exec %s %s "$@"\n' "$quoted_bun" "$quoted_source" + } > "$out" + chmod +x "$out" } add_to_path() { @@ -208,53 +175,34 @@ main() { esac done - local os - os="$(detect_os)" - local arch - arch="$(detect_arch)" - local libc - libc="$(detect_libc)" - local tag - tag="$(resolve_tag)" - [ -n "$tag" ] || fail 'unable to determine release tag' - - local archive='' - if [ "$os" = 'windows' ]; then - archive="gitd-${os}-${arch}.zip" - else - archive="gitd-${os}-${arch}${libc}.tar.gz" - fi - - local url - url="https://github.com/${REPO}/releases/download/${tag}/${archive}" + detect_os >/dev/null + ensure_bun - TMP_DIR="$(mktemp -d)" + local package_version + package_version="$(resolve_package_version)" + [ -n "$package_version" ] || fail 'unable to determine package version' - printf '==> Installing gitd %s\n' "$tag" - download_file "$url" "${TMP_DIR}/${archive}" - extract_archive "${TMP_DIR}/${archive}" "$TMP_DIR" "$os" + local package_spec="${PACKAGE}@${package_version}" + printf '==> Installing %s\n' "$package_spec" + bun add -g "$package_spec" mkdir -p "$INSTALL_DIR" - local suffix='' - if [ "$os" = 'windows' ]; then - suffix='.exe' - fi - - cp "${TMP_DIR}/gitd${suffix}" "${INSTALL_DIR}/gitd${suffix}" - cp "${TMP_DIR}/git-remote-did${suffix}" "${INSTALL_DIR}/git-remote-did${suffix}" - cp "${TMP_DIR}/git-remote-did-credential${suffix}" "${INSTALL_DIR}/git-remote-did-credential${suffix}" + local bun_path + bun_path="$(command -v bun)" + local bun_global_bin + bun_global_bin="$(bun pm bin -g)" - chmod +x "${INSTALL_DIR}/gitd${suffix}" - chmod +x "${INSTALL_DIR}/git-remote-did${suffix}" - chmod +x "${INSTALL_DIR}/git-remote-did-credential${suffix}" + write_wrapper 'gitd' "${bun_global_bin}/gitd" "$bun_path" + write_wrapper 'git-remote-did' "${bun_global_bin}/git-remote-did" "$bun_path" + write_wrapper 'git-remote-did-credential' "${bun_global_bin}/git-remote-did-credential" "$bun_path" if [ "$NO_MODIFY_PATH" = false ] && [[ ":$PATH:" != *":${INSTALL_DIR}:"* ]]; then add_to_path fi printf '==> Installed to %s\n' "$INSTALL_DIR" - "${INSTALL_DIR}/gitd${suffix}" --version || true + "${INSTALL_DIR}/gitd" --version printf 'Run: gitd setup\n' }