Skip to content

Commit

Permalink
[ci] Added workflow for publishing PyPI packages
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy authored Aug 16, 2024
1 parent a773849 commit 4f92a65
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish Python Package to Pypi.org

on:
release:
types: [published]

permissions:
id-token: write

jobs:
pypi-publish:
name: Release Python Package on Pypi.org
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/openwisp-utils
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install -U pip
pip install build
- name: Build package
run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/[email protected]
7 changes: 6 additions & 1 deletion openwisp_utils/metric_collection/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ class Migration(migrations.Migration):
"user_consented",
models.BooleanField(
default=True,
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>.',
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>.'
),
verbose_name="Allow collecting anonymous usage metrics",
),
),
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@ use_parentheses=True
line_length=88

[flake8]
exclude = *migrations/0*,,
./tests/*settings*.py,
./*setup*.py
max-line-length = 110
16 changes: 0 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
#!/usr/bin/env python
import os
import sys

from openwisp_utils import get_version
from setuptools import find_packages, setup

if sys.argv[-1] == 'publish':
# delete any *.pyc, *.pyo and __pycache__
os.system('find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf')
os.system("python setup.py sdist bdist_wheel")
os.system("twine upload -s dist/*")
os.system("rm -rf dist build")
args = {'version': get_version()}
print("You probably want to also tag the version now:")
print(" git tag -a %(version)s -m 'version %(version)s'" % args)
print(" git push --tags")
sys.exit()


setup(
name='openwisp-utils',
version=get_version(),
Expand Down
2 changes: 1 addition & 1 deletion tests/openwisp2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@

# local settings must be imported before test runner otherwise they'll be ignored
try:
from local_settings import *
from local_settings import * # noqa
except ImportError:
pass

0 comments on commit 4f92a65

Please sign in to comment.