2023-01-27 01:35:16 +01:00
|
|
|
---
|
|
|
|
- name: "Check forgejo installed version"
|
|
|
|
ansible.builtin.shell: "set -eo pipefail; {{ gitea_full_executable_path }} -v | cut -d' ' -f 3"
|
|
|
|
args:
|
2023-10-29 16:11:12 +01:00
|
|
|
executable: '/bin/bash'
|
2023-01-27 01:35:16 +01:00
|
|
|
register: gitea_active_version
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: "Determine 'latest' version release"
|
|
|
|
when: gitea_version == "latest"
|
|
|
|
block:
|
|
|
|
- name: "Get latest forgejo release metadata"
|
|
|
|
ansible.builtin.uri:
|
|
|
|
url: 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases?limit=1'
|
|
|
|
return_content: true
|
|
|
|
register: gitea_forgejo_remote_metadata
|
2023-03-20 17:31:27 +01:00
|
|
|
become: false
|
2023-01-27 01:35:16 +01:00
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: "Fail if running in check mode without versions set."
|
|
|
|
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."
|
|
|
|
when: ansible_check_mode and (gitea_version == 'latest' or gitea_version == 'present')
|
|
|
|
|
|
|
|
- name: "Set fact latest forgejo release"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_remote_version: "{{ gitea_forgejo_remote_metadata.json.0.tag_name[1:] }}"
|
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: "Set forgejo version target (latest)"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_version_target: "{{ gitea_remote_version }}"
|
|
|
|
when: not ansible_check_mode
|
|
|
|
|
2023-05-10 00:08:43 +02:00
|
|
|
- name: "Set forgejo version target {{ gitea_version }}"
|
2023-01-27 01:35:16 +01:00
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_version_target: "{{ gitea_version }}"
|
|
|
|
when: gitea_version != "latest"
|
|
|
|
|
2023-05-10 00:08:43 +02:00
|
|
|
- name: "Download forgejo version {{ gitea_version_target }}"
|
2023-01-27 01:35:16 +01:00
|
|
|
when: not ansible_check_mode
|
2023-05-10 00:08:43 +02:00
|
|
|
block:
|
|
|
|
- name: "Get specific forgejo release metadata"
|
|
|
|
ansible.builtin.uri:
|
|
|
|
url: 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/tags/v{{ gitea_version_target }}'
|
|
|
|
return_content: true
|
|
|
|
register: gitea_forgejo_remote_tags_metadata
|
|
|
|
become: false
|
|
|
|
rescue:
|
|
|
|
- name: "Error Downloading https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/tags/v{{ gitea_version_target }}"
|
|
|
|
ansible.builtin.fail:
|
|
|
|
msg: "We did not find the forgejo version you specified. Are you sure that '{{ gitea_version_target }}' is a valid forgejo version?"
|
2023-01-27 01:35:16 +01:00
|
|
|
|
|
|
|
- name: "Generate forgejo download url"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_forgejo_dl_url: "{{ gitea_forgejo_remote_tags_metadata.json | community.general.json_query(gitea_forgejo_query_download) }}"
|
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: "Generate forgejo download checksum url"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_forgejo_checksum_url: "{{ gitea_forgejo_remote_tags_metadata.json | community.general.json_query(gitea_forgejo_query_checksum) }}"
|
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: Get forgejo checksum
|
|
|
|
ansible.builtin.uri:
|
|
|
|
url: "{{ gitea_forgejo_checksum_url | first }}"
|
|
|
|
return_content: true
|
|
|
|
register: _gitea_forgejo_dl_checksum
|
2023-03-20 17:31:27 +01:00
|
|
|
become: false
|
2023-01-27 01:35:16 +01:00
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: Set forjeo checksum
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_forgejo_checksum: "{{ _gitea_forgejo_dl_checksum.content.split(' ')[0] }}"
|
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: "Generate forgejo download signed url"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_forgejo_signed_url: "{{ gitea_forgejo_remote_tags_metadata.json | community.general.json_query(gitea_forgejo_query_signed) }}"
|
|
|
|
when: not ansible_check_mode
|
|
|
|
|
|
|
|
- name: "Set a example forgejo download link if in check mode"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_forgejo_dl_url: ['https://codeberg.org/attachments/a00333ad-250a-4d30-a764-9a37fb24f419']
|
|
|
|
when: ansible_check_mode
|
|
|
|
|
|
|
|
- name: "Set a example forgejo checksum link if in check mode"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_forgejo_checksum: 'f8c71464d1b250bf022eaa3df270c810950904ceb71da5cefc7ec24a034a4c87'
|
|
|
|
when: ansible_check_mode
|
|
|
|
|
|
|
|
- name: "Set a example forgejo checksum link if in check mode"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
gitea_forgejo_signed_url: ['https://codeberg.org/attachments/ae5e50c6-e86e-4202-b95f-f142e8138e2f']
|
|
|
|
when: ansible_check_mode
|
|
|
|
|
2024-01-08 16:50:45 +01:00
|
|
|
- name: 'Assert that remote version is higher'
|
|
|
|
ansible.builtin.assert:
|
|
|
|
that:
|
|
|
|
- gitea_active_version is version(gitea_remote_version, 'lt')
|
|
|
|
fail_msg: ERROR: Remote version is lower then current version!
|
|
|
|
|
2023-10-29 16:11:12 +01:00
|
|
|
- name: Show Download URLs # noqa: H500
|
2023-01-27 01:35:16 +01:00
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "{{ item }}"
|
|
|
|
verbosity: 1
|
2023-10-29 16:11:12 +01:00
|
|
|
loop:
|
2023-01-27 01:35:16 +01:00
|
|
|
- "gitea_forgejo_dl_url: {{ gitea_forgejo_dl_url | first }}"
|
|
|
|
- "gitea_forgejo_checksum: {{ gitea_forgejo_checksum }}"
|
|
|
|
- "gitea_forgejo_signed_url: {{ gitea_forgejo_signed_url | first }}"
|