1- name : Publish to PyPI
1+ name : Publish Python Package
22
33on :
4- release :
5- types : [published ]
4+ push :
5+ branches : [ "main" ]
66
7- workflow_dispatch :
7+ permissions :
8+ contents : write
89
910jobs :
10- build_publish :
11+ publish :
12+ name : Build and publish to PyPI
1113 runs-on : ubuntu-latest
14+ environment : Production
15+
1216 steps :
13- - name : Checkout code
14- uses : actions/checkout@v2
15-
16- - name : Set up Python
17- uses : actions/setup-python@v2
18- with :
19- python-version : ' 3.9'
20-
21- - name : Install Poetry
22- run : |
23- pip install --upgrade pip
24- curl -sSL https://install.python-poetry.org | python3 -
25- poetry config virtualenvs.create false
26- poetry install
27-
28- - name : Build package
29- run : poetry build
30-
31- - name : Publish package to PyPI
32- env :
33- POETRY_PYPI_TOKEN_PYPI : ${{ secrets.PYPI_TOKEN }}
34- run : poetry publish --username __token__ --password $POETRY_PYPI_TOKEN_PYPI
35-
36- environment :
37- name : Production
38- url : https://pypi.org/project/api-to-dataframe/
17+ - uses : actions/checkout@v3
18+
19+ - name : Set up Python
20+ uses : actions/setup-python@v4
21+ with :
22+ python-version : ' 3.9'
23+
24+ - name : Install Poetry
25+ uses : snok/install-poetry@v1
26+ with :
27+ version : 1.6.1
28+ virtualenvs-create : true
29+ virtualenvs-in-project : true
30+
31+ - name : Install dependencies
32+ run : |
33+ poetry install --no-interaction
34+
35+ - name : Extract version
36+ id : extract_version
37+ run : |
38+ VERSION=$(poetry version -s)
39+ echo "version=$VERSION" >> $GITHUB_OUTPUT
40+ echo "Versão encontrada: $VERSION"
41+
42+ - name : Build package
43+ run : |
44+ poetry build
45+
46+ - name : Create GitHub Release
47+ uses : softprops/action-gh-release@v1
48+ with :
49+ tag_name : v${{ steps.extract_version.outputs.version }}
50+ name : Release v${{ steps.extract_version.outputs.version }}
51+ draft : false
52+ prerelease : false
53+ files : |
54+ dist/*
55+ env :
56+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
57+
58+ - name : Publish to PyPI
59+ run : |
60+ poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
61+ poetry publish
62+ env :
63+ PYPI_TOKEN : ${{ secrets.PYPI_TOKEN }}
0 commit comments