Run certain steps only once on deploy to prevent errors #618
This file contains 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: deploy | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
jobs: | |
test: | |
name: Test and build django-saml2-auth | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
versions: | |
- { "djangoVersion": "4.2.16", "pythonVersion": "3.10" } | |
- { "djangoVersion": "4.2.16", "pythonVersion": "3.11" } | |
- { "djangoVersion": "4.2.16", "pythonVersion": "3.12" } | |
- { "djangoVersion": "5.0.9", "pythonVersion": "3.10" } | |
- { "djangoVersion": "5.0.9", "pythonVersion": "3.11" } | |
- { "djangoVersion": "5.0.9", "pythonVersion": "3.12" } | |
poetry-version: ["1.8.3"] | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Set up Python 🐍 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.versions.pythonVersion }} | |
- name: Install Poetry | |
uses: abatilo/[email protected] | |
with: | |
poetry-version: ${{ matrix.poetry-version }} | |
- name: Install xmlsec1 📦 | |
run: sudo apt-get install xmlsec1 | |
- name: Install dependencies 📦 | |
run: | | |
python -m pip install poetry | |
poetry install --with dev | |
poetry self add "poetry-dynamic-versioning[plugin]" | |
- name: Install Django ${{ matrix.versions.djangoVersion }} 📦 | |
run: pip install Django==${{ matrix.versions.djangoVersion }} | |
- name: Check types, syntax and duckstrings 🦆 | |
run: | | |
poetry run mypy --explicit-package-bases . | |
poetry run ruff check . | |
poetry run interrogate --ignore-init-module --quiet --fail-under=95 . | |
- name: Test Django ${{ matrix.versions.djangoVersion }} with coverage 🧪 | |
run: poetry run coverage run --source=django_saml2_auth -m pytest . && poetry run coverage lcov -o coverage.lcov | |
- name: Submit coverage report to Coveralls 📈 | |
if: ${{ success() }} && ${{ matrix.versions.pythonVersion }} == '3.10' && ${{ matrix.versions.djangoVersion }} == '4.2.16' | |
uses: coverallsapp/github-action@v2 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: ./coverage.lcov | |
- name: Generate CycloneDX SBOM artifacts 📃 | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && ${{ matrix.versions.pythonVersion }} == '3.10' && ${{ matrix.versions.djangoVersion }} == '4.2.16' | |
run: | | |
poetry run cyclonedx-py poetry --all-extras --of JSON -o django-saml2-auth-${{ github.ref_name }}.cyclonedx.json | |
- name: Build and publish package to PyPI 🎉 | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && ${{ matrix.versions.pythonVersion }} == '3.10' && ${{ matrix.versions.djangoVersion }} == '4.2.16' | |
run: | | |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} | |
poetry publish --build --skip-existing | |
- name: Create release and add artifacts 🚀 | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && ${{ matrix.versions.pythonVersion }} == '3.10' && ${{ matrix.versions.djangoVersion }} == '4.2.16' | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
dist/*.tar.gz | |
dist/*.whl | |
django-saml2-auth-${{ github.ref_name }}.cyclonedx.json | |
draft: false | |
prerelease: false | |
tag_name: ${{ github.ref_name }} | |
name: ${{ github.ref_name }} | |
generate_release_notes: true |