Skip to content

Commit 5455daa

Browse files
authored
Track downloads, update manifest on publish (#561)
* Track downloads, update manifest on publish * fix name
1 parent 4d126fe commit 5455daa

File tree

4 files changed

+84
-3
lines changed

4 files changed

+84
-3
lines changed

.github/workflows/publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
release_zip_file:
13+
name: Publish zip file asset
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: 📥 Checkout the repository
19+
uses: actions/[email protected]
20+
21+
- name: 🛠️ Set up Python
22+
uses: actions/[email protected]
23+
with:
24+
python-version: "3.x"
25+
26+
- name: 🔢 Get version
27+
id: version
28+
uses: home-assistant/actions/helpers/version@master
29+
30+
- name: 🔢 Set version number
31+
run: |
32+
python3 ${{ github.workspace }}/manage/update_manifest.py --version ${{ steps.version.outputs.version }}
33+
34+
- name: 📤 Upload zip to action
35+
uses: actions/[email protected]
36+
if: ${{ github.event_name == 'push' }}
37+
with:
38+
name: ocpp
39+
path: ${{ github.workspace }}/custom_components/ocpp
40+
41+
# Pack the dir as a zip and upload to the release
42+
- name: 📦 ZIP Dir
43+
if: ${{ github.event_name == 'release' }}
44+
run: |
45+
cd ${{ github.workspace }}/custom_components/ocpp
46+
zip ocpp.zip -r ./
47+
48+
- name: 📤 Upload zip to release
49+
uses: softprops/action-gh-release@v1
50+
if: ${{ github.event_name == 'release' }}
51+
with:
52+
files: ${{ github.workspace }}/custom_components/ocpp/ocpp.zip

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![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)
44
[![codecov](https://codecov.io/gh/lbbrhzn/ocpp/branch/main/graph/badge.svg?token=3FRJIF5KRW)](https://codecov.io/gh/lbbrhzn/ocpp)
55
[![Documentation Status](https://readthedocs.org/projects/home-assistant-ocpp/badge/?version=latest)](https://home-assistant-ocpp.readthedocs.io/en/latest/?badge=latest)
6+
[![hacs_downloads](https://img.shields.io/github/downloads/lbbrhzn/ocpp/latest/total)](https://github.com/lbbrhzn/ocpp/releases/latest)
67

78
![OCPP](https://github.com/home-assistant/brands/raw/master/custom_integrations/ocpp/icon.png)
89

hacs.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"name": "Open Charge Point Protocol (OCPP)",
33
"content_in_root": false,
4-
"homeassistant": "2021.12.0",
5-
"render_readme": true
6-
}
4+
"homeassistant": "2022.7.0",
5+
"render_readme": true,
6+
"zip_release": true,
7+
"filename": "ocpp.zip"
8+
}

manage/update_manifest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Update the manifest file."""
2+
# https://github.com/hacs/integration/blob/main/manage/update_manifest.py
3+
import json
4+
import os
5+
import sys
6+
7+
8+
def update_manifest():
9+
"""Update the manifest file."""
10+
version = "0.0.0"
11+
for index, value in enumerate(sys.argv):
12+
if value in ["--version", "-V"]:
13+
version = sys.argv[index + 1]
14+
15+
with open(f"{os.getcwd()}/custom_components/ocpp/manifest.json") as manifestfile:
16+
manifest = json.load(manifestfile)
17+
18+
manifest["version"] = version
19+
20+
with open(
21+
f"{os.getcwd()}/custom_components/ocpp/manifest.json", "w"
22+
) as manifestfile:
23+
manifestfile.write(json.dumps(manifest, indent=4, sort_keys=True))
24+
25+
26+
update_manifest()

0 commit comments

Comments
 (0)