|
| 1 | +name: Test and Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + workflow_dispatch: |
| 6 | + schedule: # Run once a week to detect any regressions |
| 7 | + - cron: '0 0 * * 1' |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up Python ${{ matrix.python-version }} |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + cache: "pip" |
| 25 | + allow-prereleases: true |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: | |
| 29 | + pip install .[test] |
| 30 | +
|
| 31 | + - name: Run tests |
| 32 | + run: | |
| 33 | + python -m pytest |
| 34 | +
|
| 35 | + # ------------------------------------------------------------ |
| 36 | + # Build the distribution and publish (on release tag). |
| 37 | + # ------------------------------------------------------------ |
| 38 | + publish: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + needs: [test] |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout source |
| 44 | + uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Get minimum Python version |
| 47 | + run: | |
| 48 | + PYTHON_VERSION=$(cat pyproject.toml | grep "requires-python" | grep -Eo "[0-9]+\.[0-9]+") |
| 49 | + echo "PYTHON_VERSION=${PYTHON_VERSION}" >> $GITHUB_ENV |
| 50 | +
|
| 51 | + - name: Set up Python ${{ env.PYTHON_VERSION }} |
| 52 | + uses: actions/setup-python@v5 |
| 53 | + with: |
| 54 | + python-version: ${{ env.PYTHON_VERSION }} |
| 55 | + cache: "pip" |
| 56 | + |
| 57 | + - name: Install build dependencies |
| 58 | + run: | |
| 59 | + pip install --upgrade pip |
| 60 | + pip install --upgrade build wheel setuptools |
| 61 | +
|
| 62 | + - name: Validate links |
| 63 | + uses: gaurav-nelson/github-action-markdown-link-check@v1 |
| 64 | + with: |
| 65 | + file-path: README.md |
| 66 | + folder-path: examples/ |
| 67 | + |
| 68 | + - name: Build distributions |
| 69 | + run: python -m build |
| 70 | + |
| 71 | + - name: Publish package |
| 72 | + if: github.repository == 'Project-Platypus/Rhodium' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 73 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 74 | + with: |
| 75 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments