Files
tzst/.github/workflows/ci.yml
T
xixu-me 6b57409712 Update Python version support to 3.12+
This commit updates the CI configuration, pyproject.toml, and codebase to drop support for Python versions below 3.12 and add support for Python 3.13. Type hints are updated to use modern syntax, and redundant checks for extraction filter support are removed as Python 3.12+ always supports filters.
2025-05-31 15:48:13 +08:00

149 lines
3.8 KiB
YAML

name: CI/CD
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
release:
types: [published]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Lint with ruff
run: |
ruff check src tests
- name: Format check with black
run: |
black --check src tests
- name: Run tests
run: |
pytest -v --cov=tzst --cov-report=xml
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Check package
run: twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
environment:
name: pypi
url: https://pypi.org/p/tzst
permissions:
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
update_badges:
needs: [build, publish]
if: always() && needs.build.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
- name: Wait if this is after a publish
if: github.event_name == 'release' && github.event.action == 'published'
run: sleep 30
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Fetch PyPI version
id: pypi_version
run: |
pip install requests
python -c "
import requests, json
try:
data = requests.get('https://pypi.org/pypi/tzst/json').json()
version = data['info']['version']
print(f'PyPI version: {version}')
except Exception as e:
print(f'Error fetching version: {e}')
version = 'unknown'
print(f'::set-output name=version::{version}')
"
- name: Update README badge
run: |
echo "Updating PyPI badge with version: ${{ steps.pypi_version.outputs.version }}"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update badges [skip ci]"
file_pattern: README.md
branch: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}