2021-07-16 02:43:58 +02:00
|
|
|
---
|
|
|
|
- name: "Check gitea installed version"
|
2023-01-27 01:35:16 +01:00
|
|
|
ansible.builtin.shell: "set -eo pipefail; {{ gitea_full_executable_path }} -v | cut -d' ' -f 3"
|
2021-07-16 02:43:58 +02:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
register: gitea_active_version
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: "Determine 'latest' version release"
|
2022-09-29 23:09:19 +02:00
|
|
|
when: gitea_version == "latest"
|
2021-07-16 02:43:58 +02:00
|
|
|
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
|
2023-03-20 17:31:27 +01:00
|
|
|
become: false
|
2022-06-21 12:11:12 +02:00
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: "Fail if running in check mode without versions set."
|
2022-06-21 17:22:57 +02:00
|
|
|
ansible.builtin.fail:
|
|
|
|
msg: |
|
|
|
|
"You are running this playbook in check mode:
|
|
|
|
Please set the Gitea version with the variable 'gitea_version', because the URI module cannot detect the latest version in this mode."
|
2022-09-29 23:09:19 +02:00
|
|
|
when: ansible_check_mode and (gitea_version == 'latest' or gitea_version == 'present')
|
2021-07-19 00:55:37 +02:00
|
|
|
|
2021-07-16 02:43:58 +02:00
|
|
|
- name: "Set fact latest gitea release"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_remote_version: "{{ gitea_remote_metadata.json.tag_name[1:] }}"
|
2022-06-21 12:11:12 +02:00
|
|
|
when: not ansible_check_mode
|
2021-07-19 00:55:37 +02:00
|
|
|
|
2021-07-16 02:43:58 +02:00
|
|
|
- name: "Set gitea version target (latest)"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_version_target: "{{ gitea_remote_version }}"
|
2022-06-21 17:22:57 +02:00
|
|
|
when: not ansible_check_mode
|
2021-07-16 02:43:58 +02:00
|
|
|
|
2022-09-29 23:09:19 +02:00
|
|
|
- name: "Set gitea version target {{ gitea_version }}"
|
2021-07-16 02:43:58 +02:00
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_version_target: "{{ gitea_version }}"
|
|
|
|
when: gitea_version != "latest"
|
|
|
|
|
2024-01-08 16:47:39 +01:00
|
|
|
- name: 'Assert that remote version is higher'
|
|
|
|
ansible.builtin.assert:
|
|
|
|
that:
|
|
|
|
- gitea_active_version is version(gitea_remote_version, 'lt')
|
2024-01-08 16:54:10 +01:00
|
|
|
fail_msg: ERROR - Remote version is lower then current version!
|
2024-01-12 00:50:37 +01:00
|
|
|
when: gitea_version == "latest" and gitea_active_version.stderr == "" | bool
|
2024-01-08 16:47:39 +01:00
|
|
|
|
2021-07-16 02:43:58 +02:00
|
|
|
- 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 }}"
|