# 'zigbuild' is needed to build for target 'x86_64-unknown-linux-gnu' on linux: # https://github.com/rust-cross/cargo-zigbuild def main [host: string, destination: string, ssh_key: path] { let ssh_args = [-i $ssh_key $host] let scp_args = [-r -i $ssh_key] let target = "x86_64-unknown-linux-gnu" let app_name = "staking_watchdog" let build = "release" # "debug" or "release". def invoke_ssh [command: string] { let args = $ssh_args ++ $command print $"Executing: ssh ($args)" ssh ...$args } def copy_ssh [source: string, destination: string] { let args = $scp_args ++ [$source $"($host):($destination)"] print $"Executing: scp ($args)" scp ...$args } # Don't know how to dynamically pass variable arguments. if $build == "release" { cargo zigbuild --target $target --release } else { cargo zigbuild --target $target } invoke_ssh $"sudo systemctl stop ($app_name)" copy_ssh ./target/($target)/($build)/($app_name) $destination invoke_ssh $"chmod u+x ($destination)/($app_name)" invoke_ssh $"sudo systemctl start ($app_name)" print "Deployment finished" }