1 unstable release
| 0.1.2 | Feb 17, 2026 |
|---|
#399 in Build Utils
36KB
783 lines
postloop
Post-commit Loop - Local Git Auto-Deployment Tool
Overview
postloop is a local Git auto-deployment tool written in Rust, designed for solo developers. The core concept is: after code commit, automatically complete the "build → deploy → sync to GitHub" cycle.
Features
1. Post-commit Hook Trigger
- Provides
postloop initcommand to install post-commit hook in the target Git repository - Hook script automatically triggers postloop deployment process after each
git commit
2. Auto Build
- Executes build commands based on
build.commandin the configuration file - Supports any build command (e.g.,
cargo build --release,npm run build,go build) - Logs and terminates process on build failure
3. Auto Deploy
- Supports two deployment methods:
- Process Deployment: Execute custom deployment command (e.g.,
systemctl restart app.service) - File Deployment: Copy build artifacts to target directory (
target_dir)
- Process Deployment: Execute custom deployment command (e.g.,
- Supports rollback to previous version on deployment failure
4. Sync to GitHub
- Automatically executes
git pushto sync code to remote GitHub repository after successful deployment - Specify remote name and branch in configuration file
- Logs push failures but doesn't affect local deployment result
5. Rollback Support
- Keeps the most recent N versions of build artifacts (configurable)
- Automatically rolls back to last successful version on deployment failure
6. Logging
- All operations (build, deploy, sync, rollback) logged to local log file
- Logs include timestamp, commit hash, operation results
Installation
cargo install --path .
Or build from source:
git clone https://github.com/lipish/postloop.git
cd postloop
cargo build --release
sudo cp target/release/postloop /usr/local/bin/
Quick Start
- Initialize postloop in your Git repository:
cd /path/to/your/repo
postloop init
- Edit the generated
deploy.tomlconfiguration file:
[build]
command = "cargo build --release"
[deploy]
target_dir = "/opt/deploy"
artifacts = ["target/release/my-app"]
- Commit your code, and postloop will automatically deploy:
git add .
git commit -m "Your changes"
# postloop runs automatically via post-commit hook
- Or run manually:
postloop run
CLI Commands
postloop init— Initialize postloop in current Git repository (installs post-commit hook, generates default deploy.toml)postloop run— Manually trigger complete build→deploy→sync pipelinepostloop rollback— Manually rollback to previous versionpostloop rollback --version <hash>— Rollback to specific versionpostloop status— View current deployment status and recent deployment historypostloop log— View deployment logspostloop log --lines 100— View last 100 lines of logs
Configuration File (deploy.toml)
See deploy.toml.example for a complete configuration example.
[watch]
repo_path = "."
branch = "main"
[build]
command = "cargo build --release"
[deploy]
# Option 1: Process deployment
command = "systemctl restart app.service"
# Option 2: File deployment
target_dir = "/opt/deploy"
artifacts = ["target/release/my-app"]
[sync]
enabled = true
remote = "origin"
branch = "main"
[rollback]
enabled = true
keep_versions = 3
[log]
file = "postloop.log"
level = "info"
Requirements
- Git
- Rust 1.70+ (for building)
Platform Support
- ✅ Linux
- ✅ macOS
- ✅ Windows
License
MIT
Dependencies
~2.3–3.5MB
~62K SLoC