python-publish.yml 993 B

12345678910111213141516171819202122232425262728293031323334353637
  1. name: Release
  2. on:
  3. push:
  4. branches:
  5. - main
  6. jobs:
  7. deploy:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - uses: actions/checkout@v2
  11. - uses: actions-ecosystem/action-regex-match@v2
  12. id: regex-match
  13. with:
  14. text: ${{ github.event.head_commit.message }}
  15. regex: '^Release ([^ ]+)'
  16. - name: Set up Python
  17. uses: actions/setup-python@v2
  18. with:
  19. python-version: '3.8'
  20. - name: Install dependencies
  21. run: |
  22. python -m pip install --upgrade pip
  23. pip install setuptools wheel twine
  24. - name: Release
  25. if: ${{ steps.regex-match.outputs.match != '' }}
  26. uses: softprops/action-gh-release@v1
  27. with:
  28. tag_name: v${{ steps.regex-match.outputs.group1 }}
  29. - name: Build and publish
  30. if: ${{ steps.regex-match.outputs.match != '' }}
  31. env:
  32. TWINE_USERNAME: __token__
  33. TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
  34. run: |
  35. python setup.py sdist
  36. twine upload dist/*