src.nth.io/

summaryrefslogtreecommitdiff
path: root/lnurld/build/tasks/main.yaml
blob: 79488bc979fa13827af6120dbc7e49d31f49f505 (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
---

- name: ensure build work dir exists
  become: yes
  file:
    path: "{{build_work_dir}}"
    state: "directory"
    owner: "{{ansible_user}}"
    group: "{{ansible_user}}"
    mode: "0755"

# The unversioned package tracks the release default (1.26 on 26.04) and
# provides /usr/bin/go itself, so no pinned version or hand symlink.
- name: install golang
  become: yes
  apt: name="golang-go"

- 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