diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..98ee52e2 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,52 @@ +name: Publish + +on: + release: + types: + - published + push: + branches: + - main + +jobs: + release_zip_file: + name: Publish zip file asset + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: 📥 Checkout the repository + uses: actions/checkout@v3.0.2 + + - name: 🛠️ Set up Python + uses: actions/setup-python@v4.0.0 + with: + python-version: "3.x" + + - name: 🔢 Get version + id: version + uses: home-assistant/actions/helpers/version@master + + - name: 🔢 Set version number + run: | + python3 ${{ github.workspace }}/manage/update_manifest.py --version ${{ steps.version.outputs.version }} + + - name: 📤 Upload zip to action + uses: actions/upload-artifact@v3.1.0 + if: ${{ github.event_name == 'push' }} + with: + name: ocpp + path: ${{ github.workspace }}/custom_components/ocpp + + # Pack the dir as a zip and upload to the release + - name: 📦 ZIP Dir + if: ${{ github.event_name == 'release' }} + run: | + cd ${{ github.workspace }}/custom_components/ocpp + zip ocpp.zip -r ./ + + - name: 📤 Upload zip to release + uses: softprops/action-gh-release@v1 + if: ${{ github.event_name == 'release' }} + with: + files: ${{ github.workspace }}/custom_components/ocpp/ocpp.zip \ No newline at end of file diff --git a/README.md b/README.md index ef4b73a9..355292b4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/lbbrhzn/ocpp.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/lbbrhzn/ocpp/context:python) [![codecov](https://codecov.io/gh/lbbrhzn/ocpp/branch/main/graph/badge.svg?token=3FRJIF5KRW)](https://codecov.io/gh/lbbrhzn/ocpp) [![Documentation Status](https://readthedocs.org/projects/home-assistant-ocpp/badge/?version=latest)](https://home-assistant-ocpp.readthedocs.io/en/latest/?badge=latest) +[![hacs_downloads](https://img.shields.io/github/downloads/lbbrhzn/ocpp/latest/total)](https://github.com/lbbrhzn/ocpp/releases/latest) ![OCPP](https://github.com/home-assistant/brands/raw/master/custom_integrations/ocpp/icon.png) diff --git a/hacs.json b/hacs.json index aa91f656..3a08f6c9 100644 --- a/hacs.json +++ b/hacs.json @@ -1,6 +1,8 @@ { "name": "Open Charge Point Protocol (OCPP)", "content_in_root": false, - "homeassistant": "2021.12.0", - "render_readme": true -} + "homeassistant": "2022.7.0", + "render_readme": true, + "zip_release": true, + "filename": "ocpp.zip" +} \ No newline at end of file diff --git a/manage/update_manifest.py b/manage/update_manifest.py new file mode 100644 index 00000000..55208c3d --- /dev/null +++ b/manage/update_manifest.py @@ -0,0 +1,26 @@ +"""Update the manifest file.""" +# https://github.com/hacs/integration/blob/main/manage/update_manifest.py +import json +import os +import sys + + +def update_manifest(): + """Update the manifest file.""" + version = "0.0.0" + for index, value in enumerate(sys.argv): + if value in ["--version", "-V"]: + version = sys.argv[index + 1] + + with open(f"{os.getcwd()}/custom_components/ocpp/manifest.json") as manifestfile: + manifest = json.load(manifestfile) + + manifest["version"] = version + + with open( + f"{os.getcwd()}/custom_components/ocpp/manifest.json", "w" + ) as manifestfile: + manifestfile.write(json.dumps(manifest, indent=4, sort_keys=True)) + + +update_manifest()