Needed to update the build.yml ugh. Attempt no1 #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "python" => :optional | |
on_macos do | |
url "${MACOS_URL}" | |
sha256 "${MACOS_SHA}" | |
end | |
on_linux do | |
url "${LINUX_URL}" | |
sha256 "${LINUX_SHA}" | |
end | |
resource "pyperclip" do | |
url "https://files.pythonhosted.org/packages/source/p/pyperclip/pyperclip-1.9.0.tar.gz" | |
sha256 "b7de0142ddc81bfc5c7507eea19da920b92252b548b96186caf94a5e2527d310" | |
end | |
resource "pathspec" do | |
url "https://files.pythonhosted.org/packages/source/p/pathspec/pathspec-0.12.1.tar.gz" | |
sha256 "a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712" | |
end | |
def install | |
# Find python3 and pip3 in the user's PATH | |
python_path = `which python3`.chomp | |
pip_path = `which pip3`.chomp | |
if !python_path.empty? && !pip_path.empty? && system("#{python_path}", "--version") && system("#{pip_path}", "--version") | |
opoo "Python and pip detected. Installing with pip." | |
ENV.prepend_path "PATH", File.dirname(python_path) # Ensure the detected Python is prioritized | |
virtualenv_install_with_resources | |
else | |
opoo "Python or pip not detected. Falling back to binary installation." | |
install_binary | |
end | |
end | |
def install_binary | |
if OS.mac? | |
bin.install "gptree-macos" => "gptree" | |
elsif OS.linux? | |
bin.install "gptree-ubuntu" => "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 }} |