---
- name: Get latest Caddy release details
  uri:
    url: https://api.github.com/repos/mholt/caddy/releases/latest
    return_content: true
    headers: '{{ caddy_github_headers }}'
  register: latest_caddy_release

- name: Set Caddy tag
  set_fact:
    caddy_tag: "{{ (latest_caddy_release.content | from_json).get('tag_name') }}"

- name: Set Caddy version
  set_fact:
    caddy_version: "{{ caddy_tag | regex_replace('^v', '') }}"

- name: Set Caddy url
  set_fact:
    caddy_url: "https://github.com/caddyserver/caddy/releases/download/\
                {{ caddy_tag }}/caddy_{{ caddy_version }}_{{ caddy_os }}_{{ go_arch }}.tar.gz"
