Repository navigation
328 lines (315 loc) · 12.7 KB
/
Copy pathrelease.yml
File metadata and controls
328 lines (315 loc) · 12.7 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
316
317
318
319
320
321
322
323
324
325
326
327
328
name: Release
on:
workflow_dispatch:
inputs:
version:
description: Release version without the v prefix
required: true
type: string
candidate-sha:
description: Full commit SHA currently at the tip of main
required: true
type: string
permissions:
contents: read
concurrency:
group: release-${{ inputs.version }}
cancel-in-progress: false
env:
PYTHON_VERSION: "3.12"
UV_VERSION: "0.10.9"
UV_NO_MANAGED_PYTHON: "1"
NO_MKDOCS_2_WARNING: "1"
jobs:
preflight:
name: Validate Unpublished Main Candidate
runs-on: ubuntu-latest
outputs:
commit: ${{ steps.identity.outputs.commit }}
tree: ${{ steps.identity.outputs.tree }}
version: ${{ steps.identity.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.candidate-sha }}
fetch-depth: 0
persist-credentials: false
- name: Fetch current main without tags
run: git fetch origin main --no-tags
- name: Check candidate identity and public version absence
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
python scripts/check_release_preflight.py
--version "${{ inputs.version }}"
--candidate-sha "${{ inputs.candidate-sha }}"
--repository "${{ github.repository }}"
--workflow-sha "${{ github.sha }}"
- name: Record accepted candidate
id: identity
run: |
{
echo "commit=${{ inputs.candidate-sha }}"
echo "tree=$(git rev-parse 'HEAD^{tree}')"
echo "version=${{ inputs.version }}"
} >> "$GITHUB_OUTPUT"
ecosystem-qualification:
name: Ecosystem Qualification
needs: preflight
permissions:
contents: read
uses: ml4t/ecosystem/.github/workflows/qualify-library.yml@066dc737a879faea51a5b8a900315441712ea89a # 2026-09-25 policy snapshot
with:
import-package: ml4t.data
prerelease-exception: python-315-polars
compatibility:
name: Release Compatibility
needs: preflight
permissions:
contents: read
uses: ./.github/workflows/compatibility.yml
quality:
name: Source Quality and Security
needs: preflight
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.preflight.outputs.commit }}
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install the complete locked environment
run: uv sync --locked --all-extras --all-groups
- name: Run source quality gates
run: |
uv run ruff check src/ tests/ scripts/
uv run ruff format --check src/ tests/ scripts/
uv run ty check
uv run pytest tests/ -q -ra --cov=ml4t.data --cov-report=term-missing
uv run pytest tests/ -q -ra -W error::ResourceWarning
- name: Audit locked dependencies
run: |
uv export --locked --all-extras --all-groups --no-emit-project --no-hashes --output-file requirements-audit.txt
uv run pip-audit --requirement requirements-audit.txt
- name: Build and verify documentation
env:
ML4T_DOCS_COMMIT: ${{ needs.preflight.outputs.commit }}
ML4T_DOCS_VERSION: ${{ needs.preflight.outputs.version }}
run: |
uv run python scripts/verify_readme_links.py
uv run mkdocs build --strict
uv run python scripts/verify_documentation_identity.py \
--site site \
--expected-library data \
--expected-version "$ML4T_DOCS_VERSION" \
--expected-commit "$ML4T_DOCS_COMMIT"
build:
name: Build Candidate Once
needs: [preflight, ecosystem-qualification, compatibility, quality]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.preflight.outputs.commit }}
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: false
- name: Install build and documentation tooling
run: uv sync --locked --dev --extra docs
- name: Build distributions once
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.preflight.outputs.version }}
run: uv build --out-dir candidate/dist
- name: Validate metadata and clean installations
run: |
uv run twine check candidate/dist/*
uv run python scripts/verify_distribution.py \
--dist-dir candidate/dist \
--expected-tag "v${{ needs.preflight.outputs.version }}"
- name: Write and verify the commit-bound candidate manifest
run: |
uv run python scripts/release_candidate.py create candidate \
--commit-sha "${{ needs.preflight.outputs.commit }}" \
--git-tree "${{ needs.preflight.outputs.tree }}"
uv run python scripts/release_candidate.py verify candidate \
--expected-commit "${{ needs.preflight.outputs.commit }}" \
--expected-tree "${{ needs.preflight.outputs.tree }}" \
--expected-tag "v${{ needs.preflight.outputs.version }}"
- name: Build and verify revision-identified documentation
env:
ML4T_DOCS_COMMIT: ${{ needs.preflight.outputs.commit }}
ML4T_DOCS_VERSION: ${{ needs.preflight.outputs.version }}
run: |
uv run mkdocs build --strict --site-dir candidate/site
uv run python scripts/verify_documentation_identity.py \
--site candidate/site \
--expected-library data \
--expected-version "$ML4T_DOCS_VERSION" \
--expected-commit "$ML4T_DOCS_COMMIT"
- name: Upload immutable candidate
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-candidate-${{ needs.preflight.outputs.commit }}
path: |
candidate/dist/
candidate/candidate.json
if-no-files-found: error
retention-days: 14
- name: Upload immutable documentation
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: docs-${{ needs.preflight.outputs.commit }}
path: candidate/site/
if-no-files-found: error
retention-days: 14
documentation:
name: Deploy and Verify Qualified Documentation
needs: [preflight, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.preflight.outputs.commit }}
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: docs-${{ needs.preflight.outputs.commit }}
path: candidate-site/
- name: Verify documentation before deployment
run: >-
python scripts/verify_documentation_identity.py
--site candidate-site
--expected-library data
--expected-version "${{ needs.preflight.outputs.version }}"
--expected-commit "${{ needs.preflight.outputs.commit }}"
- name: Require documentation deploy credentials
env:
DOCS_DEPLOY_KEY: ${{ secrets.DOCS_DEPLOY_KEY }}
run: test -n "$DOCS_DEPLOY_KEY"
- name: Deploy the qualified documentation artifact
uses: cpina/github-action-push-to-another-repository@55306faa4ed53b815ae49e564af8cfb359d32ae2 # v1.7.3
env:
SSH_DEPLOY_KEY: ${{ secrets.DOCS_DEPLOY_KEY }}
with:
source-directory: candidate-site/
destination-github-username: ml4t
destination-repository-name: website
target-directory: static/docs/data/
target-branch: main
commit-message: "docs(data): release ${{ needs.preflight.outputs.version }} from ${{ needs.preflight.outputs.commit }}"
user-name: ml4t-bot
user-email: bot@ml4trading.io
- name: Verify deployed documentation identity
run: >-
python scripts/verify_documentation_identity.py
--url https://www.ml4trading.io/docs/data/
--url https://www.ml4trading.io/docs/data/api/
--url https://www.ml4trading.io/docs/data/providers/
--expected-library data
--expected-version "${{ needs.preflight.outputs.version }}"
--expected-commit "${{ needs.preflight.outputs.commit }}"
--attempts 24
--delay 10
publish:
name: Publish Exact Candidate to PyPI
needs: [preflight, documentation]
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.preflight.outputs.commit }}
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-candidate-${{ needs.preflight.outputs.commit }}
path: candidate/
- name: Verify retained candidate
run: >-
python scripts/release_candidate.py verify candidate
--expected-commit "${{ needs.preflight.outputs.commit }}"
--expected-tree "${{ needs.preflight.outputs.tree }}"
--expected-tag "v${{ needs.preflight.outputs.version }}"
- name: Publish through trusted publishing
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
packages-dir: candidate/dist/
verify-metadata: true
github-release:
name: Create Tag and GitHub Release
needs: [preflight, publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-candidate-${{ needs.preflight.outputs.commit }}
path: candidate/
- name: Create release from the published candidate
env:
GH_TOKEN: ${{ github.token }}
run: >-
gh release create "v${{ needs.preflight.outputs.version }}"
candidate/dist/* candidate/candidate.json
--repo "${{ github.repository }}"
--target "${{ needs.preflight.outputs.commit }}"
--generate-notes
post-publication:
name: Verify Package, Release, and Documentation
needs: [preflight, github-release]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.preflight.outputs.commit }}
persist-credentials: false
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: ${{ env.UV_VERSION }}
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-candidate-${{ needs.preflight.outputs.commit }}
path: candidate/
- name: Verify PyPI metadata and GitHub release digests
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
python scripts/verify_published_release.py
--manifest candidate/candidate.json
--repository "${{ github.repository }}"
- name: Install the published wheel and execute the README quick start
run: |
uv venv --python 3.12 .release-venv
uv pip install --python .release-venv/bin/python "ml4t-data==${{ needs.preflight.outputs.version }}"
.release-venv/bin/python scripts/run_readme_quickstart.py
- name: Recheck deployed documentation identity
run: >-
python scripts/verify_documentation_identity.py
--url https://www.ml4trading.io/docs/data/
--url https://www.ml4trading.io/docs/data/api/
--expected-library data
--expected-version "${{ needs.preflight.outputs.version }}"
--expected-commit "${{ needs.preflight.outputs.commit }}"
--attempts 6
--delay 10