nostr/build/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 16 Sep 2023 01:39:37 -0500
changeset 223 de03976c2df1
parent 219 0faea2a7570f
child 224 25e44d8440d4
permissions -rw-r--r--
Unifi-7.5 release doesnt seem to support arm so I held the version at 7.4.

---

- name: install golang
  become: yes
  apt: name="golang-go"

- name: unarchive nostr relayer
  unarchive:
    remote_src: yes
    src: "{{relayer_tar}}"
    dest: "/tmp/"
    creates: "{{relayer_build_dir}}"

# update name
- name: update relayer nip11 info
  lineinfile:
    path: "{{relayer_main_src}}"
    regexp: "^(\\s*)return \"WhitelistedRelay\"$"
    line: "\\1return \"{{relayer_name}}\""
    backrefs: yes

# update nip11 relay info
- name: update relayer nip11 info
  lineinfile:
    path: "{{relayer_handler_src}}"
    regexp: "^(\\s*){{item.k}}(\\s*)(.*)$"
    line: "\\1{{item.k}}\\2\"{{item.v}}\","
    backrefs: yes
  loop:
    - {"k": "Description:", "v": "{{relayer_description}}"}
    - {"k": "PubKey:", "v": "{{relayer_admin_pubkey}}"}
    - {"k": "Contact:", "v": "{{relayer_admin_contact}}"}
    - {"k": "Version:", "v": "{{relayer_version}}"}

- name: check if relayer build exists
  stat:
    path: "{{relayer_build_dir}}/whitelisted/whitelisted"
  register: build_file

- name: build relayer
  command: "go build"
  args:
    chdir: "{{relayer_build_dir}}/whitelisted"
  when: not build_file.stat.exists

- name: create build server dir
  become: yes
  file:
    path: "{{relayer_srv_dir}}"
    mode: "0755"
    state: "directory"
  when: not build_file.stat.exists

- name: copy bin to build server dir
  become: yes
  copy:
    remote_src: yes
    src: "{{relayer_build_dir}}/whitelisted/whitelisted"
    dest: "{{relayer_srv_dir}}/nostr-relayer-whitelisted"
  when: not build_file.stat.exists