blob: 5f40b93f49344d4590d2914f8d54524523dd2388 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
---
- name: ensure build work dir exists
become: yes
file:
path: "{{build_work_dir}}"
state: "directory"
owner: "{{ansible_user}}"
group: "{{ansible_user}}"
mode: "0755"
- name: install golang
become: yes
apt: name="golang-1.21-go"
- name: link go bin
become: yes
file:
src: "/usr/lib/go-1.21/bin/go"
dest: "/usr/bin/go"
state: "link"
mode: "0755"
- name: git checkout lnurld
git:
repo: "{{lnurld_git}}"
dest: "{{lnurld_build_dir}}"
version: "{{lnurld_version}}"
- name: check if build exists
stat:
path: "{{lnurld_srv_dir}}/lnurld-{{lnurld_version}}.tar.gz"
register: build_file
- name: build
command: "go build"
args:
chdir: "{{lnurld_build_dir}}"
# Keep the Go caches on build_work_dir (the SSD) instead of the SD card.
environment:
GOPATH: "{{build_work_dir}}/.go"
GOCACHE: "{{build_work_dir}}/.go-cache"
GOMODCACHE: "{{build_work_dir}}/.go-mod"
when: not build_file.stat.exists
- name: create build server dir
become: yes
file:
path: "{{lnurld_srv_dir}}"
mode: "0755"
state: "directory"
- name: create gz archive of lnurld
become: yes
archive:
path: "{{lnurld_build_dir}}/lnurld"
dest: "{{lnurld_srv_dir}}/lnurld-{{lnurld_version}}.tar.gz"
format: "gz"
# force a real tar for the single binary; the module otherwise gzips a lone
# file into a bare .gz that the server's unarchive can't extract.
force_archive: true
when: not build_file.stat.exists
|