Skip to content
Closed
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
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Auto Build

on:
push:
branches:
- main
tags:
- 'alpha*'
- 'beta*'
- 'v*'

jobs:
build:
name: Build binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v3

- uses: dtolnay/rust-toolchain@stable

- name: Build & Install Binary
shell: bash
env:
OS_NAME: ${{ runner.os }}
run: |
cargo install --path . --root dist
if [[ "$OS_NAME" == "Windows" ]]; then
mv dist/bin/pipe.exe pipe-windows-amd64.exe
elif [[ "$OS_NAME" == "macOS" ]]; then
cp dist/bin/pipe pipe-macos-amd64
else
cp dist/bin/pipe pipe-linux-amd64
fi

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: pipe-${{ runner.os }}
path: pipe-*

release:
name: Upload Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') # ⬅️ hanya jalan saat push tag

steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: ./dist

- name: Flatten Artifact Folder
run: |
find ./dist -type f -exec cp {} . \;

- name: Upload to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
pipe-*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ Download pre-built binaries for your platform from the [latest release](https://
#### Linux/macOS Installation
```bash
# Download the binary (replace URL with your platform's binary)
wget https://github.com/PipeNetwork/pipe/releases/latest/download/pipe-linux-amd64

# Make it executable
chmod +x pipe-linux-amd64

# Move to PATH
sudo mv pipe-linux-amd64 /usr/local/bin/pipe
sudo wget -O /usr/local/bin/pipe https://github.com/PipeNetwork/pipe/releases/latest/download/pipe-linux-amd64 && chmod +x /usr/local/bin/pipe

# Verify installation
pipe --version
Expand Down
47 changes: 37 additions & 10 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

set -e
set -euo pipefail

# Color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
CYAN='\033[0;36m'
Expand All @@ -11,32 +12,54 @@ NC='\033[0m' # No Color
echo -e "${CYAN}🎯 Installing system dependencies...${NC}"
sudo apt update && sudo apt install -y build-essential pkg-config libssl-dev git curl

# Version check helper
version_lt() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" != "$2" ]
}

# Rust install/check
MIN_RUST_VERSION="1.70.0"
should_install_rust=false

if command -v rustc &> /dev/null && command -v cargo &> /dev/null; then
INSTALLED_RUST_VERSION=$(rustc --version | awk '{print $2}')
echo -e "${CYAN}🔍 Detected rustc ${INSTALLED_RUST_VERSION}${NC}"

if [ "$(printf '%s\n' "$INSTALLED_RUST_VERSION" "$MIN_RUST_VERSION" | sort -V | head -n1)" != "$MIN_RUST_VERSION" ]; then
echo -e "${YELLOW}⚠️ Rust version is too old (< ${MIN_RUST_VERSION}). Updating via rustup...${NC}"
if version_lt "$INSTALLED_RUST_VERSION" "$MIN_RUST_VERSION"; then
echo -e "${YELLOW}⚠️ Rust version too old (< ${MIN_RUST_VERSION}). Updating...${NC}"
should_install_rust=true
else
echo -e "${GREEN}✅ Rust version is sufficient. Skipping installation.${NC}"
echo -e "${GREEN}✅ Rust version is sufficient. Skipping install.${NC}"
fi
else
echo -e "${YELLOW}🚫 Rust or Cargo not found.${NC}"
should_install_rust=true
fi

if [ "$should_install_rust" = true ]; then
echo -e "${CYAN}🚀 Installing rustup (Rust & Cargo)...${NC}"
echo -e "${CYAN}🚀 Installing Rust via rustup...${NC}"
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
source "$HOME/.cargo/env"

if ! command -v cargo &> /dev/null; then
echo -e "${RED}❌ Cargo not found after install. Exiting.${NC}"
exit 1
fi
fi

# Handle --force flag
if [[ "$1" == "--force" ]]; then
# Ensure cargo bin path is in PATH
export PATH="$HOME/.cargo/bin:$PATH"

# Parse flags
FORCE=false
for arg in "$@"; do
if [[ "$arg" == "--force" ]]; then
FORCE=true
fi
done

# Clone if not exists or force
if [ "$FORCE" = true ]; then
echo -e "${YELLOW}⚠️ --force enabled. Removing existing 'pipe' folder...${NC}"
rm -rf pipe
fi
Expand All @@ -47,20 +70,24 @@ else
echo -e "${CYAN}📦 Cloning Pipe repo...${NC}"
git clone https://github.com/PipeNetwork/pipe.git
fi

cd pipe

echo -e "${CYAN}🔧 Building Pipe CLI...${NC}"

if cargo install --path .; then
echo -e "${GREEN}✅ Build successful!${NC}"
else
echo -e "${RED}❌ Build failed. Please check the error log.${NC}"
exit 1
fi

# Final check
if command -v pipe &> /dev/null; then
echo -e "\n${GREEN}🚀 All set! You can now run:${NC}"
echo -e " ${CYAN}pipe --help${NC}\n"
echo -e "${CYAN}📍 Installed binary: $(which pipe)${NC}"
else
echo -e "\n${RED}⚠️ Setup complete, but 'pipe' command not found in PATH.${NC}"
echo -e "${YELLOW}You might need to restart your terminal or add ~/.cargo/bin to PATH.${NC}\n"
echo -e "\n${RED}⚠️ Build completed, but 'pipe' not found in PATH.${NC}"
echo -e "${YELLOW}Try running: export PATH=\"\$HOME/.cargo/bin:\$PATH\"${NC}"
fi