diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..288fc1b --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# All permissions +* @wolflu05 diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..18df8da --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,26 @@ +# .github/release.yml + +changelog: + categories: + - title: ":boom: Breaking Changes" + labels: + - Semver-Major + - breaking + - title: ":sparkles: New Features" + labels: + - Semver-Minor + - type/feature + - type/enhancement + - type/fields + - title: ":bug: Bug Fixes" + labels: + - Semver-Patch + - type/bug + - title: ":package: Devops / Setup / Docs Changes" + labels: + - type/setup + - type/documentation + - type/dependencies + - title: ":memo: Other Changes" + labels: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e8e25dd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,113 @@ +name: CI + +on: + push: + pull_request: + release: + types: [published] + +jobs: + style-python: + name: "💄 Style: python" + if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3.5.3 + + - name: Setup python + uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # pin@v4.7.0 + with: + python-version: "3.10" + + - name: Install style check dependencies + run: | + pip install flake8==6.0.0 + pip install pep8-naming==0.13.2 + + - name: Check style + run: | + flake8 . + + style-js: + name: "💄 Style: js" + if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3.5.3 + + - name: Setup node + uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # pin@v3.7.0 + with: + node-version: "18" + + - name: Install dependencies + run: cd inventree_template_editor/frontend && npm ci + + - name: Check style + run: cd inventree_template_editor/frontend && npm run lint + + build-js: + name: "🏗️ Build: js" + needs: [style-js] + if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3.5.3 + + - name: Setup node + uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # pin@v3.7.0 + with: + node-version: "18" + + - name: Install dependencies + run: cd inventree_template_editor/frontend && npm ci + + - name: Build js + run: cd inventree_template_editor/frontend && npm run build + + - name: Upload frontend artifact + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # pin@v3.1.2 + with: + name: frontend + path: inventree_template_editor/static/dist + + publish: + if: github.event_name == 'release' && github.event.action == 'published' + needs: [build-js] + name: 📦 Publish to PyPi + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/p/inventree-template-editor-plugin + permissions: + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3.5.3 + + - name: Setup python + uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # pin@v4.7.0 + with: + python-version: "3.10" + + - name: Install build dependencies + run: pip install --upgrade wheel setuptools twine build + + - name: Download frontend artifact + uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # pin@v3.0.2 + with: + name: frontend + path: inventree_template_editor/static/dist + + - name: Build pip package + run: python3 -m build + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@f8c70e705ffc13c3b4d1221169b84f12a75d6ca8 # pin@v1.8.8 diff --git a/inventree_template_editor/InvenTreeTemplateEditorPlugin.py b/inventree_template_editor/InvenTreeTemplateEditorPlugin.py index 475671b..eed7600 100644 --- a/inventree_template_editor/InvenTreeTemplateEditorPlugin.py +++ b/inventree_template_editor/InvenTreeTemplateEditorPlugin.py @@ -9,6 +9,7 @@ from .version import TEMPLATE_EDITOR_PLUGIN_VERSION + class InvenTreeTemplateEditorPlugin(InvenTreePlugin, UserInterfaceMixin): AUTHOR = "wolflu05" DESCRIPTION = "InvenTree template editor plugin" @@ -25,7 +26,7 @@ def get_ui_features(self, feature_type: FeatureType, context: dict, request: Req if feature_type != "template_editor" or context.get("template_type", None) != "labeltemplate": return [] - IS_DEV = settings.CUSTOMIZE.get("inventree_template_editor_plugin_dev", False) + is_dev = settings.CUSTOMIZE.get("inventree_template_editor_plugin_dev", False) return [ { @@ -35,6 +36,6 @@ def get_ui_features(self, feature_type: FeatureType, context: dict, request: Req "title": _("Label Designer"), "icon": "build" }, - "source": plugin_static({}, "labelEditor.dev.js" if IS_DEV else "dist/labelEditor.js", plugin="inventree-template-editor-plugin"), + "source": plugin_static({}, "labelEditor.dev.js" if is_dev else "dist/labelEditor.js", plugin="inventree-template-editor-plugin"), } ]