Skip to content

poyea/relais

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

relais

Git-driven CI/CD.

git push relais-production main

Flow diagram

Install

Download the latest binary from Releases and put it on your PATH:

# Linux (x86_64)
curl -fsSL https://github.com/poyea/relais/releases/latest/download/relais-linux-x86_64 \
  -o ~/.local/bin/relais && chmod +x ~/.local/bin/relais

# Linux (ARM64)
curl -fsSL https://github.com/poyea/relais/releases/latest/download/relais-linux-aarch64 \
  -o ~/.local/bin/relais && chmod +x ~/.local/bin/relais

# Windows x86_64 (PowerShell)
irm https://github.com/poyea/relais/releases/latest/download/relais-windows-x86_64.exe `
  -OutFile "$env:LOCALAPPDATA\Microsoft\WindowsApps\relais.exe"

# Windows ARM64 (PowerShell)
irm https://github.com/poyea/relais/releases/latest/download/relais-windows-aarch64.exe `
  -OutFile "$env:LOCALAPPDATA\Microsoft\WindowsApps\relais.exe"

Or build from source.

How it works

  1. You need a .relais.json.
  2. Run relais init for bootstrapping.
  3. Deploy by pushing to that remote. The hook runs on the server: checks out the branch, then runs your script.

Requirements

  • Local: Zig 0.14.0 (to build), an SSH key, Git
  • Server: Linux, Git, Bash, base64 (standard on all distros)

.relais.json

Commit this to your repo root.

{
  "targets": {
    "production": {
      "host": "prod.example-service.com",
      "user": "deploy",
      "ssh_key": "~/.ssh/id_relais",
      "port": 22,
      "remote_dir": "/srv/myapp",
      "script": "./scripts/deploy.sh",
      "branches": ["main"]
    },
    "staging": {
      "host": "staging.example-service.com",
      "user": "deploy",
      "ssh_key": "~/.ssh/id_relais",
      "remote_dir": "/srv/myapp-staging",
      "script": "./scripts/deploy.sh",
      "branches": ["develop"]
    }
  }
}
Field Required Default Description
host βœ“ SSH hostname or IP
user βœ“ SSH user on the server
ssh_key βœ“ Path to private key (~ is expanded)
port 22 SSH port
remote_dir βœ“ Directory on the server to check out into
script βœ“ Path to deploy script, relative to remote_dir
branches βœ“ Only pushes to these branches trigger the script

Usage

relais init               # bootstrap all targets in .relais.json
relais init production    # bootstrap one target

git push relais-production main     # deploy
git push relais-staging develop

relais version

Deploy script

relais doesn't care what your script does. A minimal example:

#!/usr/bin/env bash
# scripts/deploy.sh that runs inside remote_dir on the server
set -euo pipefail
docker compose pull
docker compose up -d --remove-orphans

Build from source

# Install Zig 0.14.0: https://ziglang.org/download/

git clone https://github.com/poyea/relais
cd relais

zig build                                      # native debug binary β†’ zig-out/bin/relais
zig build -Doptimize=ReleaseSafe               # native optimised
zig build linux -Doptimize=ReleaseSafe         # static x86_64-linux-musl
zig build windows -Doptimize=ReleaseSafe       # x86_64-windows
zig build all -Doptimize=ReleaseSafe           # both release targets
zig build test                                 # run unit tests

Binaries land in zig-out/bin/.

License

MIT

About

πŸš€ Git-driven CI/CD in Zig

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors