diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..b1ed529 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,40 @@ +--- +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 1242dfb..72ffe60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [Unreleased](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/tree/HEAD) + +[Full Changelog](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/compare/v0.0.2...HEAD) + +**Merged pull requests:** + +- Prepare for public release [\#5](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/pull/5) ([abhi1693](https://github.com/abhi1693)) + ## [v0.0.2](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/tree/v0.0.2) (2023-01-22) [Full Changelog](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/compare/v0.0.1...v0.0.2) diff --git a/README.md b/README.md index 2a37afd..7fbeee6 100644 --- a/README.md +++ b/README.md @@ -5,32 +5,38 @@ The plugin uses [GitHub GraphQL API](https://docs.github.com/en/graphql) to load DeviceType and ModuleType from [NetBox Device Type Library](https://github.com/netbox-community/devicetype-library). The plugin loads only file tree representation from GitHub repo and shows it as a table with vendor and model columns. DeviceType definitions files are loaded when you try to import selected models. To use GraphQL API you need to set GitHub personal access token in plugin settings. How to create the token, see ["Creating a personal access token."](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) -## Compatibility +# Compatibility -This plugin in compatible with [NetBox](https://netbox.readthedocs.org/) 3.4 and later +| NetBox Version | Plugin Version | +|:----------------:|:--------------:| +| 3.4.x | 0.0.x | -## Installation +# Installation -The plugin is available as a Python package in pypi and can be installed with pip - -``` -pip install git+https://github.com/Onemind-Services-LLC/netbox-metatype-importer.git -``` -Enable the plugin in [NetBox Configuration](https://netbox.readthedocs.io/en/stable/configuration/) -``` -PLUGINS = ['netbox_metatype_importer'] -``` +* Install NetBox as per NetBox documentation +* Add to local_requirements.txt: + * `netbox-metatype-importer` +* Install requirements: `./venv/bin/pip install -r local_requirements.txt` +* Add to PLUGINS in NetBox configuration: + * `'netbox_metatype_importer',` +* Run migration: `./venv/bin/python netbox/manage.py migrate` ## Configuration -Put your GitHub personal access token to [NetBox plugins config](https://netbox.readthedocs.io/en/stable/configuration/optional-settings/#plugins_config) -``` -PLUGINS_CONFIG = { - 'netbox_metatype_importer': { - 'github_token': '' - } -} -``` - -## Future -* Import device images from GitHub repo +The following options are available in the configuration file: + +- `branch` + - __Type__: `String` + - __Description__: Branch of the NetBox Device Type Library repo + - __Default__: `master` +- `github_token` + - __Type__: `String` + - __Description__: GitHub personal access token +- `repo` + - __Type__: `String` + - __Description__: Name of the NetBox Device Type Library repo + - __Default__: `devicetype-library` +- `repo_owner` + - __Type__: `String` + - __Description__: Owner of the NetBox Device Type Library repo + - __Default__: `netbox-community` diff --git a/configuration/plugins.py b/configuration/plugins.py index 2a4fc90..a5363f0 100644 --- a/configuration/plugins.py +++ b/configuration/plugins.py @@ -9,5 +9,7 @@ ] PLUGINS_CONFIG = { # type: ignore - "netbox_metatype_importer": {}, + "netbox_metatype_importer": { + 'github_token': 'YOUR_GITHUB_TOKEN' + }, } diff --git a/netbox_metatype_importer/__init__.py b/netbox_metatype_importer/__init__.py index b8dfbca..ca900ef 100644 --- a/netbox_metatype_importer/__init__.py +++ b/netbox_metatype_importer/__init__.py @@ -18,9 +18,9 @@ class NetBoxMetatypeImporterConfig(PluginConfig): 'repo_owner': 'netbox-community', 'repo': 'devicetype-library', 'branch': 'master', - 'github_token': '', - 'use_gql': True, + 'github_token': '' } + required_settings = ['github_token'] config = NetBoxMetatypeImporterConfig diff --git a/setup.py b/setup.py index 6f347f3..73aa2a8 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='netbox-metatype-importer', - version='0.0.2', + version='0.0.3', description='Import Metatypes', long_description='Import MetaTypes into NetBox', long_description_content_type="text/markdown",