Skip to content

Commit 4f92a65

Browse files
authored
[ci] Added workflow for publishing PyPI packages
1 parent a773849 commit 4f92a65

5 files changed

Lines changed: 39 additions & 21 deletions

File tree

.github/workflows/pypi.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish Python Package to Pypi.org
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
id-token: write
9+
10+
jobs:
11+
pypi-publish:
12+
name: Release Python Package on Pypi.org
13+
runs-on: ubuntu-latest
14+
environment:
15+
name: pypi
16+
url: https://pypi.org/p/openwisp-utils
17+
permissions:
18+
id-token: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.10'
25+
- name: Install dependencies
26+
run: |
27+
pip install -U pip
28+
pip install build
29+
- name: Build package
30+
run: python -m build
31+
- name: Publish package distributions to PyPI
32+
uses: pypa/gh-action-pypi-publish@v1.9.0

openwisp_utils/metric_collection/migrations/0001_initial.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ class Migration(migrations.Migration):
4545
"user_consented",
4646
models.BooleanField(
4747
default=True,
48-
help_text='Allow OpenWISP to collect and share anonymous usage metrics to improve the software. Before opting-out kindly consider reading <a href="https://openwisp.io/docs/user/usage-metric-collection.html" target="_blank">why we collect metrics</a>.',
48+
help_text=(
49+
'Allow OpenWISP to collect and share anonymous usage metrics to improve'
50+
' the software. Before opting-out kindly consider reading'
51+
' <a href="https://openwisp.io/docs/user/usage-metric-collection.html"'
52+
' target="_blank">why we collect metrics</a>.'
53+
),
4954
verbose_name="Allow collecting anonymous usage metrics",
5055
),
5156
),

setup.cfg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,4 @@ use_parentheses=True
1212
line_length=88
1313

1414
[flake8]
15-
exclude = *migrations/0*,,
16-
./tests/*settings*.py,
17-
./*setup*.py
1815
max-line-length = 110

setup.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
#!/usr/bin/env python
2-
import os
3-
import sys
4-
52
from openwisp_utils import get_version
63
from setuptools import find_packages, setup
74

8-
if sys.argv[-1] == 'publish':
9-
# delete any *.pyc, *.pyo and __pycache__
10-
os.system('find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf')
11-
os.system("python setup.py sdist bdist_wheel")
12-
os.system("twine upload -s dist/*")
13-
os.system("rm -rf dist build")
14-
args = {'version': get_version()}
15-
print("You probably want to also tag the version now:")
16-
print(" git tag -a %(version)s -m 'version %(version)s'" % args)
17-
print(" git push --tags")
18-
sys.exit()
19-
20-
215
setup(
226
name='openwisp-utils',
237
version=get_version(),

tests/openwisp2/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@
131131

132132
# local settings must be imported before test runner otherwise they'll be ignored
133133
try:
134-
from local_settings import *
134+
from local_settings import * # noqa
135135
except ImportError:
136136
pass

0 commit comments

Comments
 (0)