forked from os-climate/osc-github-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
315 lines (282 loc) · 10.6 KB
/
build-test-release.yaml
File metadata and controls
315 lines (282 loc) · 10.6 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
---
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2025 The Linux Foundation
# Runs on a new pull request, performs build and runs tests
name: 'Python Build/Test/Release'
# yamllint disable-line rule:truthy
on:
# Trigger on tag push events
push:
tags:
- '**'
permissions: {}
jobs:
repository:
name: 'Repository'
# yamllint disable-line rule:line-length
uses: os-climate/osc-github-devops/.github/workflows/reuse-inspect-repository.yaml@50a55963fb815139987f49c15f7380eb5d028974 # Pre v0.1.30
permissions:
contents: read
tag-validate:
name: 'Validate tag push'
needs: repository
runs-on: 'ubuntu-24.04'
permissions:
contents: read
timeout-minutes: 1
outputs:
tag: "${{ steps.tag-validate.outputs.tag }}"
steps:
# Harden the runner used by this workflow
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
- name: 'Verify Pushed Tag'
id: tag-validate
# yamllint disable-line rule:line-length
uses: lfreleng-actions/tag-push-verify-action@f9c6e753870c6405883be2ba18af05d075aaffe8 # v0.1.0
with:
versioning: 'semver'
dynamic-version-check:
name: 'Dynamic Version Check'
runs-on: ubuntu-24.04
needs: repository
if: needs.repository.outputs.python_project == 'true'
outputs:
dynamic_version: ${{ steps.dynamic-version.outputs.dynamic_version }}
permissions:
contents: read
timeout-minutes: 1
steps:
# Harden the runner used by this workflow
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Check for dynamic versioning'
id: dynamic-version
# yamllint disable-line rule:line-length
uses: lfreleng-actions/python-dynamic-version-action@757278a7dce3add2c777305e7ec61d9e2b97ed7e # v0.1.6
python-build:
name: 'Python Build'
needs:
- repository
- tag-validate
- dynamic-version-check
if: needs.repository.outputs.python_project == 'true'
runs-on: 'ubuntu-24.04'
outputs:
matrix_json: "${{ steps.python-build.outputs.matrix_json }}"
artefact_name: "${{ steps.python-build.outputs.artefact_name }}"
artefact_path: "${{ steps.python-build.outputs.artefact_path }}"
permissions:
contents: write
id-token: write # Needed for attestations
attestations: write # Needed for attestations
timeout-minutes: 12
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
# Harden the runner used by this workflow
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Build Python project'
id: python-build
# yamllint disable-line rule:line-length
uses: modeseven-lfreleng-actions/python-build-action@build-requirements-fix # Testing
# yamllint disable-line rule:line-length
# uses: lfreleng-actions/python-build-action@56dd541a74b5cf9f0c5939ed98387478824720a2 # v0.1.8
with:
# Only pass tag if NOT using dynamic versioning
# yamllint disable-line rule:line-length
tag: ${{ needs.dynamic-version-check.outputs.dynamic_version == 'true' && '' || needs.tag-validate.outputs.tag }}
# Skip version patching when using dynamic versioning
skip_version_patch: ${{ needs.dynamic-version-check.outputs.dynamic_version == 'true' }}
sigstore_sign: true
attestations: true
python-tests:
name: 'Python Tests'
runs-on: 'ubuntu-24.04'
needs:
- python-build
# Matrix job
strategy:
fail-fast: false
matrix: "${{ fromJson(needs.python-build.outputs.matrix_json) }}"
permissions:
contents: read
timeout-minutes: 12
steps:
# Harden the runner used by this workflow
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Test Python project [PYTEST]'
# yamllint disable-line rule:line-length
uses: modeseven-lfreleng-actions/python-test-action@update-action # Testing
# yamllint disable-line rule:line-length
# uses: lfreleng-actions/python-test-action@b06828bf94ae4beef00d49cddc06839eca2d8f05 # v0.1.6
with:
python_version: "${{ matrix.python-version }}"
python-audit:
name: 'Python Audit'
runs-on: 'ubuntu-24.04'
needs:
- python-build
# Matrix job
strategy:
fail-fast: false
matrix: "${{ fromJson(needs.python-build.outputs.matrix_json) }}"
permissions:
contents: read
timeout-minutes: 10
steps:
# Harden the runner used by this workflow
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Audit Python project'
# yamllint disable-line rule:line-length
uses: lfreleng-actions/python-audit-action@4c51bc76f9876b4f294f8afa4bb002b0b89aec68 # v0.1.3
with:
python_version: "${{ matrix.python-version }}"
notebooks:
name: 'Test Jupyter Notebooks'
runs-on: 'ubuntu-24.04'
if: needs.repository.outputs.jupyter_notebooks == 'true'
needs:
- repository
- python-build
# Matrix job
strategy:
fail-fast: false
matrix: "${{ fromJson(needs.python-build.outputs.matrix_json) }}"
permissions:
contents: read
timeout-minutes: 10
steps:
# Harden the runner used by this workflow
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# yamllint disable-line rule:line-length
- uses: lfreleng-actions/python-notebook-test-action@471123b59d0ef608f95bece4d36a95ebabab0a68 # v0.1.1
with:
python_version: "${{ matrix.python-version }}"
test-pypi:
name: 'Test PyPI Publishing'
runs-on: 'ubuntu-24.04'
needs:
- tag-validate
- repository
- python-tests
- python-audit
- notebooks
environment:
name: development
permissions:
contents: read
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
timeout-minutes: 5
steps:
# Harden the runner used by this workflow
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Test PyPI publishing'
# yamllint disable-line rule:line-length
uses: lfreleng-actions/pypi-publish-action@81a056957ed050f8305760055b1fd8103a916989 # v0.1.1
with:
environment: 'development'
tag: "${{ needs.tag-validate.outputs.tag }}"
pypi:
name: 'Release PyPI Package'
runs-on: 'ubuntu-24.04'
needs:
- tag-validate
- test-pypi
environment:
name: production
permissions:
contents: read
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
timeout-minutes: 5
steps:
# Harden the runner used by this workflow
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'PyPI release'
# yamllint disable-line rule:line-length
uses: lfreleng-actions/pypi-publish-action@81a056957ed050f8305760055b1fd8103a916989 # v0.1.1
with:
environment: 'production'
attestations: true
tag: "${{ needs.tag-validate.outputs.tag }}"
promote-release:
name: 'Promote Draft Release'
# yamllint disable-line rule:line-length
if: startsWith(github.ref, 'refs/tags/')
needs:
- tag-validate
- pypi
runs-on: 'ubuntu-24.04'
permissions:
contents: write
# id-token: write
timeout-minutes: 2
outputs:
release_url: "${{ steps.promote-release.outputs.release_url }}"
steps:
# Harden the runner used by this workflow
# yamllint disable-line rule:line-length
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
# yamllint disable-line rule:line-length
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Promote draft release'
id: promote-release
# yamllint disable-line rule:line-length
uses: modeseven-lfreleng-actions/draft-release-promote-action@output-release-url # Testing
# yamllint disable-line rule:line-length
# uses: lfreleng-actions/draft-release-promote-action@0392844e1e08a0539b63ba1940a7a2bfa2bda077 # v0.1.1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
tag: "${{ needs.tag-validate.outputs.tag }}"
latest: true
# Need to attach build artefacts to the release
# This step could potentially be moved
# (May be better to when/where the release is still in draft state)
attach-artefacts:
name: 'Attach Artefacts to Release'
runs-on: 'ubuntu-24.04'
needs:
- tag-validate
- python-build
- promote-release
permissions:
contents: write
timeout-minutes: 5
steps:
# Harden the runner used by this workflow
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
# Note: should not need a checkout step
- name: 'Attach artefacts to release'
# yamllint disable-line rule:line-length
uses: modeseven-lfreleng-actions/release-attach-artefacts-action@initial-update # Testing
with:
# Probably only need one of these in the implementation; decide later
tag: "${{ needs.tag-validate.outputs.tag }}"
release_url: "${{ needs.promote-release.outputs.release_url }}"
artefact_name: "${{ needs.python-build.outputs.artefact_name }}"
artefact_path: "${{ needs.python-build.outputs.artefact_path }}"