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