diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..cd8ae25 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,32 @@ +name: Build distribution + +on: + release: + types: [created] + +jobs: + test: + uses: ./.github/workflows/test.yml + deploy: + needs: test + name: Deploy to PyPI + permissions: + id-token: write + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + cache: "pip" # caching pip dependencies + - name: Install build dependencies + run: python -m pip install build twine + + - name: Build distributions + run: python -m build + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..96a5dc0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,63 @@ +name: PyTest +on: + workflow_call: + workflow_dispatch: + push: + branches: + - main + pull_request: + paths: + - ".github/workflows/test.yml" + - "src/**" + - "tests/**" + - "pyproject.toml" + - "requirements.txt" + +jobs: + test-against-python-matrix: + # Only test all the supported versions when a pull request is made or the workflow is called + if: ${{github.event_name == 'workflow_call'}} || ${{github.event_name == 'pull_request'}} + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13"] + fail-fast: true + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" # caching pip dependencies + - name: Install requirements + run: | + python -m pip install -e .[dev] + - name: Run tests + run: | + python -m pytest + + test-against-latest-os: + # Always run against the latest version on both Windows, Linux, MacOS + if: github.event.pull_request.user.login != 'dependabot[bot]' + strategy: + matrix: + os: [windows-latest, macos-latest] + fail-fast: true + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "pip" # caching pip dependencies + - name: Install requirements + run: | + python -m pip install -e .[dev] + - name: Run tests + run: | + python -m pytest + - name: coverage + uses: actions/upload-artifact@v4 + with: + name: code-coverage-report-${{ matrix.os }} + path: .coverage + overwrite: true