| # SPDX-FileCopyrightText: © 2022 Matt Williams <matt@milliams.com> |
| # SPDX-License-Identifier: BSD |
| |
| --- |
| |
| name: Python package |
| |
| on: |
| push: |
| branches: |
| - master |
| tags: |
| - "*" |
| |
| pull_request: |
| branches: |
| - master |
| |
| jobs: |
| unit-tests: |
| runs-on: ubuntu-latest |
| strategy: |
| fail-fast: false |
| matrix: |
| python-version: ["3.7", "3.8", "3.9", "3.10"] |
| steps: |
| - uses: actions/checkout@v3 |
| - name: Install doxygen |
| run: | |
| sudo apt install -y doxygen |
| - name: Set up Python ${{ matrix.python-version }} |
| uses: actions/setup-python@v3 |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Install Poetry |
| run: pip install poetry |
| - name: Setup package |
| run: poetry install |
| - name: Run mypy |
| run: poetry run mypy --install-types --non-interactive sphinxcontrib/doxylink |
| - name: Run pytest |
| run: poetry run pytest |
| - name: Test that package builds |
| run: poetry build |
| release: |
| runs-on: ubuntu-latest |
| needs: [unit-tests] |
| if: startsWith(github.ref, 'refs/tags/') |
| steps: |
| - uses: actions/checkout@v2 |
| - name: Set up Python |
| uses: actions/setup-python@v2 |
| with: |
| python-version: "3.x" |
| - name: Install Poetry |
| run: pip install poetry |
| - name: Build package |
| run: poetry build |
| - name: Get the version |
| id: get_version |
| run: echo ::set-output name=version::${GITHUB_REF#refs/tags/} |
| - name: Create Release ${{ github.ref }} |
| id: create_release |
| uses: actions/create-release@v1 |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| with: |
| tag_name: ${{ steps.get_version.outputs.version }} |
| release_name: ${{ steps.get_version.outputs.version }} |
| # body: # TODO Read this from the CHANGELOG |
| draft: false |
| prerelease: false |
| - name: Set PyPI credentials |
| run: poetry config pypi-token.pypi ${PYPI_TOKEN} |
| env: |
| PYPI_TOKEN: ${{ secrets.pypi_token }} |
| - name: Publish |
| run: poetry publish |