aboutsummaryrefslogtreecommitdiff
path: root/build.zig
blob: bff42c48dcd0402bdeff0a1afadda137384a2f16 (plain) (blame)
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
const std = @import("std");
const webgen = @import("webgen");

pub fn build(b: *std.Build) void {
    const run_webgen = webgen.installHtmlStep(b);
    run_webgen.addDirectoryArg(b.path("src"));

    const bundle_html = b.addSystemCommand(&.{ "tar", "--exclude=pages.tar.gz", "-czvf", "html-out/pages.tar.gz", "html-out" });
    bundle_html.step.dependOn(&run_webgen.step);
    b.getInstallStep().dependOn(&bundle_html.step);

    const serve = b.addSystemCommand(&.{ "lighttpd", "-Df" });
    serve.addFileArg(b.path("util/lighttpd.conf"));
    const run_server = b.step("serve", "Run a local test server");
    serve.step.dependOn(b.getInstallStep());
    run_server.dependOn(&serve.step);

    const publish_to_prod = b.step("publish", "Publish the website to production");
    const copy_bundle = b.addSystemCommand(&.{"scp"});
    copy_bundle.step.dependOn(b.getInstallStep());
    copy_bundle.addFileArg(b.path("html-out/pages.tar.gz"));
    copy_bundle.addArg("debian@www.eviltransgenders.club:pages.tar.gz");

    const unpack_bundle = b.addSystemCommand(&.{ "ssh", "debian@www.eviltransgenders.club", "cp pages.tar.gz /var/www/www.eviltransgenders.club && cd /var/www/www.eviltransgenders.club && tar -xvf /var/www/www.eviltransgenders.club/pages.tar.gz" });
    unpack_bundle.step.dependOn(&copy_bundle.step);
    publish_to_prod.dependOn(&unpack_bundle.step);

    const clean_html = b.addSystemCommand(&.{"rm", "-rf"});
    clean_html.addFileArg(b.path("html-out"));
    clean_html.addFileArg(b.path("zig-out"));
    b.getUninstallStep().dependOn(&clean_html.step);
}