python-package.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
  2. # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
  3. name: Python package
  4. on:
  5. push:
  6. tags:
  7. - '*released'
  8. workflow_dispatch:
  9. jobs:
  10. update-version:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: Checkout repository
  14. uses: actions/checkout@v4
  15. with:
  16. ref: master
  17. fetch-depth: 0
  18. - name: Set up Python
  19. uses: actions/setup-python@v5
  20. with:
  21. python-version: "3.10"
  22. - name: Update version.py
  23. run: |
  24. python update_version.py
  25. - name: Verify version.py
  26. run: |
  27. ls -l mineru/version.py
  28. cat mineru/version.py
  29. - name: Commit changes
  30. run: |
  31. git config --local user.email "moe@myhloli.com"
  32. git config --local user.name "myhloli"
  33. git add mineru/version.py
  34. if git diff-index --quiet HEAD; then
  35. echo "No changes to commit"
  36. else
  37. git commit -m "Update version.py with new version"
  38. fi
  39. id: commit_changes
  40. - name: Push changes
  41. if: steps.commit_changes.outcome == 'success'
  42. env:
  43. GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
  44. run: |
  45. git push origin HEAD:master
  46. check-install:
  47. needs: [ update-version ]
  48. runs-on: ubuntu-latest
  49. strategy:
  50. fail-fast: false
  51. matrix:
  52. python-version: ["3.10", "3.11", "3.12", "3.13"]
  53. steps:
  54. - name: Checkout code
  55. uses: actions/checkout@v4
  56. with:
  57. ref: master
  58. fetch-depth: 0
  59. - name: Verify version.py
  60. run: |
  61. ls -l mineru/version.py
  62. cat mineru/version.py
  63. - name: Set up Python ${{ matrix.python-version }}
  64. uses: actions/setup-python@v5
  65. with:
  66. python-version: ${{ matrix.python-version }}
  67. - name: Install mineru
  68. run: |
  69. python -m pip install --upgrade pip
  70. pip install -e .[core]
  71. build:
  72. needs: [ check-install ]
  73. runs-on: ubuntu-latest
  74. strategy:
  75. fail-fast: false
  76. matrix:
  77. python-version: [ "3.10"]
  78. steps:
  79. - name: Checkout code
  80. uses: actions/checkout@v4
  81. with:
  82. ref: master
  83. fetch-depth: 0
  84. - name: Install wheel
  85. run: |
  86. python -m pip install wheel
  87. pip install build
  88. - name: Build wheel
  89. run: |
  90. python -m build --wheel
  91. - name: Upload artifact
  92. uses: actions/upload-artifact@v4
  93. with:
  94. name: wheel-file
  95. path: dist/*.whl
  96. retention-days: 30
  97. release:
  98. needs: [ build ]
  99. runs-on: ubuntu-latest
  100. steps:
  101. - name: Checkout code
  102. uses: actions/checkout@v4
  103. - name: Download artifact
  104. uses: actions/download-artifact@v4
  105. with:
  106. name: wheel-file
  107. path: dist
  108. - name: Create and Upload Release
  109. id: create_release
  110. uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
  111. with:
  112. files: './dist/*.whl'
  113. env:
  114. GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
  115. - name: Publish distribution to PyPI
  116. run: |
  117. pip install -U twine id keyring packaging readme-renderer requests requests-toolbelt rfc3986 rich urllib3
  118. twine check dist/*
  119. twine upload dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN }}