Skip to content

Commit 09dea3a

Browse files
authored
Update python-publish.yml
1 parent 5a6c25d commit 09dea3a

1 file changed

Lines changed: 33 additions & 21 deletions

File tree

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,50 @@
11
# This workflow will upload a Python Package using Twine when a release is created
22
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
33

4-
name: Upload Python Package to PyPI
4+
name: Upload Python Package
55

66
on:
77
release:
88
types: [created]
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
deploy:
1215

1316
runs-on: ubuntu-latest
14-
env:
15-
FASTAPI_FF: '{"json_only": False, "file_1": True, "file_2": False, "file_3": True, "file_4": True}'
16-
17+
1718
steps:
18-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
1920
- name: Set up Python
20-
uses: actions/setup-python@v2
21+
uses: actions/setup-python@v3
2122
with:
2223
python-version: '3.x'
24+
- name: Install Poetry
25+
uses: snok/install-poetry@v1
26+
with:
27+
virtualenvs-create: true
28+
virtualenvs-in-project: true
29+
installer-parallel: true
30+
- name: Load cached venv
31+
id: cached-poetry-dependencies
32+
uses: actions/cache@v3
33+
with:
34+
path: .venv
35+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
2336
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
python -m pip install pytest pytest-cov
27-
python -m pip install setuptools wheel twine
28-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
29-
- name: Tests with pytest
30-
run: |
31-
python3 -m pytest --cov=fastapi_featureflags -v tests/ --disable-warnings
32-
- name: Build and publish
33-
env:
34-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
35-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
36-
run: |
37-
python setup.py sdist bdist_wheel
38-
twine upload dist/*
37+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
38+
run: poetry install --no-interaction --no-root
39+
40+
- name: Build package
41+
run:
42+
source .venv/bin/activate
43+
poetry build
44+
- name: Publish package
45+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
46+
with:
47+
user: __token__
48+
password: ${{ secrets.PYPI_API_TOKEN }}
49+
50+

0 commit comments

Comments
 (0)