dotfiles/github-bin/doctl.yml

45 lines
1.7 KiB
YAML

- name: "Discover the latest {{ gh_project }} release from GitHub"
community.general.github_release:
user: "{{ gh_user }}"
repo: "{{ gh_project }}"
action: latest_release
register: release_latest
- name: Set the release version strings
ansible.builtin.set_fact:
release_latest_tag: "{{ release_latest['tag'] }}"
release_latest_trim: "{{ release_latest['tag'] | regex_replace('^v','') }}"
- name: Set the checksum filename
ansible.builtin.set_fact:
release_checksum: "{{ gh_project }}-{{ release_latest_trim }}-checksums.sha256"
- name: Set the release download filename for aarch64
ansible.builtin.set_fact:
release_filename: "{{ gh_project }}-{{ release_latest_trim }}-linux-arm64.tar.gz"
when: ansible_facts['architecture'] == "aarch64"
- name: Set the release download filename for x86_64
ansible.builtin.set_fact:
release_filename: "{{ gh_project }}-{{ release_latest_trim }}-linux-amd64.tar.gz"
when: ansible_facts['architecture'] == "x86_64"
- name: Check if the release was previously downloaded
ansible.builtin.stat:
path: "{{ gh_bin_dir }}/{{ release_filename }}"
register: release_local
- name: "Download the latest {{ gh_project }} release from GitHub"
ansible.builtin.get_url:
url: "https://github.com/{{ gh_user }}/{{ gh_project }}/releases/download/{{ release_latest_tag }}/{{ release_filename }}"
dest: "{{ gh_bin_dir }}"
mode: "0644"
checksum: sha256:https://github.com/{{ gh_user }}/{{ gh_project }}/releases/download/{{ release_latest['tag'] }}/{{ release_checksum }}
when: not release_local.stat.exists
register: doctl_dl
- name: "doctl updated"
ansible.builtin.unarchive:
src: "{{ gh_bin_dir }}/{{ release_filename }}"
dest: "{{ home_dir }}/bin"
when: doctl_dl.changed