|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ['v**'] |
| 6 | + |
| 7 | +concurrency: |
| 8 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + cancel-in-progress: false |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: Test / Python ${{ matrix.python-version }} |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v6 |
| 20 | + |
| 21 | + - uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: pip install -e .[test] |
| 27 | + |
| 28 | + - name: Run tests |
| 29 | + run: pytest -k "not example" |
| 30 | + env: |
| 31 | + API_KEY: ${{ secrets.API_KEY }} |
| 32 | + |
| 33 | + - name: Run example tests |
| 34 | + if: matrix.python-version == '3.13' |
| 35 | + run: pytest -k "example" |
| 36 | + env: |
| 37 | + API_KEY: ${{ secrets.API_KEY }} |
| 38 | + |
| 39 | + build: |
| 40 | + name: Build distribution |
| 41 | + needs: [test] |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v6 |
| 45 | + |
| 46 | + - uses: actions/setup-python@v5 |
| 47 | + with: |
| 48 | + python-version: "3.13" |
| 49 | + |
| 50 | + - name: Build sdist and wheel |
| 51 | + run: | |
| 52 | + pip install build |
| 53 | + python -m build |
| 54 | +
|
| 55 | + - uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: dist |
| 58 | + path: dist/ |
| 59 | + if-no-files-found: error |
| 60 | + |
| 61 | + publish: |
| 62 | + name: Publish release |
| 63 | + needs: [build] |
| 64 | + runs-on: ubuntu-latest |
| 65 | + permissions: |
| 66 | + contents: write |
| 67 | + packages: write |
| 68 | + steps: |
| 69 | + - uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + name: dist |
| 72 | + path: dist/ |
| 73 | + |
| 74 | + - name: Create GitHub Release |
| 75 | + env: |
| 76 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + GH_REPO: ${{ github.repository }} |
| 78 | + run: gh release create ${{ github.ref_name }} dist/* --generate-notes |
| 79 | + |
| 80 | + - name: Install twine |
| 81 | + run: pip install twine |
| 82 | + |
| 83 | + - name: Publish to PyPI |
| 84 | + env: |
| 85 | + TWINE_USERNAME: __token__ |
| 86 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 87 | + run: twine upload dist/* |
| 88 | + |
| 89 | + - name: Publish to GitHub Packages |
| 90 | + env: |
| 91 | + TWINE_USERNAME: ${{ github.repository_owner }} |
| 92 | + TWINE_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + run: twine upload --repository-url https://pypi.pkg.github.com/${{ github.repository_owner }} dist/* |
0 commit comments