mirror of
https://gitlab.com/sagidayan/linux-config.git
synced 2024-11-22 23:35:26 +00:00
47 lines
1.4 KiB
YAML
47 lines
1.4 KiB
YAML
|
---
|
||
|
- name: Validate manual versioning folder
|
||
|
ansible.builtin.file:
|
||
|
state: directory
|
||
|
path: ~/.ansible_gh_release_versions
|
||
|
|
||
|
- name: Setting local release file path
|
||
|
set_fact:
|
||
|
local_version_file: "~/.ansible_gh_release_versions/{{ name }}"
|
||
|
|
||
|
- name: Fetch latest release tarball url
|
||
|
shell:
|
||
|
cmd: curl -s https://api.github.com/repos/{{ repo }}/releases/latest | jq -r '.assets[] | select(.browser_download_url|test("{{ filter }}")) | .browser_download_url'
|
||
|
warn: false
|
||
|
register: tar_url
|
||
|
changed_when: false
|
||
|
|
||
|
- name: Get latest version tag from github
|
||
|
shell: echo {{ tar_url.stdout }} | grep -oP "(?<=download\/).*(?=\/)"
|
||
|
changed_when: false
|
||
|
register: version
|
||
|
|
||
|
- name: Get latest version from local entry
|
||
|
set_fact:
|
||
|
local_version: "{{ lookup('file', local_version_file, errors='ignore') }}"
|
||
|
version: "{{ version.stdout }}"
|
||
|
tar_url: "{{ tar_url.stdout }}"
|
||
|
tar_download_location: "/tmp/{{ name }}.tar.gz"
|
||
|
failed_when: false
|
||
|
|
||
|
- name: Unarchive the release
|
||
|
ansible.builtin.unarchive:
|
||
|
src: "{{ tar_url }}"
|
||
|
dest: /tmp/
|
||
|
remote_src: yes
|
||
|
when: version != local_version
|
||
|
|
||
|
- name: Moving bin to /usr/local/bin
|
||
|
become: true
|
||
|
shell: |
|
||
|
cp /tmp{{ bin_path }} /usr/local/bin/{{ name }}
|
||
|
when: version != local_version
|
||
|
|
||
|
- name: Updating local version entry
|
||
|
shell: echo {{ version }} > {{ local_version_file }}
|
||
|
when: version != local_version
|