chore: bump to 1.0.3 #16
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: Build | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
release: | |
types: [ "published" ] | |
permissions: | |
contents: read | |
concurrency: | |
group: main-${{ github.head_ref || github.ref }} | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
jobs: | |
format-checks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install Project | |
run: python -m pip install -e . | |
- name: Install ruff | |
run: | | |
python -m pip install ruff==0.6.1 | |
- name: Formatting Checks | |
run: ruff format --check src tests | |
type-checks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install Project | |
run: python -m pip install -e . | |
- name: Install mypy | |
run: python -m pip install mypy==1.11.1 | |
- name: Type Checks | |
run: mypy src | |
tests: | |
name: Tests / ${{ matrix.python-version }} | |
runs-on: ubuntu-latest | |
needs: | |
- format-checks | |
- type-checks | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ "3.8", "3.9", "3.10" ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Project | |
run: python -m pip install -e . | |
- name: Install Coverage | |
run: python -m pip install "coverage[toml]==7.6.1" | |
- name: Run Tests ${{ matrix.python-version }} | |
run: python -m coverage run -m unittest discover -s tests | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: cov-${{ matrix.python-version }} | |
path: .coverage.* | |
retention-days: 5 | |
coverage: | |
runs-on: ubuntu-latest | |
needs: | |
- tests | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install Coverage | |
run: python -m pip install "coverage[toml]==7.6.1" | |
- name: Download Coverage Data | |
uses: actions/download-artifact@v3 | |
- name: Prepare Coverage Report | |
run: | | |
python -m coverage combine **/.coverage.* | |
python -m coverage report -m --skip-covered | |
python -m coverage json | |
- name: Output Coverage | |
run: echo "COVERAGE_JSON=$(jq -c . < coverage.json)" >> $GITHUB_ENV | |
- name: Get Coverage Totals | |
id: coverage-total | |
run: echo "coverage_total=${{ fromJson(env.COVERAGE_JSON).totals.percent_covered_display }}" >> $GITHUB_OUTPUT | |
outputs: | |
coverage_total: ${{ steps.coverage-total.outputs.coverage_total }} | |
coverage-badge: | |
runs-on: ubuntu-latest | |
needs: | |
- coverage | |
if: github.ref == 'refs/heads/main' | |
environment: release | |
env: | |
COVERAGE_TOTAL: ${{ needs.coverage.outputs.coverage_total }} | |
steps: | |
- name: Create Coverage Badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_TOKEN }} | |
gistID: ${{ vars.GIST_COVERAGE_ID }} | |
filename: ${{ vars.GIST_COVERAGE_NAME }} | |
label: Coverage | |
message: ${{ env.COVERAGE_TOTAL }}% | |
valColorRange: ${{ env.COVERAGE_TOTAL }} | |
maxColorRange: 90 | |
minColorRange: 50 | |
build: | |
runs-on: ubuntu-latest | |
needs: | |
- coverage | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install PyPa's build package | |
run: python -m pip install build | |
- name: Build | |
run: python -m build | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: build-${{ github.sha }} | |
path: dist | |
retention-days: 5 | |
deploy: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
if: github.event_name == 'release' | |
environment: release | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: build-${{ github.sha }} | |
path: dist | |
- name: Upload to GH Release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
GH_REPO: ${{ github.repository }} | |
run: | | |
gh release upload "${{ github.ref_name }}" dist/*.tar.gz | |
gh release upload "${{ github.ref_name }}" dist/*.whl | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |