nostr/build/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 23 Jul 2023 11:08:34 -0500
changeset 219 0faea2a7570f
parent 217 e69a030975c4
child 224 25e44d8440d4
permissions -rw-r--r--
Updated relayer whitelisted for custom nip11 info.

---

- 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