diff --git a/obal/data/playbooks/update/metadata.obal.yaml b/obal/data/playbooks/update/metadata.obal.yaml index 8d136e7d..1ca2e573 100644 --- a/obal/data/playbooks/update/metadata.obal.yaml +++ b/obal/data/playbooks/update/metadata.obal.yaml @@ -27,3 +27,5 @@ variables: commit: help: When true, creates a git branch and commits the update changes to it. action: store_true + template: + help: The template to use diff --git a/obal/data/playbooks/update/update.yaml b/obal/data/playbooks/update/update.yaml index 44acfdb2..707e485e 100644 --- a/obal/data/playbooks/update/update.yaml +++ b/obal/data/playbooks/update/update.yaml @@ -7,6 +7,11 @@ - git_annex_setup - spec_file tasks: + - name: Read changelog + changelog: + spec: "{{ spec_file_path }}" + register: changelog + - name: Determine source file from spec shell: "spectool --list-files --all {{ spec_file_path }} | awk '{print $2}'" args: @@ -23,9 +28,18 @@ when: - "'://' in item" - - name: 'Fetch sources' + - name: 'update spec file' + include_role: + name: update_spec_file + + - name: 'update source files' include_role: - name: fetch_sources + name: setup_sources + + - name: Run spec update template + shell: "gem2rpm -o {{ spec_file_path }} -t {{ template }} {{ inventory_dir }}/{{ package_base_dir }}/{{ inventory_hostname }}/*.gem" + args: + chdir: "{{ inventory_dir }}" - name: Determine new source file from spec shell: "spectool --list-files --all {{ spec_file_path }} | awk '{print $2}'" @@ -51,6 +65,33 @@ when: - "'://' not in item" + - name: Add back changelog + lineinfile: + path: "{{ spec_file_path }}" + insertafter: "%changelog" + line: "{{ changelog.changelog }}" + + - name: Check for updates + command: git status --porcelain + register: git_status + args: + chdir: "{{ inventory_dir }}" + + - when: git_status.stdout + block: + - name: 'Bump release' + command: "rpmdev-bumpspec {{ spec_file_path | basename }} -c \"Update spec file\"" + args: + chdir: "{{ spec_file_path | dirname }}" + changed_when: true + when: version is not defined + + - name: 'Add changelog entry' + changelog: + spec: "{{ spec_file_path }}" + entry: "Release {{ version }}" + when: version is defined + - hosts: - packages gather_facts: false