1
1
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_gitea.git synced 2024-08-16 11:39:50 +02:00
ansible_role_gitea/tasks/set_version.yml
Robert Pufky 39e76e2359 Add 'latest' version to automatically download the latest gitea release.
* Versioning logic moved into separate file; versioning is determined in that
  file and appropriate facts are set.
* Removed 'gitea_dl_url' from defaults/main.yml. This is now a generated fact
  from tasks/set_version.yml.
* Remote gitea version is only checked if 'latest' is set, otherwise no logic
  change.
* 'gitea_version' used in tasks is now 'gitea_version_target'. This is the
  target install version after versioning logic is applied. No change to end
  user usage of 'gitea_version' in defaults/main.yml.
* Updated documentation with usage and removal of 'gitea_dl_url'.
2021-07-16 10:16:54 -07:00

34 lines
1.2 KiB
YAML

---
- name: "Check gitea installed version"
ansible.builtin.shell: "set -eo pipefail; /usr/local/bin/gitea -v | cut -d' ' -f 3"
args:
executable: /bin/bash
register: gitea_active_version
changed_when: false
failed_when: false
- name: "Determine 'latest' version release"
block:
- name: "Get latest gitea release metadata"
ansible.builtin.uri:
url: https://api.github.com/repos/go-gitea/gitea/releases/latest
return_content: true
register: gitea_remote_metadata
- name: "Set fact latest gitea release"
ansible.builtin.set_fact:
gitea_remote_version: "{{ gitea_remote_metadata.json.tag_name[1:] }}"
- name: "Set gitea version target (latest)"
ansible.builtin.set_fact:
gitea_version_target: "{{ gitea_remote_version }}"
when: gitea_version == "latest"
- name: "Set gitea version target ({{ gitea_version }})"
ansible.builtin.set_fact:
gitea_version_target: "{{ gitea_version }}"
when: gitea_version != "latest"
- name: "Generate gitea download URL"
ansible.builtin.set_fact:
gitea_dl_url: "https://github.com/go-gitea/gitea/releases/download/v{{ gitea_version_target }}/gitea-{{ gitea_version_target }}-linux-{{ gitea_arch }}"