1- name : Publish to Test PyPI
1+ name : Test and Publish to PyPI
22
33on :
4- push :
54 workflow_dispatch :
65
7-
86jobs :
9- test-and-publish :
7+ test :
8+ if : startsWith(github.ref, 'refs/heads/v')
109 runs-on : ubuntu-latest
1110
1211 steps :
1615 - name : Set up Python
1716 uses : actions/setup-python@v5
1817 with :
19- python-version : ' 3.11 '
18+ python-version : ' 3.12 '
2019
2120 - name : Install Poetry and dependencies
2221 run : |
2726 - name : Run tests
2827 run : poetry run pytest
2928
29+ publish :
30+ if : startsWith(github.ref, 'refs/heads/v')
31+ needs : test
32+ runs-on : ubuntu-latest
33+
34+ steps :
35+ - name : Checkout code
36+ uses : actions/checkout@v4
37+
38+ - name : Set up Python
39+ uses : actions/setup-python@v5
40+ with :
41+ python-version : ' 3.11'
42+
43+ - name : Install Poetry and dependencies
44+ run : |
45+ curl -sSL https://install.python-poetry.org | python3 -
46+ echo "$HOME/.local/bin" >> $GITHUB_PATH
47+ poetry install
48+
3049 - name : Extract version from pyproject.toml
3150 id : get_version
3251 run : |
@@ -35,15 +54,15 @@ jobs:
3554 - name : Show extracted version
3655 run : echo "Publishing version $VERSION"
3756
38- - name : Build the package
39- run : poetry build
40-
4157 - name : Clean old builds
4258 run : rm -rf dist/
59+
60+ - name : Build the package
61+ run : poetry build
4362
44- - name : Publish to Test PyPI
63+ - name : Publish to PyPI
4564 env :
46- POETRY_PYPI_TOKEN_TESTPYPI : ${{ secrets.TEST_PYPI_TOKEN }}
65+ POETRY_PYPI_TOKEN_PYPI : ${{ secrets.PYPI_TOKEN }}
4766 run : |
48- poetry config repositories.testpypi https://test. pypi.org/legacy/
49- poetry publish -r testpypi --build - -no-interaction
67+ poetry config pypi-token.pypi $POETRY_PYPI_TOKEN_PYPI
68+ poetry publish --no-interaction
0 commit comments