Skip to content

Merge pull request #27 from HexDecimal/pre-commit-ci-update-config #270

Merge pull request #27 from HexDecimal/pre-commit-ci-update-config

Merge pull request #27 from HexDecimal/pre-commit-ci-update-config #270

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Package
on:
push:
pull_request:
types: [opened, reopened]
defaults:
run:
shell: bash
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Ruff
run: pip install ruff
- name: Ruff Check
run: ruff check . --output-format=github
- name: Ruff Format
run: ruff format . --check
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Setup Python ${{ matrix.python-version }}
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: pip install -e ".[test]"
- name: Mypy
uses: liskin/gh-problem-matcher-wrap@v2
with:
linters: mypy
run: mypy --show-column-numbers --python-version ${{ matrix.python-version }}
- name: Run tests
run: pytest --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v3
build-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install build
run: pip install build
- name: Build package
run: python -m build
- uses: actions/upload-artifact@v3
with:
name: python-dist
path: dist/*
if-no-files-found: error
retention-days: 1
deploy:
needs: [build-dist]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/tcod-ecs
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: python-dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
release:
if: startsWith(github.ref, 'refs/tags/')
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Generate body
run: scripts/get_release_description.py | tee release_body.md
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
bodyFile: release_body.md