Workflow file for this run
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: Lighter - CI & Auto Publish | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install uv | |
run: make setup | |
- name: Set up cache | |
uses: actions/cache@v2 | |
with: | |
path: .venv | |
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }} | |
restore-keys: | | |
venv-${{ matrix.python-version }}- | |
- name: Check security | |
run: make check-safety | |
- name: Check codestyle | |
run: make check-codestyle | |
# Run tests and generate coverage report | |
- name: Run tests | |
run: make test | |
# Publish the pre-release package only when on the main branch and the Python 3.11 run. | |
# Integrating auto-publish in this workflow enables direct use of the coverage badge artifact. | |
- name: Bump version & commit badge | |
if: github.ref == 'refs/heads/main' && matrix.python-version == '3.11' | |
run: | | |
# Bump version | |
make bump-prerelease | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
# Stage the version bump & the coverage badge | |
git add pyproject.toml lighter/__init__.py assets/images/coverage.svg | |
git commit -m "Bump version" || echo "No version bump or coverage changes to commit" | |
git push | |
- name: Build distribution | |
if: github.ref == 'refs/heads/main' && matrix.python-version == '3.11' | |
run: uv build | |
- name: Publish pre-release distribution 📦 to PyPI | |
if: github.ref == 'refs/heads/main' && matrix.python-version == '3.11' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} |