-
Notifications
You must be signed in to change notification settings - Fork 2
215 lines (179 loc) · 6.27 KB
/
release.yml
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: CI
on:
push:
branches: [master]
pull_request:
env:
NAMESPACE: zscaler
COLLECTION_NAME: zpacloud
PYTHON_VERSION: 3.8
jobs:
## Sanity is required:
#
# https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html
sanity:
name: Sanity (Ⓐ${{ matrix.ansible }})
strategy:
matrix:
include:
- ansible: "2.14"
python_ver: "3.11"
- ansible: "2.15"
python_ver: "3.11"
- ansible: "2.16"
python_ver: "3.11"
- ansible: "2.17"
python_ver: "3.11"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
steps:
- uses: actions/checkout@v4
with:
path: ./ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_ver }}
- name: Install Poetry
uses: Gr1N/setup-poetry@v9
# Install the head of the given branch (devel, stable-2.10)
- name: Install ansible-base (${{ matrix.ansible }})
run: poetry run pip install https://github.com/ansible/ansible/archive/stable-${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Create lock file
run: poetry lock
- name: Install dependencies
run: poetry install
- name: Run sanity tests
timeout-minutes: 10
run: poetry run make new-sanity
format:
name: Code Format Check
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
steps:
- uses: actions/checkout@v4
with:
path: ./ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: Gr1N/setup-poetry@v9
- name: Install dependencies
run: poetry install
- name: Do black code format
run: poetry run make format
- name: Do black code check-format
run: poetry run make check-format
release:
name: release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [sanity, format]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# This task could be removed once the task below is confirmed working
- name: Set up Galaxy auth
run: |
mkdir -p ~/.ansible
echo "token: $GALAXY_API_KEY" > ~/.ansible/galaxy_token
env:
GALAXY_API_KEY: ${{ secrets.GALAXY_API_KEY }}
shell: bash
# New task for combined Galaxy and AutomationHub publishing
- name: Set up Automation Hub and Galaxy ansible.cfg file
run: |
cat << EOF > ansible.cfg
[galaxy]
server_list = automation_hub, release_galaxy
[galaxy_server.automation_hub]
url=${{ secrets.AUTOMATION_HUB_URL }}
auth_url=${{ secrets.AUTOMATION_HUB_SSO_URL }}
token=${{ secrets.AUTOMATION_HUB_API_TOKEN }}
[galaxy_server.release_galaxy]
url=https://galaxy.ansible.com/
token=${{ secrets.GALAXY_API_KEY }}
EOF
shell: bash
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Create release and publish
id: release
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 17.1.1
extra_plugins: |
conventional-changelog-conventionalcommits@^4.4.0
@semantic-release/changelog@^5.0.1
@semantic-release/git@^9.0.0
@semantic-release/exec@^5.0.0
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Store built collection
uses: actions/upload-artifact@v4
with:
name: collection
path: |
*.tar.gz
docs:
name: docs
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [release]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ansible_collections/zscaler/zpacloud
steps:
# Just a note here: The Ansible stuff is apparently doing realpath
# checks, so trying to simlink stuff and then run Ansible commands
# such as ansible-test in the symlink directory fails. Thus we need
# to have the real path contain ansible_collections/zscaler/zpacloud.
- name: Checkout
uses: actions/checkout@v4
with:
path: ./ansible_collections/zscaler/zpacloud
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Poetry
uses: Gr1N/setup-poetry@v9
- name: Add ansible-core
run: poetry add ansible-core^2.14
- name: Add antsibull-docs
run: poetry add antsibull-docs^2.10.0
- name: Install dependencies
run: poetry install
- name: Build the collection
run: poetry run ansible-galaxy collection build
- name: Install built collection
run: poetry run ansible-galaxy collection install *.tar.gz
- name: Generate documentation
run: poetry run make docs
# This is here for right now because the action to deploy seems to assume
# (and not have a configuration option to) mirror the actions/checkout@v4
# the with.path spec.
- name: Move the repo to where the deploy action is looking for it
run: |
cd ../../../..
mv zpacloud-ansible the_repo
mv the_repo/ansible_collections/zscaler/zpacloud zpacloud-ansible
mkdir -p zpacloud-ansible/ansible_collections/zscaler/zpacloud
- name: Deploy to GitHub Pages
uses: JamesIves/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: docs/html
clean: true