|
| 1 | +name: Publish to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + - 'v*.*.*a*' |
| 8 | + - 'v*.*.*b*' |
| 9 | + - 'v*.*.*rc*' |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: Tests (Python ${{ matrix.python-version }}) |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + python-version: ["3.10", "3.11", "3.12"] |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - name: Set up Python ${{ matrix.python-version }} |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + cache: pip |
| 25 | + - name: Install dependencies |
| 26 | + run: pip install -e ".[dev]" |
| 27 | + - name: Run tests (no LLM) |
| 28 | + run: pytest -x -q |
| 29 | + env: |
| 30 | + BOARDSMITH_NO_LLM: "1" |
| 31 | + |
| 32 | + build: |
| 33 | + name: Build distribution |
| 34 | + needs: [test] |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - name: Set up Python 3.12 |
| 39 | + uses: actions/setup-python@v5 |
| 40 | + with: |
| 41 | + python-version: "3.12" |
| 42 | + cache: pip |
| 43 | + - name: Install build frontend |
| 44 | + run: pip install build |
| 45 | + - name: Build wheel and sdist |
| 46 | + run: python -m build |
| 47 | + - name: Upload dist artifacts |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + with: |
| 50 | + name: dist |
| 51 | + path: dist/ |
| 52 | + if-no-files-found: error |
| 53 | + |
| 54 | + publish: |
| 55 | + name: Publish to PyPI |
| 56 | + needs: [build] |
| 57 | + runs-on: ubuntu-latest |
| 58 | + environment: pypi |
| 59 | + permissions: |
| 60 | + id-token: write |
| 61 | + contents: read |
| 62 | + steps: |
| 63 | + - name: Download dist artifacts |
| 64 | + uses: actions/download-artifact@v4 |
| 65 | + with: |
| 66 | + name: dist |
| 67 | + path: dist/ |
| 68 | + - name: Publish to PyPI (OIDC) |
| 69 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 70 | + |
| 71 | + release: |
| 72 | + name: Create GitHub Release |
| 73 | + needs: [publish] |
| 74 | + runs-on: ubuntu-latest |
| 75 | + permissions: |
| 76 | + contents: write |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v4 |
| 79 | + - name: Download dist artifacts |
| 80 | + uses: actions/download-artifact@v4 |
| 81 | + with: |
| 82 | + name: dist |
| 83 | + path: dist/ |
| 84 | + - name: Create GitHub Release |
| 85 | + uses: softprops/action-gh-release@v2 |
| 86 | + with: |
| 87 | + prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }} |
| 88 | + generate_release_notes: true |
| 89 | + files: dist/* |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments