Skip to content

Commit a1703dc

Browse files
committed
ci: Publish distribution files to PyPI
Add steps to publish distribution files to PyPI when a tag is created. The Python version used to create the wheel is updated just for consistency with other projects, it shouldn't really affect the resulting wheel because this is a pure python package, so it doesn't depend on the Python version, is just shipping text files. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 6f0f6a2 commit a1703dc

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

.github/workflows/ci.yaml

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,51 @@ jobs:
3434
- name: Install required Python packages
3535
run: |
3636
python -m pip install --upgrade pip
37-
python -m pip install nox wheel
37+
python -m pip install nox
3838
3939
- name: run nox
4040
run: nox -e ci_checks_max pytest_min
4141
timeout-minutes: 10
4242

43-
build-wheels:
43+
build-dist:
4444
runs-on: ubuntu-20.04
45-
needs: test
46-
4745
steps:
48-
- name: Fetch sources
49-
uses: actions/checkout@v3
46+
- name: Fetch sources
47+
uses: actions/checkout@v3
5048

51-
- name: Set up Python
52-
uses: actions/setup-python@v4
53-
with:
54-
python-version: 3.8
49+
- name: Set up Python
50+
uses: actions/setup-python@v4
51+
with:
52+
python-version: "3.10"
5553

56-
- uses: actions/cache@v3
57-
with:
58-
path: ~/.cache/pip
59-
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('minimum-requirements-ci.txt', 'pyproject.toml') }}
60-
restore-keys: |
61-
${{ runner.os }}-${{ matrix.python-version }}-pip-
54+
- name: Install build dependencies
55+
run: |
56+
python -m pip install -U pip
57+
python -m pip install -U build
6258
63-
- name: Install required Python packages
64-
run: |
65-
python -m pip install --upgrade pip
66-
python -m pip install wheel
59+
- name: Build the source and binary distribution
60+
run: python -m build
6761

68-
- name: make wheel
69-
run: python -m pip wheel --no-deps -w dist .
62+
- name: Upload dist files
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: frequenz-sdk-python-dist
66+
path: dist/
67+
if-no-files-found: error
68+
69+
publish-to-pypi:
70+
needs: ["test", "build-dist"]
71+
# Publish only on tags creation
72+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
73+
runs-on: ubuntu-20.04
74+
steps:
75+
- name: Download dist files
76+
uses: actions/download-artifact@v3
77+
with:
78+
name: frequenz-sdk-python-dist
7079

71-
- name: upload wheels
72-
uses: actions/upload-artifact@v3
73-
with:
74-
name: frequenz-sdk-python-wheels
75-
path: dist/*.whl
80+
- name: Publish the Python distribution to PyPI
81+
uses: pypa/gh-action-pypi-publish@release/v1
82+
with:
83+
password: ${{ secrets.PYPI_API_TOKEN }}
84+
skip_existing: true

0 commit comments

Comments
 (0)