Remove two useless comments.
[stakingWatchdogWatchdog.git] / deploy.nu
1 # 'zigbuild' is needed to build for target 'x86_64-unknown-linux-gnu' on linux:
2 # https://github.com/rust-cross/cargo-zigbuild
3
4 def main [host: string, destination: string, ssh_key: path] {
5     let ssh_args = [-i $ssh_key $host]
6     let scp_args = [-r -i $ssh_key]
7     let target = "x86_64-unknown-linux-gnu"
8     let app_name = "staking_watchdog_watchdog"
9     let build = "release" # "debug" or "release".
10
11     def invoke_ssh [command: string] {
12         let args = $ssh_args ++ $command
13         print $"Executing: ssh ($args)"
14         ssh $args
15     }
16
17     def copy_ssh [source: string, destination: string] {
18         let args = $scp_args ++ [$source $"($host):($destination)"]
19         print $"Executing: scp ($args)"
20         scp $args
21     }
22
23     # Don't know how to dynamically pass variable arguments.
24     if $build == "release" {
25         cargo zigbuild --target $target --release
26     } else {
27         cargo zigbuild --target $target
28     }
29
30     invoke_ssh $"systemctl --user stop ($app_name)"
31     copy_ssh ./target/($target)/($build)/($app_name) $destination
32     invoke_ssh $"chmod u+x ($destination)/($app_name)"
33     invoke_ssh $"systemctl --user start ($app_name)"
34     print "Deployment finished"
35 }