From 7a33798e26ab5b5cb0be37c8b84528f6f51b8049 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Wed, 18 Sep 2024 23:19:08 -0500 Subject: [PATCH 1/2] Convert to pyproject.toml --- .github/workflows/build-test.yml | 28 +++++++++++++++ .github/workflows/pypi.yml | 62 +++++++++++++++++++++----------- netbox_lifecycle/__init__.py | 4 +-- pyproject.toml | 38 ++++++++++++++++++++ setup.py | 25 ------------- 5 files changed, 110 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/build-test.yml create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..d73bf44 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,28 @@ +name: Build Test +on: [push, pull_request] + +jobs: + build: + name: Build Distribution + runs-on: ubuntu-latest + environment: + name: build + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade setuptools wheel + python -m pip install build --user + - name: Build a binary wheel and a source tarball + run: python -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ \ No newline at end of file diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 5d6c7ec..1ba8330 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -4,41 +4,63 @@ on: types: released jobs: + build: + name: Build Distribution runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.9] + environment: release steps: - - name: Checkout repo - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} - + python-version: 3.12 - name: Install dependencies run: | python -m pip install --upgrade pip pip install --upgrade setuptools wheel - - - - name: Build - run: python setup.py sdist bdist_wheel - + python -m pip install build --user + - name: Build a binary wheel and a source tarball + run: python -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + publish-to-testpypi: + name: Publish Python 🐍 distribution 📦 to PyPI + needs: + - build + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/p/netbox-lifecycle + permissions: + id-token: write + steps: - name: Publish package to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - user: __token__ - password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ skip_existing: true - + publish-to-pypi: + name: Publish Python 🐍 distribution 📦 to PyPI + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/netbox-lifecycle + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ - name: Publish package uses: pypa/gh-action-pypi-publish@release/v1 with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} skip_existing: true \ No newline at end of file diff --git a/netbox_lifecycle/__init__.py b/netbox_lifecycle/__init__.py index 9adfade..817e5c8 100644 --- a/netbox_lifecycle/__init__.py +++ b/netbox_lifecycle/__init__.py @@ -7,8 +7,8 @@ class NetBoxLifeCycle(PluginConfig): name = metadata.get('Name').replace('-', '_') - verbose_name = metadata.get('Summary') - description = metadata.get('Description') + verbose_name = metadata.get('Name').replace('-', ' ').title() + description = metadata.get('Summary') version = metadata.get('Version') author = metadata.get('Author') author_email = metadata.get('Author-email') diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1df76ff --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ +[build-system] +requires = [ + "setuptools", + "wheel" +] +build-backend = "setuptools.build_meta" + +[project] +name = "netbox-lifecycle" +authors = [ + {name = "Daniel Sheppard", email = "dans@dansheps.com"} +] +maintainers = [ + {name = "Daniel Sheppard", email = "dans@dansheps.com"}, +] +description = "NetBox Support Contract and EOL/EOS management" +readme = "README.md" +requires-python = ">=3.10" +keywords = ["netbox-plugin", ] +version = "1.1.3-beta1" +license = {file = "LICENSE"} +classifiers = [ + "Programming Language :: Python :: 3", +] +dependencies = [ + 'django-polymorphic', +] + +[project.urls] +Documentation = "https://github.com/dansheps/netbox-lifecycle/blob/main/README.md" +Source = "https://github.com/dansheps/netbox-lifecycle" +Tracker = "https://github.com/dansheps/netbox-lifecycle/issues" + +[tool.setuptools.packages.find] +exclude=["netbox_lifecycle.tests"] + +[tool.black] +skip-string-normalization = 1 \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 3e33760..0000000 --- a/setup.py +++ /dev/null @@ -1,25 +0,0 @@ -from setuptools import find_packages, setup - -setup( - name='netbox-lifecycle', - version='1.1.3-beta1', - description='NetBox Lifecycle', - long_description='NetBox Support Contract and EOL/EOS management', - url='https://github.com/dansheps/netbox-lifecycle/', - download_url='https://pypi.org/project/netbox-lifecycle/', - author='Daniel Sheppard', - author_email='dans@dansheps.com', - maintainer='Daniel Sheppard', - maintainer_email='dans@dansheps.com', - install_requires=[], - packages=find_packages(), - include_package_data=True, - license='Proprietary', - zip_safe=False, - platform=[], - keywords=['netbox', 'netbox-plugin'], - classifiers=[ - 'Framework :: Django', - 'Programming Language :: Python :: 3', - ] -) \ No newline at end of file From 4904aad42736ad0b18a81caae353742329ff1071 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Wed, 18 Sep 2024 23:32:42 -0500 Subject: [PATCH 2/2] Some minor action changes --- .github/workflows/ci.yml | 2 +- .github/workflows/pypi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e47de0a..1419def 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ on: branches: - 'master' concurrency: - group: ci-${{ github.action }}-${{ github.ref }}-${{ github.actor }} + group: ci-${{ github.event_name }}-${{ github.ref }}-${{ github.actor }} cancel-in-progress: true permissions: contents: read diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 1ba8330..a975d6a 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -6,7 +6,7 @@ on: jobs: build: - name: Build Distribution + name: Build Distribution for PyPI runs-on: ubuntu-latest environment: release steps: