Skip to content

Update README.md with simpler instal recommendations #13

Update README.md with simpler instal recommendations

Update README.md with simpler instal recommendations #13

Workflow file for this run

name: Build and Release gptree CLI
on:
push:
tags:
- 'v*' # Trigger on version tags like v1.0.0
workflow_dispatch: # Allow manual triggering
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
# Checkout code
- name: Checkout repository
uses: actions/checkout@v4
# Set up Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
# Install dependencies
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install pyinstaller pathspec pyperclip
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
sudo apt-get update && sudo apt-get install -y upx
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
brew install upx
fi
# Build binary with PyInstaller and optimize
- name: Build executable with PyInstaller
shell: bash
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
pyinstaller --onefile --noconsole --name gptree.exe cli_tool_gptree/main.py
else
# Dynamically find UPX path
UPX_PATH=$(which upx || echo "")
echo "Using UPX path: $UPX_PATH"
if [ -n "$UPX_PATH" ]; then
pyinstaller --onefile --noconsole --upx-dir=$(dirname "$UPX_PATH") --name gptree cli_tool_gptree/main.py
else
echo "UPX not found; skipping compression."
pyinstaller --onefile --noconsole --name gptree cli_tool_gptree/main.py
fi
fi
# Rename binaries for platform-specific names
- name: Rename binaries for upload
shell: bash # Use Bash explicitly
run: |
if [ "${{ matrix.os }}" = "macos-latest" ]; then
mv dist/gptree dist/gptree-macos
elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
mv dist/gptree dist/gptree-ubuntu
elif [ "${{ matrix.os }}" = "windows-latest" ]; then
mv dist/gptree.exe dist/gptree-windows.exe
fi
# Upload binary as artifact
- name: Upload binary as artifact
uses: actions/upload-artifact@v4
with:
name: gptree-${{ matrix.os }}
path: |
dist/gptree-macos
dist/gptree-ubuntu
dist/gptree-windows.exe
release:
name: Create Release
needs: build # Waits for the build job to complete
runs-on: ubuntu-latest
permissions:
contents: write # Grants permission to create a release and upload files
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
# Download all artifacts from the build job
- name: Download all binaries
uses: actions/download-artifact@v4
with:
path: artifacts
# List downloaded files for debugging
- name: List downloaded binaries
run: ls -R artifacts
# Create GitHub Release and upload binaries
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/**/* # Match all files recursively in artifacts/
body: "Release of gptree CLI tool.\n\nDownload the appropriate binary for your operating system."
tag_name: ${{ github.ref_name }}
name: 'GPTree Release ${{ github.ref_name }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Update Homebrew Tap Formula
- name: Update Homebrew Tap Formula
run: |
# Clone the Homebrew tap repository
git clone https://github.com/travisvn/homebrew-tap.git
cd homebrew-tap
# Define variables for version and compute SHA256 checksums
VERSION=${{ github.ref_name }}
MACOS_URL="https://github.com/travisvn/gptree/releases/download/${VERSION}/gptree-macos"
LINUX_URL="https://github.com/travisvn/gptree/releases/download/${VERSION}/gptree-ubuntu"
# Calculate SHA256 checksums
MACOS_SHA=$(curl -L $MACOS_URL | shasum -a 256 | cut -d' ' -f1)
LINUX_SHA=$(curl -L $LINUX_URL | shasum -a 256 | cut -d' ' -f1)
echo "MacOS SHA256: $MACOS_SHA"
echo "Linux SHA256: $LINUX_SHA"
# Update the gptree.rb formula
cat <<EOF > Formula/gptree.rb
class Gptree < Formula
desc "Project tree structure and file content aggregator for providing LLM context"
homepage "https://github.com/travisvn/gptree"
license "MIT"
version "${VERSION}"
depends_on "[email protected]" => :optional
def install
if system("which pip3")
# Attempt to install via pip
pip_success = system("pip3", "install", "gptree-cli==${VERSION}", "--prefix=#{prefix}")
unless pip_success
opoo "pip3 installation failed. Falling back to binary installation."
download_and_install_binary
end
else
# Fallback to binary installation if pip3 isn't available
download_and_install_binary
end
end
def download_and_install_binary
if OS.mac?
url = "${MACOS_URL}"
sha256 = "${MACOS_SHA}"
fetch_and_install(url, sha256, "gptree-macos")
elsif OS.linux?
url = "${LINUX_URL}"
sha256 = "${LINUX_SHA}"
fetch_and_install(url, sha256, "gptree-ubuntu")
end
end
def fetch_and_install(url, sha256, filename)
# Download the file manually
resource filename do
url url
sha256 sha256
end
resource(filename).stage do
bin.install filename => "gptree"
end
end
test do
assert_match "usage", shell_output("#{bin}/gptree --help")
end
end
EOF
# Commit and push the changes
git config user.name "github-actions"
git config user.email "[email protected]"
git add Formula/gptree.rb
git commit -m "Update gptree formula to version ${VERSION}"
git push https://x-access-token:${{ secrets.HOMEBREW_TAP_TOKEN }}@github.com/travisvn/homebrew-tap.git main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}