Update GitHub workflow #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ci | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "*" | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| pytest: | |
| name: Run pytest π§ͺ | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.14'] | |
| services: | |
| postgres: | |
| image: postgres:latest | |
| env: | |
| POSTGRES_PASSWORD: postgres_password | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout repo ποΈ | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python ${{ matrix.python-version }} π | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install package π¦ | |
| run: | | |
| python -m pip install --upgrade pip setuptools | |
| python -m pip install psycopg2-binary | |
| python -m pip install -e .[pytest] | |
| - name: Setup environment file π | |
| run: | | |
| echo "SECRET_KEY=thisisnotaverysecretkey" >> $GITHUB_ENV | |
| echo "DATABASE=postgresql://postgres:postgres_password@localhost/django_datacite" >> $GITHUB_ENV | |
| - name: Run pytest π§ͺ | |
| run: | | |
| pytest --cov | |
| - name: Run coveralls π | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| flag-name: ${{ matrix.python-version }} | |
| parallel: true | |
| coveralls: | |
| name: Upload to coveralls π | |
| needs: pytest | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Upload to coveralls π | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| parallel-finished: true | |
| carryforward: "3.7,3.14" | |
| build: | |
| name: Build distribution π· | |
| needs: pytest | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo ποΈ | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python π | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.x" | |
| - name: Install build π§± | |
| run: python -m pip install build --user | |
| - name: Build a binary wheel and a source tarball π οΈ | |
| run: python -m build | |
| - name: Store the distribution packages π€ | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| pypi: | |
| name: Publish distribution to PyPI π¦ | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/django-datacite | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download the distribution packages π₯ | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish to PyPI π | |
| uses: pypa/gh-action-pypi-publish@release/v1 |