SSH deployment tool inspired by PHP Envoy
go install github.com/yejune/gorelay@latestOr build from source:
git clone https://github.com/yejune/gorelay.git
cd gorelay
go install .# 1. Initialize in your project folder
gorelay init
# 2. Edit Gorelayfile.yaml (server info, task settings)
# 3. Run deployment
gorelay deploy| Command | Description |
|---|---|
gorelay |
Show available tasks (if Gorelayfile.yaml exists) |
gorelay init |
Create Gorelayfile.yaml template |
gorelay list |
List available tasks |
gorelay <task> |
Run a task |
gorelay <task> --on=<server> |
Run on specific server only |
gorelay <task> -v |
Run with verbose output |
gorelay help |
Show help |
# Server definitions
servers:
production:
host: example.com
user: ubuntu
key: ~/.ssh/id_rsa # default: ~/.ssh/id_rsa
port: 22 # default: 22
staging:
host: staging.example.com
user: deploy
# Task definitions
tasks:
deploy:
description: "Deploy to production"
on: [production] # servers to run on (defaults to first server)
scripts:
- local: echo "Building locally"
- sync: ./app:/remote/path/app
- run: sudo systemctl restart myapp
logs:
description: "View logs"
on: [production]
scripts:
- run: sudo journalctl -u myapp -fscripts:
- local: npm run buildscripts:
- sync: ./server:/app/server
- sync: ./dist:/var/www/htmlFeatures:
- Compares SHA256 checksums before upload
- Only uploads changed files
- Verifies integrity after upload
scripts:
- tar: ./server:/app/server
- tar: ./dist:/var/www/htmlFeatures:
- Creates tar.gz in memory
- Uploads and extracts on remote server
- Atomic: all or nothing (no partial uploads)
- Best for production deployments
scripts:
- scp: ./server:/app/server
- scp: ./dist:/var/www/htmlFeatures:
- Fastest method (no checksum comparison)
- Uploads all files unconditionally
- Use for quick development deploys
scripts:
- run: echo "Hello from server"
- run: |
cd /app
./server restart
sudo systemctl restart myapp| Method | Checksum | Atomic | Speed | Use Case |
|---|---|---|---|---|
sync |
✓ (before + after) | ✗ | Medium | Incremental deploys |
tar |
✓ (tar content) | ✓ | Medium | Production deploys |
scp |
✗ | ✗ | Fast | Development deploys |
servers:
production:
host: example.com
user: ubuntu
key: ~/.ssh/id_rsa
tasks:
deploy:
description: "Deploy to production"
on: [production]
scripts:
# 1. Build for Linux locally
- local: GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o server-linux .
# 2. Upload with tar (atomic)
- tar: server-linux:/app/server-new
# 3. Replace and restart on server
- run: |
cd /app
mv server server-old 2>/dev/null || true
mv server-new server
chmod +x server
sudo systemctl restart myapp
# 4. Clean up local build file
- local: rm -f server-linux
status:
description: "Check service status"
on: [production]
scripts:
- run: sudo systemctl status myapp --no-pager
logs:
description: "Real-time logs"
on: [production]
scripts:
- run: sudo journalctl -u myapp -f
rollback:
description: "Rollback to previous version"
on: [production]
scripts:
- run: |
cd /app
mv server server-failed
mv server-old server
sudo systemctl restart myappGorelayonment variables can be used in Gorelayfile.yaml:
servers:
production:
host: $DEPLOY_HOST
user: $DEPLOY_USER
key: $SSH_KEY_PATHservers:
web:
hosts:
- web1.example.com
- web2.example.com
- web3.example.com
user: ubuntu
tasks:
deploy:
on: [web] # automatically expands to web[0], web[1], web[2]
parallel: true
scripts:
- tar: ./app:/app/server-new
- run: sudo systemctl restart myapptasks:
deploy:
on: [web1, web2] # runs sequentially
scripts:
- tar: ./app:/app/server-new
- run: sudo systemctl restart myapptasks:
deploy:
on: [web1, web2, web3]
parallel: true # run on all servers simultaneously
scripts:
- tar: ./app:/app/server-new
- run: sudo systemctl restart myappWhen running in parallel:
- Deploys to all servers simultaneously
- Output from each server is buffered and displayed in order
- Returns error if any server fails
gorelay deploy --on=web1Enable file logging in Gorelayfile.yaml:
log:
enabled: true
path: ./gorelay.log # default: gorelay.logWhen enabled, all output is saved to the log file with timestamps.
Use -v flag for detailed output:
gorelay deploy -vShows:
- SHA256 checksums for uploads
- Elapsed time for each step
- Total execution time
MIT