Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload install scripts
uses: actions/upload-artifact@v4
with:
name: install-scripts
path: |
install.sh
install.ps1

test:
runs-on: ubuntu-latest
Expand Down
10 changes: 7 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ builds:
main: ./cmd/buildtree
archives:
- format: tar.gz
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
files:
- LICENSE
- README.md
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
name_template: "{{ .ProjectName }}_checksums.txt"
snapshot:
name_template: "{{ .ProjectName }}-SNAPSHOT-{{ .ShortCommit }}"
changelog:
Expand All @@ -33,4 +33,8 @@ changelog:
exclude:
- "^docs:"
- "^test:"
- "^chore:"
- "^chore:"
release:
github:
owner: neomen
name: buildtree
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ custom_login/
go install github.com/neomen/buildtree/cmd/buildtree@latest
```

### Quick install (Linux/macOS)

```bash
curl -sSL https://raw.githubusercontent.com/neomen/buildtree/main/install.sh | sh
```
### Manual installation

1. Download the latest release for your platform from the [releases page](https://github.com/neomen/buildtree/releases)
2. Extract the archive:
```bash
tar xzf buildtree_<os>_<arch>.tar.gz
```
3. Move the binary to your PATH:
```bash
# Linux/macOS
sudo mv buildtree /usr/local/bin/

# Windows
# Move buildtree.exe to a directory in your PATH
```

## Usage

### Basic Example
Expand All @@ -54,7 +75,7 @@ pbpaste | buildtree -

### From File
```bash
buildtree -f structure.txt
buildtree -i structure.txt
```

### Multi-level Project
Expand Down
53 changes: 53 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Buildtree installer for Windows
Write-Host "Installing buildtree..." -ForegroundColor Green

# Determine architecture
$Arch = if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") { "amd64" } else { "arm64" }

# Download URL
$Url = "https://github.com/neomen/buildtree/releases/latest/download/buildtree_windows_${Arch}.tar.gz"
$OutputFile = "buildtree_windows_${Arch}.tar.gz"

Write-Host "Downloading from $Url..."

# Download the file
try {
Invoke-WebRequest -Uri $Url -OutFile $OutputFile
}
catch {
Write-Host "Error downloading buildtree: $_" -ForegroundColor Red
exit 1
}

# Extract the archive
try {
tar -xzf $OutputFile
Remove-Item $OutputFile
}
catch {
Write-Host "Error extracting archive: $_" -ForegroundColor Red
exit 1
}

# Check if buildtree.exe was extracted
if (Test-Path "buildtree.exe") {
Write-Host "Download successful!" -ForegroundColor Green

# Check if a bin directory exists in PATH
$LocalBin = "$env:USERPROFILE\bin"
$InPath = $env:PATH -split ";" | Where-Object { $_ -eq $LocalBin }

if (-not $InPath) {
Write-Host "Consider adding a directory to your PATH for easier access." -ForegroundColor Yellow
Write-Host "You can create a bin directory and add it to your PATH:" -ForegroundColor Yellow
Write-Host "1. mkdir $LocalBin" -ForegroundColor Yellow
Write-Host "2. [Environment]::SetEnvironmentVariable('PATH', `"$LocalBin;`$env:PATH`", 'User')" -ForegroundColor Yellow
Write-Host "3. Move buildtree.exe to $LocalBin" -ForegroundColor Yellow
}

Write-Host "`nRun buildtree from current directory: .\buildtree.exe -h" -ForegroundColor Green
}
else {
Write-Host "Error: buildtree.exe not found in downloaded archive" -ForegroundColor Red
exit 1
}
70 changes: 59 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,68 @@
#!/bin/sh
# install.sh
# Buildtree installer script

set -e

# OS and Architecture definition
echo "Installing buildtree..."

# Determine OS and Architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
[ "$ARCH" = "x86_64" ] && ARCH="amd64"
[ "$ARCH" = "aarch64" ] && ARCH="arm64"

# Download
URL="https://github.com/neomen/buildtree/releases/latest/download/buildtree_${OS}_${ARCH}.tar.gz"
echo "Download from the $URL..."
curl -L "$URL" | tar xz
case $ARCH in
x86_64) ARCH="amd64" ;;
aarch64) ARCH="arm64" ;;
arm64) ARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac

# Check if the OS is supported
if [ "$OS" != "linux" ] && [ "$OS" != "darwin" ] && [ "$OS" != "windows" ]; then
echo "Unsupported OS: $OS. This script supports Linux, macOS, and Windows (via WSL)."
exit 1
fi

# For Windows, we need to adjust the binary name
if [ "$OS" = "windows" ]; then
BINARY_NAME="buildtree.exe"
ARCHIVE_NAME="buildtree_windows_${ARCH}.tar.gz"
else
BINARY_NAME="buildtree"
ARCHIVE_NAME="buildtree_${OS}_${ARCH}.tar.gz"
fi

# Download URL
URL="https://github.com/neomen/buildtree/releases/latest/download/${ARCHIVE_NAME}"
echo "Downloading from $URL..."

# Download and extract
if command -v curl >/dev/null 2>&1; then
curl -sSL "$URL" | tar xz
elif command -v wget >/dev/null 2>&1; then
wget -q -O - "$URL" | tar xz
else
echo "Error: curl or wget is required to download buildtree"
exit 1
fi

# Installation
sudo mv buildtree /usr/local/bin/
echo "Installed in /usr/local/bin/buildtree"
buildtree -h
if [ "$OS" = "windows" ]; then
# For Windows, offer to install to a directory in PATH
echo "Windows installation:"
echo "1. Move $BINARY_NAME to a directory in your PATH"
echo "2. Or run directly from current directory: .\\$BINARY_NAME"
mv "$BINARY_NAME" ./
echo "Binary downloaded to current directory: $BINARY_NAME"
else
# For Unix systems, install to /usr/local/bin
sudo mv "$BINARY_NAME" /usr/local/bin/
echo "Installed in /usr/local/bin/$BINARY_NAME"

# Test the installation
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
echo "Installation successful. You can now use '$BINARY_NAME'"
"$BINARY_NAME" -v
else
echo "Installation completed, but the binary is not in your PATH."
fi
fi
Loading