plz / deploy.vsh
35 lines · 28 sloc · 986 bytes · 1adb1cd122a6e2f2ae8b54f0709bf06eb7b0599d
Raw
1#!/usr/bin/env -S v run
2
3import os
4import term
5
6const server = 'gitly'
7const remote_path = '/var/www/gitly'
8const local_binary = 'gitly_linux'
9
10fn main() {
11 if !os.exists(local_binary) {
12 eprintln(term.red('${local_binary} not found. Build it first with:'))
13 eprintln(' ~/code/v3/v -os linux -d use_openssl -cc clang -gc none -prealloc -cflags "-O2" -o ${local_binary} .')
14 exit(1)
15 }
16
17 println('Step 1: Syncing binary, static/ and translations/...')
18 rsync := 'rsync -avz'
19 exec_safe('${rsync} ${local_binary} ${server}:${remote_path}/gitly')
20 exec_safe('${rsync} static/ ${server}:${remote_path}/static/')
21 exec_safe('${rsync} translations/ ${server}:${remote_path}/translations/')
22
23 println('\nStep 2: Restarting gitly...')
24 exec_safe('ssh ${server} "sudo systemctl restart gitly"')
25
26 println(term.green('\nDeployment successful!'))
27}
28
29fn exec_safe(cmd string) {
30 println('>>> ${cmd}')
31 if os.system(cmd) != 0 {
32 eprintln(term.red('\n Error executing command.'))
33 exit(1)
34 }
35}
36