2022-01-03 09:46:10 +00:00
|
|
|
---
|
|
|
|
- name: Validate manual versioning folder
|
|
|
|
ansible.builtin.file:
|
|
|
|
state: directory
|
|
|
|
path: ~/.ansible_gh_release_versions
|
2022-01-18 09:19:19 +00:00
|
|
|
mode: '0755'
|
2022-01-03 09:46:10 +00:00
|
|
|
|
|
|
|
- name: Setting local release file path
|
|
|
|
set_fact:
|
|
|
|
local_version_file: "~/.ansible_gh_release_versions/{{ name }}"
|
|
|
|
|
|
|
|
- name: Fetch latest release tarball url
|
2023-02-21 13:00:51 +00:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: curl -s https://api.github.com/repos/{{ repo }}/releases/latest | jq -r '.assets[] | select(.browser_download_url|test("{{ filter }}")) | .browser_download_url'
|
2022-01-03 09:46:10 +00:00
|
|
|
register: tar_url
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: Get latest version tag from github
|
2023-02-21 13:00:51 +00:00
|
|
|
ansible.builtin.shell:
|
2022-01-18 09:19:19 +00:00
|
|
|
cmd: 'echo {{ tar_url.stdout }} | grep -oP "(?<=download\/).*(?=\/)"'
|
2022-01-03 09:46:10 +00:00
|
|
|
changed_when: false
|
|
|
|
register: version
|
|
|
|
|
|
|
|
- name: Get latest version from local entry
|
|
|
|
set_fact:
|
2022-11-06 14:07:55 +00:00
|
|
|
local_version: "{{ lookup('file', local_version_file, errors='ignore') | default(NOT_FOUND) }}"
|
2022-01-03 09:46:10 +00:00
|
|
|
version: "{{ version.stdout }}"
|
|
|
|
tar_url: "{{ tar_url.stdout }}"
|
2022-11-06 14:07:55 +00:00
|
|
|
tar_download_location: "/tmp/{{ name }}.tar.gz"
|
2022-01-03 09:46:10 +00:00
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: Unarchive the release
|
|
|
|
ansible.builtin.unarchive:
|
|
|
|
src: "{{ tar_url }}"
|
|
|
|
dest: /tmp/
|
|
|
|
remote_src: yes
|
|
|
|
when: version != local_version
|
|
|
|
|
2022-01-18 09:19:19 +00:00
|
|
|
- name: Unarchive release source
|
|
|
|
ansible.builtin.unarchive:
|
|
|
|
src: "https://github.com/{{ repo }}/archive/refs/tags/{{ version }}.tar.gz"
|
|
|
|
dest: /tmp/
|
|
|
|
remote_src: yes
|
|
|
|
when: version != local_version and (include_source is defined)
|
|
|
|
|
2022-01-03 09:46:10 +00:00
|
|
|
- name: Moving bin to /usr/local/bin
|
|
|
|
become: true
|
2023-02-21 13:00:51 +00:00
|
|
|
ansible.builtin.shell: |
|
2022-01-05 12:32:39 +00:00
|
|
|
cp /tmp{{ bin_path }} /usr/local/bin/
|
2022-01-03 09:46:10 +00:00
|
|
|
when: version != local_version
|
|
|
|
|
2022-01-05 12:32:39 +00:00
|
|
|
- name: Adding man page if needed
|
|
|
|
become: true
|
2023-02-21 13:00:51 +00:00
|
|
|
ansible.builtin.shell: |
|
2022-01-05 12:32:39 +00:00
|
|
|
cp /tmp{{ man_path }} /usr/share/man/man1/
|
|
|
|
register: added_man
|
|
|
|
when: man_path is defined and (version != local_version)
|
|
|
|
|
|
|
|
- name: Update mandb if needed
|
|
|
|
become: true
|
2023-02-21 13:00:51 +00:00
|
|
|
ansible.builtin.shell: mandb || true
|
2022-01-09 14:30:43 +00:00
|
|
|
when: added_man is defined and (version != local_version)
|
2022-01-05 12:32:39 +00:00
|
|
|
|
|
|
|
- name: Adding autocomplete if needed
|
2023-02-21 13:00:51 +00:00
|
|
|
ansible.builtin.shell: |
|
2022-01-18 09:19:19 +00:00
|
|
|
cp /tmp/{{ autocomplete_path }} ~/.shellconfig/autocomplete/{{ name }}.autocomplete
|
2022-01-05 12:32:39 +00:00
|
|
|
when: autocomplete_path is defined and (version != local_version)
|
|
|
|
|
2022-01-03 09:46:10 +00:00
|
|
|
- name: Updating local version entry
|
2023-02-21 13:00:51 +00:00
|
|
|
ansible.builtin.shell: echo {{ version }} > {{ local_version_file }}
|
2022-01-03 09:46:10 +00:00
|
|
|
when: version != local_version
|
2022-01-05 12:32:39 +00:00
|
|
|
|