Repository navigation
284 lines (245 loc) · 8.38 KB
/
Copy pathcd-monorepo.yml
File metadata and controls
284 lines (245 loc) · 8.38 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
name: CD - Monorepo
on:
workflow_dispatch:
inputs:
run_tests:
description: Run pre-release tests
type: boolean
default: true
bump_type:
description: Version bump type
type: choice
default: patch
options:
- patch
- minor
- major
release_syft_restrict:
description: Release syft-restrict
type: boolean
default: true
release_syft_permissions:
description: Release syft-permissions
type: boolean
default: true
release_syft_perms:
description: Release syft-perms
type: boolean
default: true
release_syft_migration:
description: Release syft-migration
type: boolean
default: true
release_syft_job:
description: Release syft-job
type: boolean
default: true
release_syft_dataset:
description: Release syft-dataset
type: boolean
default: true
release_syft_rds:
description: Release syft-rds
type: boolean
default: true
release_syft_enclave:
description: Release syft-enclave
type: boolean
default: true
release_syft_bg:
description: Release syft-bg
type: boolean
default: true
concurrency:
group: 'CD - Monorepo'
cancel-in-progress: false
jobs:
# Every job below pushes a bump commit straight to the branch, and the dev
# ruleset rejects that push after the upload. Refuse before anything runs.
preflight:
runs-on: ubuntu-latest
steps:
- name: Release only from a release branch
run: |
case "${{ github.ref }}" in
refs/heads/release/*) echo "Releasing from ${{ github.ref_name }}" ;;
*) echo "::error::Dispatch the release from a release/vX.Y branch, not ${{ github.ref_name }}"; exit 1 ;;
esac
# The test workflows come from this branch, like the code they test.
call-linting-tests:
needs: [preflight]
if: inputs.run_tests == true
uses: ./.github/workflows/ci.yml
call-unit-tests:
needs: [preflight]
if: inputs.run_tests == true
uses: ./.github/workflows/unit-tests.yml
call-integration-tests:
needs: [preflight]
if: inputs.run_tests == true
uses: ./.github/workflows/integration-tests.yml
secrets: inherit
# Release order follows the dependency graph. The jobs run one at a time:
# each pushes a bump commit, and two pushes from parallel jobs conflict.
# 1. syft-restrict (no internal deps)
# 2. syft-permissions (no internal deps)
# 3. syft-perms (depends on syft-permissions)
# 4. syft-migration (no internal deps; needed by dataset + job)
# 5. syft-dataset, then syft-job (depend on syft-perms + syft-migration)
# 6. syft (root; depends on the packages above, whose jobs rewrote its pins)
# 7. syft-rds (depends on syft, syft-job, syft-dataset)
# 8. syft-enclave, then syft-bg (depend on syft-rds)
# syft goes before the packages that depend on it, so a failure in one of
# them does not hold syft back.
release-syft-restrict:
needs:
[preflight, call-linting-tests, call-unit-tests, call-integration-tests]
if: >-
!cancelled() && !failure() &&
inputs.release_syft_restrict == true
uses: ./.github/workflows/cd-syft-restrict.yml
with:
bump_type: ${{ inputs.bump_type }}
secrets: inherit
release-syft-permissions:
needs: [release-syft-restrict]
if: >-
!cancelled() && !failure() &&
inputs.release_syft_permissions == true
uses: ./.github/workflows/cd-syft-permissions.yml
with:
bump_type: ${{ inputs.bump_type }}
secrets: inherit
release-syft-perms:
needs: [release-syft-permissions]
if: >-
!cancelled() && !failure() &&
inputs.release_syft_perms == true
uses: ./.github/workflows/cd-syft-perms.yml
with:
bump_type: ${{ inputs.bump_type }}
secrets: inherit
release-syft-migration:
needs: [release-syft-perms]
if: >-
!cancelled() && !failure() &&
inputs.release_syft_migration == true
uses: ./.github/workflows/cd-syft-migration.yml
with:
bump_type: ${{ inputs.bump_type }}
secrets: inherit
release-syft-dataset:
needs: [release-syft-migration]
if: >-
!cancelled() && !failure() &&
inputs.release_syft_dataset == true
uses: ./.github/workflows/cd-syft-dataset.yml
with:
bump_type: ${{ inputs.bump_type }}
secrets: inherit
release-syft-job:
needs: [release-syft-dataset]
if: >-
!cancelled() && !failure() &&
inputs.release_syft_job == true
uses: ./.github/workflows/cd-syft-job.yml
with:
bump_type: ${{ inputs.bump_type }}
secrets: inherit
release-syft-rds:
needs: [deploy-syft]
if: >-
!cancelled() && !failure() &&
inputs.release_syft_rds == true
# A called workflow cannot exceed the caller's token permissions, so the
# OIDC permission for trusted publishing has to be granted here as well.
permissions:
contents: write
id-token: write
uses: ./.github/workflows/cd-syft-rds.yml
with:
bump_type: ${{ inputs.bump_type }}
secrets: inherit
release-syft-enclave:
needs: [release-syft-rds]
if: >-
!cancelled() && !failure() &&
inputs.release_syft_enclave == true
uses: ./.github/workflows/cd-syft-enclave.yml
with:
bump_type: ${{ inputs.bump_type }}
secrets: inherit
release-syft-bg:
needs: [release-syft-enclave]
if: >-
!cancelled() && !failure() &&
inputs.release_syft_bg == true
uses: ./.github/workflows/cd-syft-bg.yml
with:
bump_type: ${{ inputs.bump_type }}
secrets: inherit
deploy-syft:
needs: [release-syft-job]
if: >-
!cancelled() && !failure()
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.publish.outputs.version }}
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install Just
uses: extractions/setup-just@v3
- name: Configure git user
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# The branch already holds the version to release. The bump happens after
# the publish, so the version on the branch names an unreleased version
- name: Read the version to release
run: |
# Only this branch and no tags: a bare `git pull` fetches every old
git pull --ff-only --no-tags origin "${{ github.ref_name }}"
VERSION=$(python3 syft/version.py)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Releasing syft $VERSION"
# No release artifacts before 1.0.0: protocol 0 stays open. See
# "Release artifacts" in docs/release.md.
- name: Build
run: just build
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASS_SYFT }}
run: uvx twine upload dist/*
- name: Record the released version
id: publish
run: echo "version=${{ env.VERSION }}" >> $GITHUB_OUTPUT
# The tag must name the published version, so it is created before the bump.
# Root tags continue the repo's historical vX.Y.Z lineage; sub-packages
# use <name>/vX.Y.Z. The tag is annotated and pushed explicitly:
# `--follow-tags` only pushes annotated tags, so a lightweight tag would
# never reach origin. The bump and the tag are pushed together (--atomic),
# so a re-run never finds one without the other.
- name: Tag the release, then bump for the next one
run: |
git tag -a "v${{ env.VERSION }}" -m "syft v${{ env.VERSION }}"
just bump ${{ inputs.bump_type }}
git push --atomic origin HEAD "refs/tags/v${{ env.VERSION }}"
# Waits for the last package so the smoke test installs what this run
# published, but runs whenever syft itself was published.
post-release-tests:
needs: [deploy-syft, release-syft-bg]
if: >-
!cancelled() &&
needs.deploy-syft.result == 'success'
uses: ./.github/workflows/post-release-tests.yml
with:
package_version: ${{ needs.deploy-syft.outputs.version }}