1 def main [host: string, destination: string, ssh_key: path] {
2 let ssh_args = [-i $ssh_key $host]
3 let scp_args = [-r -i $ssh_key]
4 let target = "x86_64-unknown-linux-musl"
5 let app_name = "staking_watchdog"
6 let build = "debug" # "debug" or "release".
8 def invoke_ssh [command: string] {
9 let args = $ssh_args ++ $command
10 print $"Executing: ssh ($args)"
14 def copy_ssh [source: string, destination: string] {
15 let args = $scp_args ++ [$source $"($host):($destination)"]
16 print $"Executing: scp ($args)"
20 # Don't know how to dynamically pass variable arguments.
21 if $build == "release" {
22 cargo build --target $target --release
24 cargo build --target $target
27 # invoke_ssh [sudo systemctl stop $app_name]
28 copy_ssh ./target/($target)/($build)/($app_name) $destination
29 invoke_ssh $"chmod u+x ($destination)/($app_name)"
30 # invoke_ssh [sudo systemctl start $app_name]
31 print "Deployment finished"