src.nth.io/

summaryrefslogtreecommitdiff
path: root/bin/build/tasks/main.yaml
blob: 8da49b65403db9ae5d63f668af47d0338876d3f1 (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
---

- 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 cargo
  become: yes
  apt: name="cargo"

- name: unarchive bin
  unarchive:
    remote_src: yes
    src: "{{bin_tar}}"
    dest: "{{build_work_dir}}/"
    creates: "{{bin_build_dir}}"

- name: check if bin build exists
  stat:
    path: "{{bin_srv_dir}}/bin-{{bin_version}}.tar.gz"
  register: build_file

- name: build bin
  command: "cargo build --release"
  args:
    chdir: "{{bin_build_dir}}"
  # Keep the cargo cache on build_work_dir (the SSD) instead of the SD card.
  environment:
    CARGO_HOME: "{{build_work_dir}}/.cargo"
  when: not build_file.stat.exists

- name: create build server dir
  become: yes
  file:
    path: "{{bin_srv_dir}}"
    mode: "0755"
    state: "directory"

- name: create gz archive of bin
  become: yes
  archive:
    path: "{{bin_build_dir}}/target/release/bin"
    dest: "{{bin_srv_dir}}/bin-{{bin_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