main.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. name: build
  2. on: [push, pull_request]
  3. jobs:
  4. lint:
  5. name: Lint
  6. runs-on: ubuntu-latest
  7. steps:
  8. - uses: actions/checkout@v2
  9. - name: Set up Python
  10. uses: actions/setup-python@v2
  11. with:
  12. python-version: 3.7
  13. - name: Set Poetry cache
  14. uses: actions/cache@v2
  15. id: poetry-cache
  16. with:
  17. path: ~/.cache/pypoetry/virtualenvs
  18. key: poetry-${{ hashFiles('**/poetry.lock') }}
  19. - name: Upgrade Pip
  20. run: python -m pip install --upgrade pip
  21. - name: Install Poetry
  22. run: python -m pip install poetry
  23. - name: Install dependencies
  24. run: |
  25. poetry run pip install --upgrade pip
  26. poetry install
  27. - name: Run linters
  28. run: poetry run invoke lint
  29. deploy:
  30. name: Deploy
  31. environment: Deployment
  32. needs: [lint]
  33. runs-on: ubuntu-latest
  34. if: ${{ github.ref=='refs/heads/main' && github.event_name!='pull_request' }}
  35. steps:
  36. - uses: actions/checkout@v2
  37. - name: Setup Python
  38. uses: actions/setup-python@v2
  39. with:
  40. python-version: 3.7
  41. - name: Check release
  42. id: check_release
  43. run: |
  44. python -m pip install --upgrade pip
  45. python -m pip install poetry githubrelease httpx==0.16.1 autopub
  46. echo "##[set-output name=release;]$(autopub check)"
  47. - name: Publish
  48. if: ${{ steps.check_release.outputs.release=='' }}
  49. env:
  50. GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
  51. PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
  52. run: |
  53. git remote set-url origin https://$GITHUB_TOKEN@github.com/${{ github.repository }}
  54. autopub prepare
  55. poetry build
  56. autopub commit
  57. autopub githubrelease
  58. poetry publish -u __token__ -p $PYPI_PASSWORD