summaryrefslogtreecommitdiff
path: root/Cargo.toml
blob: fb8e20df9bc92eb00c3d9d102b23b790d4c7ed17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
[package]
name = "witryna"
version = "0.1.0"
edition = "2024"
authors = ["Dawid Rycerz"]
description = "Minimalist Git-based static site deployment orchestrator"
homepage = "https://git.craftknight.com/dawid/witryna"
repository = "https://git.craftknight.com/dawid/witryna.git"
license = "MIT"

[features]
default = []
integration = []

[dependencies]
anyhow = "1.0.100"
clap = { version = "4", features = ["derive"] }
subtle = "2.6"
axum = "0.8.8"
chrono = "0.4.43"
dashmap = "6.1.0"
governor = "0.8"
serde = { version = "1.0.228", features = ["derive"] }
serde_yaml_ng = "0.10"
tokio = { version = "1.49.0", features = ["rt-multi-thread", "macros", "fs", "process", "net", "signal", "sync", "time", "io-util", "io-std"] }
toml = "0.9.11"
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
humantime = "2.3.0"
tokio-util = "0.7.18"
serde_json = "1.0"

[dev-dependencies]
tower = "0.5"
reqwest = { version = "0.12" }
tempfile = "3"
nix = { version = "0.29", features = ["signal"] }
serial_test = "3"

[build-dependencies]
clap = { version = "4", features = ["derive"] }
clap_mangen = "0.2.31"

[profile.release]
strip = true
lto = true
panic = "abort"

[package.metadata.deb]
maintainer = "Dawid Rycerz"
copyright = "2026, Dawid Rycerz"
extended-description = """\
Witryna is a minimalist Git-based static site deployment orchestrator. \
It listens for webhook triggers, pulls Git repositories, runs \
containerized build commands, and publishes static assets via atomic \
symlink switching."""
section = "web"
priority = "optional"
depends = "$auto, adduser, systemd"
recommends = "podman | docker.io"
maintainer-scripts = "debian/"
conf-files = ["/etc/witryna/witryna.toml"]
assets = [
    ["target/release/witryna", "usr/bin/", "755"],
    ["target/man/witryna.1", "usr/share/man/man1/witryna.1", "644"],
    ["man/witryna.toml.5", "usr/share/man/man5/witryna.toml.5", "644"],
    ["examples/witryna.toml", "etc/witryna/witryna.toml", "644"],
    ["README.md", "usr/share/doc/witryna/README.md", "644"],
    ["examples/hooks/caddy-deploy.sh", "usr/share/doc/witryna/examples/hooks/caddy-deploy.sh", "755"],
    ["examples/caddy/Caddyfile", "usr/share/doc/witryna/examples/caddy/Caddyfile", "644"],
    ["examples/nginx/witryna.conf", "usr/share/doc/witryna/examples/nginx/witryna.conf", "644"],
    ["examples/witryna.yaml", "usr/share/doc/witryna/examples/witryna.yaml", "644"],
    ["examples/systemd/docker.conf", "usr/share/doc/witryna/examples/systemd/docker.conf", "644"],
    ["examples/systemd/podman.conf", "usr/share/doc/witryna/examples/systemd/podman.conf", "644"],
]

[package.metadata.deb.systemd-units]
unit-scripts = "debian/"
enable = true
start = false
restart-after-upgrade = true

[package.metadata.generate-rpm]
summary = "Minimalist Git-based static site deployment orchestrator"
description = """\
Witryna is a minimalist Git-based static site deployment orchestrator. \
It listens for webhook triggers, pulls Git repositories, runs \
containerized build commands, and publishes static assets via atomic \
symlink switching."""
group = "Applications/Internet"
release = "1"
assets = [
    { source = "target/release/witryna", dest = "/usr/bin/witryna", mode = "755" },
    { source = "target/man/witryna.1", dest = "/usr/share/man/man1/witryna.1", mode = "644", doc = true },
    { source = "man/witryna.toml.5", dest = "/usr/share/man/man5/witryna.toml.5", mode = "644", doc = true },
    { source = "examples/witryna.toml", dest = "/etc/witryna/witryna.toml", mode = "644", config = "noreplace" },
    { source = "debian/witryna.service", dest = "/usr/lib/systemd/system/witryna.service", mode = "644" },
    { source = "README.md", dest = "/usr/share/doc/witryna/README.md", mode = "644", doc = true },
    { source = "examples/hooks/caddy-deploy.sh", dest = "/usr/share/doc/witryna/examples/hooks/caddy-deploy.sh", mode = "755", doc = true },
    { source = "examples/caddy/Caddyfile", dest = "/usr/share/doc/witryna/examples/caddy/Caddyfile", mode = "644", doc = true },
    { source = "examples/nginx/witryna.conf", dest = "/usr/share/doc/witryna/examples/nginx/witryna.conf", mode = "644", doc = true },
    { source = "examples/witryna.yaml", dest = "/usr/share/doc/witryna/examples/witryna.yaml", mode = "644", doc = true },
    { source = "examples/systemd/docker.conf", dest = "/usr/share/doc/witryna/examples/systemd/docker.conf", mode = "644", doc = true },
    { source = "examples/systemd/podman.conf", dest = "/usr/share/doc/witryna/examples/systemd/podman.conf", mode = "644", doc = true },
]
post_install_script = """\
#!/bin/bash
set -e
# Create system user/group (idempotent)
if ! getent group witryna >/dev/null 2>&1; then
    groupadd --system witryna
fi
if ! getent passwd witryna >/dev/null 2>&1; then
    useradd --system --gid witryna --no-create-home \
        --home-dir /var/lib/witryna --shell /sbin/nologin witryna
fi
# Create data + log directories
install -d -o witryna -g witryna -m 0755 /var/lib/witryna
install -d -o witryna -g witryna -m 0755 /var/lib/witryna/clones
install -d -o witryna -g witryna -m 0755 /var/lib/witryna/builds
install -d -o witryna -g witryna -m 0755 /var/lib/witryna/cache
install -d -o witryna -g witryna -m 0755 /var/log/witryna
# Fix config permissions (root owns, witryna group can read)
if [ -f /etc/witryna/witryna.toml ]; then
    chown root:witryna /etc/witryna/witryna.toml
    chmod 640 /etc/witryna/witryna.toml
fi
# Auto-detect and configure container runtime
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
    if getent group docker >/dev/null; then
        usermod -aG docker witryna || true
    fi
    mkdir -p /etc/systemd/system/witryna.service.d
    cp /usr/share/doc/witryna/examples/systemd/docker.conf \
       /etc/systemd/system/witryna.service.d/10-runtime.conf
    chmod 644 /etc/systemd/system/witryna.service.d/10-runtime.conf
    systemctl daemon-reload >/dev/null 2>&1 || true
    echo "witryna: Docker detected and configured."
elif command -v podman >/dev/null 2>&1 && podman info >/dev/null 2>&1; then
    if ! grep -q "^witryna:" /etc/subuid 2>/dev/null; then
        usermod --add-subuids 100000-165535 witryna || true
    fi
    if ! grep -q "^witryna:" /etc/subgid 2>/dev/null; then
        usermod --add-subgids 100000-165535 witryna || true
    fi
    loginctl enable-linger witryna >/dev/null 2>&1 || true
    mkdir -p /etc/systemd/system/witryna.service.d
    cp /usr/share/doc/witryna/examples/systemd/podman.conf \
       /etc/systemd/system/witryna.service.d/10-runtime.conf
    chmod 644 /etc/systemd/system/witryna.service.d/10-runtime.conf
    systemctl daemon-reload >/dev/null 2>&1 || true
    echo "witryna: Podman detected and configured."
else
    echo "witryna: WARNING — no container runtime (docker/podman) detected."
    echo "  Install one, then reinstall this package or copy an override from"
    echo "  /usr/share/doc/witryna/examples/systemd/ manually."
fi
# Reload systemd
systemctl daemon-reload >/dev/null 2>&1 || true
# Enable (but don't start) on fresh install — matches deb behavior
if [ "$1" -eq 1 ]; then
    systemctl enable witryna.service >/dev/null 2>&1 || true
fi"""
pre_uninstall_script = """\
#!/bin/bash
if [ "$1" -eq 0 ]; then
    systemctl stop witryna.service >/dev/null 2>&1 || true
    systemctl disable witryna.service >/dev/null 2>&1 || true
fi"""
post_uninstall_script = """\
#!/bin/bash
if [ "$1" -eq 0 ]; then
    # Remove user and group
    userdel witryna >/dev/null 2>&1 || true
    groupdel witryna >/dev/null 2>&1 || true
    # Remove config directory and systemd overrides
    rm -rf /etc/witryna
    rm -rf /etc/systemd/system/witryna.service.d
    loginctl disable-linger witryna >/dev/null 2>&1 || true
    # /var/lib/witryna and /var/log/witryna left for manual cleanup
    # Reload systemd
    systemctl daemon-reload >/dev/null 2>&1 || true
fi"""

[package.metadata.generate-rpm.requires]
systemd = "*"
shadow-utils = "*"
git = "*"

[package.metadata.generate-rpm.recommends]
podman = "*"