-
Notifications
You must be signed in to change notification settings - Fork 57
151 lines (119 loc) · 4.93 KB
/
release.yaml
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
env:
NAMESPACE: checkmk
COLLECTION_NAME: general
name: Release Collection
on: # yamllint disable-line rule:truthy
workflow_dispatch:
jobs:
#
# Run sanity checks prior to release.
#
sanity:
runs-on: ubuntu-latest
name: Sanity (Ⓐ${{ matrix.ansible }})
strategy:
fail-fast: false
matrix:
ansible:
- stable-2.14
- stable-2.15
- stable-2.16
- devel
steps:
- name: Check out code
uses: actions/checkout@v4
with:
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Run sanity tests
run: ansible-test sanity --docker -v --color --coverage
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
release:
needs: sanity
runs-on: ubuntu-latest
steps:
#
# Prepare the environment.
#
- name: Checkout code
uses: actions/checkout@v4
- name: Get current version
id: current_version
run: echo "version=$(grep 'version:' galaxy.yml | cut -d ' ' -f 2)" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
#
# First stage: Build and install collection to generate docs and changelogs.
#
- name: Copy Files and Directories to Source
run: |
mkdir -p build/src
cp $files build/src
cp -rf $directories build/src
env:
files: "ansible.cfg CHANGELOG.rst galaxy.yml LICENSE README.md"
directories: "changelogs docs meta playbooks plugins roles"
- name: Build Ansible Collection
run: ansible-galaxy collection build build/src --force
- name: Install Ansible Collection
run: ansible-galaxy collection install --no-deps ./${{env.NAMESPACE}}-${{env.COLLECTION_NAME}}-${{ steps.current_version.outputs.version }}.tar.gz
- name: Compile Collection Changelog
run: antsibull-changelog release
- name: Compile Collection Docs
run: antsibull-docs collection --use-current --squash-hierarchy --fail-on-error --dest-dir ./docs/ ${{env.NAMESPACE}}.${{env.COLLECTION_NAME}}
- name: Create Pull Request for docs and changelog against devel branch
uses: peter-evans/create-pull-request@v6
with:
commit-message: Update Docs and Changelogs upon Release
signoff: false
branch: changelogs-docs-update-devel
base: devel
delete-branch: true
title: '[Auto] Update changelogs and docs upon release'
body: |
Changelogs and docs updated during *${{ steps.current_version.outputs.version }}* release.
assignees: robin-checkmk
reviewers: robin-checkmk
draft: false
#
# Second stage: Build the final version of the collection and release it.
#
- name: Copy Files and Directories to Source
run: |
mkdir -p build/src
cp $files build/src
cp -rf $directories build/src
rm -rf build/src/roles/*/molecule
env:
files: "CHANGELOG.rst LICENSE README.md ansible.cfg galaxy.yml"
directories: "changelogs docs meta playbooks plugins roles"
- name: Build Ansible Collection
run: ansible-galaxy collection build build/src --force
- name: Create Release and upload Assets
id: create-release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
name: v${{ steps.current_version.outputs.version }}
tag_name: v${{ steps.current_version.outputs.version }}
files: ${{env.NAMESPACE}}-${{env.COLLECTION_NAME}}-${{ steps.current_version.outputs.version }}.tar.gz
body: |
# Ansible Collection: ${{env.NAMESPACE}}.${{env.COLLECTION_NAME}}
For information about this collection and how to install it, refer to the [README](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/README.md).
For a detailed changelog, refer to the [CHANGELOG](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/CHANGELOG.rst).
- name: Publish Ansible Collection to the Galaxy
run: ansible-galaxy collection publish ${{env.NAMESPACE}}-${{env.COLLECTION_NAME}}-${{ steps.current_version.outputs.version }}.tar.gz --api-key ${{ secrets.GALAXY_API_KEY }}