Repository navigation
222 lines (192 loc) · 6.75 KB
/
Copy pathpython-package.yml
File metadata and controls
222 lines (192 loc) · 6.75 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
name: Python package
on:
push:
tags:
- '*released'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
validate-source:
if: github.repository == 'opendatalab/MinerU'
runs-on: ubuntu-latest
timeout-minutes: 5
env:
RELEASE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@v7
- name: Verify release source before running the matrix
run: uv run --no-project --with packaging python scripts/ci/check_release.py --tag "$RELEASE_TAG" --commit "$GITHUB_SHA"
tests:
needs: validate-source
uses: ./.github/workflows/cli.yml
check-install:
needs: [ build ]
runs-on: ${{ matrix.os }}
env:
PYTHONUTF8: '1'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.11", "3.12", "3.13", "3.14"]
timeout-minutes: 15
defaults:
run:
shell: bash
steps:
- name: Download release wheel
uses: actions/download-artifact@v7
with:
name: wheel-file
path: dist
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install and verify release wheel
run: |
python -m pip install --upgrade pip
python -m pip install --only-binary=docvortex dist/*.whl
python -m pip check
python -I -c "from mineru.parser import MinerUParser, MinerUApiParser, parse, parse_async; from mineru.render import render; from mineru.types import MiddleJson"
mineru version --json
mineru-kit --version
build:
needs: [ tests ]
runs-on: ubuntu-latest
timeout-minutes: 10
env:
RELEASE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install build tools
run: |
python -m pip install wheel
pip install build twine
- name: Verify tagged source
run: python scripts/ci/check_release.py --tag "$RELEASE_TAG" --commit "$GITHUB_SHA"
- name: Build wheel
run: |
python -m build --wheel
- name: Check wheel metadata
run: |
python -m twine check --strict dist/*.whl
python scripts/ci/check_release.py --tag "$RELEASE_TAG" --commit "$GITHUB_SHA" \
--wheel-dir dist --output build/release.json
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: wheel-file
path: dist/*.whl
retention-days: 30
- name: Upload release provenance
uses: actions/upload-artifact@v6
with:
name: release-provenance
path: build/release.json
if-no-files-found: error
retention-days: 30
publish:
needs: [ tests, build, check-install ]
if: github.repository == 'opendatalab/MinerU' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/mineru/
permissions:
id-token: write
steps:
- name: Download artifact
uses: actions/download-artifact@v7
with:
name: wheel-file
path: dist
- name: Download release provenance
uses: actions/download-artifact@v7
with:
name: release-provenance
path: provenance
- name: Create and Upload Release
id: create_release
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
with:
files: |
dist/*.whl
provenance/release.json
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
sync-issue-template:
needs: [ publish ]
if: startsWith(github.ref, 'refs/tags/') && needs.publish.result == 'success'
runs-on: ubuntu-latest
env:
RELEASE_BRANCH: ${{ github.event.repository.default_branch }}
RELEASE_TAG: ${{ github.ref_name }}
steps:
- name: Checkout default branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Download published wheel
uses: actions/download-artifact@v7
with:
name: wheel-file
path: ${{ runner.temp }}/mineru-issue-template-dist
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Sync and commit latest stable version hint
shell: bash
env:
RELEASE_WHEEL_DIR: ${{ runner.temp }}/mineru-issue-template-dist
RELEASE_HISTORY: ${{ runner.temp }}/mineru-release-history.json
GH_TOKEN: ${{ github.token }}
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
for attempt in 1 2 3; do
# 此 job 的独立 checkout 每次基于最新分支重新生成,避免覆盖并发提交。
git fetch origin "$RELEASE_BRANCH"
git reset --hard FETCH_HEAD
gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/releases?per_page=100" > "$RELEASE_HISTORY"
uv run --no-project --python 3.12 scripts/sync_issue_template_version.py \
--wheel "$RELEASE_WHEEL_DIR" --tag "$RELEASE_TAG" --releases-json "$RELEASE_HISTORY"
git add -- .github/ISSUE_TEMPLATE/bug_report.yml .github/ISSUE_TEMPLATE/bug_report_zh.yml
if git diff --cached --quiet -- .github/ISSUE_TEMPLATE/bug_report.yml .github/ISSUE_TEMPLATE/bug_report_zh.yml; then
echo "Issue templates already reflect the recent stable releases."
exit 0
fi
git commit -m "chore: sync recent releases in issue templates"
if git push origin "HEAD:$RELEASE_BRANCH"; then
exit 0
fi
echo "Push attempt $attempt failed; regenerating from the latest default branch."
done
echo "::error::Could not synchronize the issue template after three push attempts."
exit 1