summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/vmware/tools/prepare_release.yml
blob: 3d52dd28cc053716feebfad2cefda4ec5de924fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
- hosts: localhost
  tasks:
    - name: Generate version
      block:
        - name: Get the next release version
          ansible.builtin.shell: git tag --sort=-creatordate --merged|head -n1|perl -pe 's/(\d+\.)(\d+)\.\d+/"$1" . ($2+1) . ".0"/e'
          register: result

        - name: Set the release version
          ansible.builtin.set_fact:
            version: "{{ result.stdout }}"
      when: version is not defined

    - name: Create release branch
      ansible.builtin.shell: git checkout -b "prepare_{{ version }}_release"

    - name: Update galaxy.yml
      ansible.builtin.lineinfile:
        path: "{{ playbook_dir }}/../galaxy.yml"
        regexp: "^version: "
        line: "version: {{ version }}"

    - name: Update changelog
      block:
        - name: Install tox
          ansible.builtin.pip:
            name: tox

        - name: Refresh the changelog
          ansible.builtin.shell: 'tox -e antsibull-changelog -- release --verbose --version {{ version }}'

    - name: Add everything
      ansible.builtin.shell: git add --all

    # git diff-index --quiet HEAD
    #   0 -> repository is clean, nothing to commit
    #   1 -> the opposite
    - name: Commit everything
      ansible.builtin.shell: 'git diff-index --quiet HEAD || git commit -m "prepare {{ version }} release"'