| 1 |
name: Build |
| 2 |
|
| 3 |
on: |
| 4 |
- push |
| 5 |
- pull_request |
| 6 |
|
| 7 |
concurrency: |
| 8 |
group: ${{ github.workflow }}-${{ github.ref }} |
| 9 |
cancel-in-progress: true |
| 10 |
|
| 11 |
env: |
| 12 |
publish-python-version: 3.12 |
| 13 |
|
| 14 |
jobs: |
| 15 |
lint_test_build: |
| 16 |
runs-on: ubuntu-latest |
| 17 |
strategy: |
| 18 |
matrix: |
| 19 |
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
| 20 |
steps: |
| 21 |
- uses: actions/checkout@v7 |
| 22 |
- name: Set up Python ${{ matrix.python-version }} |
| 23 |
uses: actions/setup-python@v7 |
| 24 |
with: |
| 25 |
python-version: ${{ matrix.python-version }} |
| 26 |
allow-prereleases: true |
| 27 |
cache: 'pip' |
| 28 |
- name: Install dependencies |
| 29 |
run: | |
| 30 |
python -m pip install --upgrade pip |
| 31 |
python -m pip install --upgrade build |
| 32 |
python -m pip install --upgrade tox tox-gh-actions |
| 33 |
- name: Test with tox |
| 34 |
run: tox |
| 35 |
- name: Build package |
| 36 |
run: python -m build |
| 37 |
- name: Upload build artifacts |
| 38 |
uses: actions/upload-artifact@v7 |
| 39 |
with: |
| 40 |
name: python-package-distributions-${{ matrix.python-version }} |
| 41 |
path: dist/ |
| 42 |
- name: Upload coverage reports to Codecov |
| 43 |
uses: codecov/codecov-action@v7 |
| 44 |
if: ${{ hashFiles('coverage-py312.xml') != '' }} |
| 45 |
with: |
| 46 |
files: coverage-py312.xml |
| 47 |
env: |
| 48 |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 49 |
|
| 50 |
publish-to-pypi: |
| 51 |
name: Publish to PyPI |
| 52 |
runs-on: ubuntu-latest |
| 53 |
if: startsWith(github.ref, 'refs/tags/') |
| 54 |
needs: |
| 55 |
- lint_test_build |
| 56 |
environment: |
| 57 |
name: pypi |
| 58 |
url: https://pypi.org/p/async-upnp-client |
| 59 |
permissions: |
| 60 |
id-token: write |
| 61 |
steps: |
| 62 |
- name: Download all the dists |
| 63 |
uses: actions/download-artifact@v8 |
| 64 |
with: |
| 65 |
name: python-package-distributions-${{ env.publish-python-version }} |
| 66 |
path: dist/ |
| 67 |
- name: Publish to PyPI |
| 68 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 69 |
|
| 70 |
github-release: |
| 71 |
needs: |
| 72 |
- publish-to-pypi |
| 73 |
runs-on: ubuntu-latest |
| 74 |
permissions: |
| 75 |
contents: write |
| 76 |
id-token: write |
| 77 |
steps: |
| 78 |
- name: Download all the dists |
| 79 |
uses: actions/download-artifact@v8 |
| 80 |
with: |
| 81 |
name: python-package-distributions-${{ env.publish-python-version }} |
| 82 |
path: dist/ |
| 83 |
- name: Sign the dists with Sigstore |
| 84 |
uses: sigstore/[email protected] |
| 85 |
with: |
| 86 |
inputs: >- |
| 87 |
./dist/*.tar.gz |
| 88 |
./dist/*.whl |
| 89 |
- name: Create GitHub Release |
| 90 |
env: |
| 91 |
GITHUB_TOKEN: ${{ github.token }} |
| 92 |
run: >- |
| 93 |
gh release create |
| 94 |
'${{ github.ref_name }}' |
| 95 |
--repo '${{ github.repository }}' |
| 96 |
--notes "" |
| 97 |
- name: Upload artifact signatures to GitHub Release |
| 98 |
env: |
| 99 |
GITHUB_TOKEN: ${{ github.token }} |
| 100 |
run: >- |
| 101 |
gh release upload |
| 102 |
'${{ github.ref_name }}' dist/** |
| 103 |
--repo '${{ github.repository }}' |
| 104 |
|
| 105 |
publish-to-testpypi: |
| 106 |
name: Publish to TestPyPI |
| 107 |
runs-on: ubuntu-latest |
| 108 |
if: github.repository == 'StevenLooman/async_upnp_client' |
| 109 |
needs: |
| 110 |
- lint_test_build |
| 111 |
environment: |
| 112 |
name: testpypi |
| 113 |
url: https://test.pypi.org/p/async-upnp-client |
| 114 |
permissions: |
| 115 |
id-token: write |
| 116 |
steps: |
| 117 |
- name: Download all the dists |
| 118 |
uses: actions/download-artifact@v8 |
| 119 |
with: |
| 120 |
name: python-package-distributions-${{ env.publish-python-version }} |
| 121 |
path: dist/ |
| 122 |
- name: Publish to TestPyPI |
| 123 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 124 |
with: |
| 125 |
repository-url: https://test.pypi.org/legacy/ |
| 126 |
continue-on-error: true |