Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Added workflow for publishing PyPI packages #404

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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