Skip to content

Commit 3cfb1f1

Browse files
authored
release for synd-cli (#926)
1 parent 84b9871 commit 3cfb1f1

File tree

3 files changed

+209
-14
lines changed

3 files changed

+209
-14
lines changed

.github/workflows/publish-synd-cli.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
name: Publish synd-cli Binaries
22

33
on:
4-
release:
5-
types: [published]
64
workflow_dispatch:
75
inputs:
86
tag_name:
9-
description: Release tag version (e.g., v1.2.3, v0.10.15-dev.1)
7+
description: "synd-cli version tag (e.g., synd-cli-v1.0.0)"
108
required: true
119
type: string
1210

@@ -74,13 +72,13 @@ jobs:
7472
retention-days: 1
7573

7674
publish-release:
77-
name: Attach binaries to GitHub release
75+
name: Create release and attach binaries
7876
permissions:
7977
contents: write
8078
needs: build
8179
runs-on: ubuntu-latest
8280
env:
83-
TAG_NAME: ${{ github.event.release.tag_name || inputs.tag_name }}
81+
TAG_NAME: ${{ inputs.tag_name }}
8482
steps:
8583
- name: Download build artifacts
8684
uses: actions/download-artifact@v4
@@ -94,10 +92,12 @@ jobs:
9492
mv synd-cli/synd-cli-darwin-x64 synd-cli-darwin-x64-${{ env.TAG_NAME }}
9593
mv synd-cli/synd-cli-darwin-arm64 synd-cli-darwin-arm64-${{ env.TAG_NAME }}
9694
97-
- name: Attach binaries to release
95+
- name: Create release and attach binaries
9896
uses: softprops/action-gh-release@v1
9997
with:
10098
tag_name: ${{ env.TAG_NAME }}
99+
name: "synd-cli ${{ env.TAG_NAME }}"
100+
body: "Release of synd-cli ${{ env.TAG_NAME }}"
101101
files: |
102102
synd-cli-linux-x64-${{ env.TAG_NAME }}
103103
synd-cli-linux-arm64-${{ env.TAG_NAME }}

synd-cli/README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,50 @@ A TypeScript-based CLI tool for creating and managing Syndicate Appchains. It ha
44

55
## Installation
66

7+
### Pre-built Binaries (Recommended)
8+
9+
Install the latest version:
10+
11+
```bash
12+
curl -L https://raw.githubusercontent.com/SyndicateProtocol/syndicate-appchains/main/synd-cli/install.sh | bash
13+
```
14+
15+
Install a specific version:
16+
17+
```bash
18+
curl -L https://raw.githubusercontent.com/SyndicateProtocol/syndicate-appchains/main/synd-cli/install.sh | SYND_VERSION=synd-cli-v1.0.0 bash
19+
```
20+
21+
Custom install directory:
22+
23+
```bash
24+
curl -L https://raw.githubusercontent.com/SyndicateProtocol/syndicate-appchains/main/synd-cli/install.sh | SYND_INSTALL_DIR=/usr/local/bin bash
25+
```
26+
27+
After installation, add `~/.synd/bin` to your PATH (the installer will provide instructions).
28+
29+
### From Source
30+
731
```bash
832
bun install
933
```
1034

1135
## Quick Start
1236

37+
> **Note:** If running from source, replace `synd-cli` with `bun run synd-cli` in all commands below.
38+
1339
1. **Generate example config files:**
1440
```bash
15-
bun run synd-cli appchain create foundation init
16-
bun run synd-cli appchain create features init
41+
synd-cli appchain create foundation init
42+
synd-cli appchain create features init
1743
```
1844

1945
2. **Edit the generated config files** in `options/` with your values
2046

2147
3. **Deploy contracts:**
2248
```bash
23-
bun run synd-cli appchain create foundation --config options/foundation.json
24-
bun run synd-cli appchain create features --config options/features.json
49+
synd-cli appchain create foundation --config options/foundation.json
50+
synd-cli appchain create features --config options/features.json
2551
```
2652

2753
4. **Save the private keys** displayed during deployment (sequencer, proposer, etc.)
@@ -36,10 +62,10 @@ Most commands support an `init` subcommand that generates an example config file
3662

3763
```bash
3864
# Generate example config
39-
bun run synd-cli appchain create foundation init
65+
synd-cli appchain create foundation init
4066

4167
# Use the config file
42-
bun run synd-cli appchain create foundation --config options/foundation.json
68+
synd-cli appchain create foundation --config options/foundation.json
4369
```
4470

4571
Config files use kebab-case keys matching CLI flag names. CLI flags can override config file values.
@@ -49,7 +75,7 @@ Config files use kebab-case keys matching CLI flag names. CLI flags can override
4975
All options can also be passed as CLI flags. Run any command with `--help` to see available options:
5076

5177
```bash
52-
bun run synd-cli appchain create foundation --help
78+
synd-cli appchain create foundation --help
5379
```
5480

5581
## Creating a New Appchain
@@ -76,7 +102,7 @@ Deploys additional contracts that depend on the Appchain node:
76102
77103
## Available Commands
78104

79-
Run `bun run synd-cli` to see all available commands. Main command categories:
105+
Run `synd-cli` to see all available commands. Main command categories:
80106

81107
- `appchain create` - Deploy various contract sets (foundation, features, sequencing, withdrawals, etc.)
82108
- `appchain handoff` - Transfer contract ownership

synd-cli/install.sh

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Syndicate CLI Installer
5+
# Usage:
6+
# curl -L https://raw.githubusercontent.com/SyndicateProtocol/syndicate-appchains/main/synd-cli/install.sh | bash
7+
# curl -L https://raw.githubusercontent.com/SyndicateProtocol/syndicate-appchains/main/synd-cli/install.sh | SYND_VERSION=synd-cli-v1.0.0 bash
8+
9+
REPO="SyndicateProtocol/syndicate-appchains"
10+
INSTALL_DIR="${SYND_INSTALL_DIR:-$HOME/.synd/bin}"
11+
BINARY_NAME="synd-cli"
12+
13+
# Colors for output
14+
RED='\033[0;31m'
15+
GREEN='\033[0;32m'
16+
YELLOW='\033[1;33m'
17+
NC='\033[0m' # No Color
18+
19+
info() {
20+
printf "${GREEN}info${NC}: %s\n" "$1"
21+
}
22+
23+
warn() {
24+
printf "${YELLOW}warn${NC}: %s\n" "$1"
25+
}
26+
27+
error() {
28+
printf "${RED}error${NC}: %s\n" "$1"
29+
exit 1
30+
}
31+
32+
detect_platform() {
33+
local os arch
34+
35+
# Detect OS
36+
case "$(uname -s)" in
37+
Linux*) os="linux" ;;
38+
Darwin*) os="darwin" ;;
39+
*) error "Unsupported operating system: $(uname -s)" ;;
40+
esac
41+
42+
# Detect architecture
43+
case "$(uname -m)" in
44+
x86_64|amd64) arch="x64" ;;
45+
arm64|aarch64) arch="arm64" ;;
46+
*) error "Unsupported architecture: $(uname -m)" ;;
47+
esac
48+
49+
echo "${os}-${arch}"
50+
}
51+
52+
get_latest_version() {
53+
local latest
54+
# Find the latest synd-cli release (tags starting with "synd-cli-")
55+
latest=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases" | \
56+
grep '"tag_name"' | \
57+
sed -E 's/.*"([^"]+)".*/\1/' | \
58+
grep '^synd-cli-' | \
59+
head -n 1)
60+
61+
if [[ -z "$latest" ]]; then
62+
error "Failed to fetch latest synd-cli version. Please check your internet connection or specify a version with SYND_VERSION=synd-cli-vX.Y.Z"
63+
fi
64+
65+
echo "$latest"
66+
}
67+
68+
download_binary() {
69+
local version="$1"
70+
local platform="$2"
71+
local url="https://github.com/${REPO}/releases/download/${version}/${BINARY_NAME}-${platform}-${version}"
72+
local tmp_file
73+
74+
tmp_file=$(mktemp)
75+
76+
info "Downloading synd-cli ${version} for ${platform}..."
77+
78+
if ! curl -fsSL "$url" -o "$tmp_file"; then
79+
rm -f "$tmp_file"
80+
error "Failed to download from ${url}. Please check that version ${version} exists and has binaries for ${platform}."
81+
fi
82+
83+
echo "$tmp_file"
84+
}
85+
86+
install_binary() {
87+
local tmp_file="$1"
88+
local install_path="${INSTALL_DIR}/${BINARY_NAME}"
89+
90+
# Create install directory
91+
mkdir -p "$INSTALL_DIR"
92+
93+
# Move binary to install location
94+
mv "$tmp_file" "$install_path"
95+
chmod +x "$install_path"
96+
97+
info "Installed synd-cli to ${install_path}"
98+
}
99+
100+
setup_path_instructions() {
101+
local shell_name
102+
local rc_file
103+
104+
shell_name=$(basename "$SHELL")
105+
106+
case "$shell_name" in
107+
bash)
108+
if [[ -f "$HOME/.bash_profile" ]]; then
109+
rc_file="$HOME/.bash_profile"
110+
else
111+
rc_file="$HOME/.bashrc"
112+
fi
113+
;;
114+
zsh) rc_file="$HOME/.zshrc" ;;
115+
fish) rc_file="$HOME/.config/fish/config.fish" ;;
116+
*) rc_file="your shell's config file" ;;
117+
esac
118+
119+
# Check if already in PATH
120+
if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
121+
info "synd-cli is ready to use!"
122+
else
123+
echo ""
124+
warn "Add synd-cli to your PATH by running:"
125+
echo ""
126+
if [[ "$shell_name" == "fish" ]]; then
127+
printf " fish_add_path %s\n" "$INSTALL_DIR"
128+
else
129+
printf " echo 'export PATH=\"%s:\$PATH\"' >> %s\n" "$INSTALL_DIR" "$rc_file"
130+
fi
131+
echo ""
132+
printf "Then restart your shell or run:\n"
133+
printf " source %s\n" "$rc_file"
134+
echo ""
135+
fi
136+
}
137+
138+
main() {
139+
local version="${SYND_VERSION:-}"
140+
local platform
141+
142+
info "Syndicate CLI Installer"
143+
echo ""
144+
145+
# Detect platform
146+
platform=$(detect_platform)
147+
info "Detected platform: ${platform}"
148+
149+
# Get version (use provided or fetch latest)
150+
if [[ -z "$version" ]]; then
151+
info "Fetching latest version..."
152+
version=$(get_latest_version)
153+
fi
154+
info "Version: ${version}"
155+
156+
# Download binary
157+
local tmp_file
158+
tmp_file=$(download_binary "$version" "$platform")
159+
160+
# Install binary
161+
install_binary "$tmp_file"
162+
163+
# Show PATH setup instructions
164+
setup_path_instructions
165+
166+
info "Installation complete!"
167+
}
168+
169+
main "$@"

0 commit comments

Comments
 (0)