Update ci.yml #131
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| # 1️⃣ Test Job | |
| test: | |
| name: Tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.11", "3.12", "3.13"] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Poetry | |
| run: pip install poetry | |
| - name: Install dependencies | |
| run: poetry install | |
| - name: Run tests | |
| run: poetry run pytest | |
| # 2️⃣ Release Job (Uses Prebuilt Package) | |
| release: | |
| name: Release / Publish to PyPI | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Poetry | |
| run: pip install poetry | |
| - name: Install dependencies | |
| run: poetry install | |
| - name: Clean dist folder | |
| run: rm -rf dist/ | |
| - name: Configure Poetry and Set Version | |
| run: | | |
| git fetch --tags | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| VERSION=$(poetry version --short) | |
| echo "Stable version for release: $VERSION" | |
| elif [[ "${GITHUB_REF}" == refs/heads/main ]]; then | |
| SHORT_SHA=$(git rev-parse --short HEAD) | |
| VERSION="$(poetry version --short).dev$SHORT_SHA" | |
| echo "Development version (main): $VERSION" | |
| poetry version "$VERSION" | |
| else | |
| SHORT_SHA=$(git rev-parse --short HEAD) | |
| VERSION="$(poetry version --short).dev$SHORT_SHA" | |
| echo "Development version (branch): $VERSION" | |
| poetry version "$VERSION" | |
| fi | |
| - name: Build the package | |
| run: poetry build | |
| - name: Publish to PyPI | |
| run: | | |
| poetry config pypi-token.pypi "${{ secrets.PYPI_API_TOKEN }}" | |
| poetry publish |