|
6 | 6 | - 'v*' # Runs only on version tags like v1.2.3 |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - build-and-publish: |
| 9 | + publish: |
10 | 10 | runs-on: ubuntu-latest |
11 | 11 |
|
12 | 12 | steps: |
13 | | - - name: Checkout code |
14 | | - uses: actions/checkout@v4 |
| 13 | + - uses: actions/checkout@v4 |
15 | 14 |
|
16 | | - - name: Set up Python |
17 | | - uses: actions/setup-python@v5 |
18 | | - with: |
19 | | - python-version: '3.11' |
20 | | - |
21 | | - - name: Install Poetry |
22 | | - run: curl -sSL https://install.python-poetry.org | python3 - |
23 | | - |
24 | | - - name: Extract tag version |
25 | | - id: get_tag |
26 | | - run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV |
| 15 | + - name: Set up Python & Poetry |
| 16 | + run: | |
| 17 | + curl -sSL https://install.python-poetry.org | python3 - --version 2.1.3 |
| 18 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
27 | 19 |
|
28 | | - - name: Validate pyproject.toml version matches tag |
| 20 | + - name: Validate version tag matches pyproject.toml |
29 | 21 | run: | |
30 | | - PYPROJECT_VERSION=$(poetry version -s) |
31 | | - if [ "$PYPROJECT_VERSION" != "$TAG_VERSION" ]; then |
32 | | - echo "Version mismatch! Tag is v$TAG_VERSION but pyproject.toml has $PYPROJECT_VERSION" |
| 22 | + TAG_VERSION="${GITHUB_REF#refs/tags/v}" |
| 23 | + PROJECT_VERSION=$(poetry version -s) |
| 24 | + if [ "$TAG_VERSION" != "$PROJECT_VERSION" ]; then |
| 25 | + echo "Tag v$TAG_VERSION does not match pyproject.toml version $PROJECT_VERSION" |
33 | 26 | exit 1 |
34 | 27 | fi |
35 | | - echo "Version check passed: $PYPROJECT_VERSION" |
36 | | -
|
37 | | - - name: Configure Poetry for publishing |
38 | | - run: poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} |
39 | 28 |
|
40 | 29 | - name: Install dependencies |
41 | 30 | run: poetry install --no-dev |
42 | 31 |
|
43 | 32 | - name: Build package |
44 | 33 | run: poetry build |
45 | 34 |
|
| 35 | + - name: Verify with Twine |
| 36 | + run: | |
| 37 | + pip install --no-cache-dir twine |
| 38 | + twine check dist/* |
| 39 | +
|
46 | 40 | - name: Publish to PyPI |
47 | | - run: poetry publish |
| 41 | + run: | |
| 42 | + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} |
| 43 | + poetry publish |
0 commit comments