1 # 'zigbuild' is needed to build for target 'x86_64-unknown-linux-gnu' on linux:
2 # https://github.com/rust-cross/cargo-zigbuild
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"
9 let build = "debug" # "debug" or "release".
11 def invoke_ssh [command: string] {
12 let args = $ssh_args ++ $command
13 print $"Executing: ssh ($args)"
17 def copy_ssh [source: string, destination: string] {
18 let args = $scp_args ++ [$source $"($host):($destination)"]
19 print $"Executing: scp ($args)"
23 # Don't know how to dynamically pass variable arguments.
24 if $build == "release" {
25 cargo zigbuild --target $target --release
27 cargo zigbuild --target $target
30 # invoke_ssh [sudo systemctl stop $app_name]
31 copy_ssh ./target/($target)/($build)/($app_name) $destination
32 invoke_ssh $"chmod u+x ($destination)/($app_name)"
33 # invoke_ssh [sudo systemctl start $app_name]
34 print "Deployment finished"