Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit cf3400f

Browse files
authored
Add Version to Manifest (#66)
1 parent 10f88ba commit cf3400f

File tree

4 files changed

+95
-11
lines changed

4 files changed

+95
-11
lines changed

.github/workflows/release.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This GitHub action workflow is meant to be copyable to any repo that have the same structure.
2+
# - Your integration exist under custom_components/{INTEGRATION_NAME}/[integration files]
3+
# - You are using GitHub releases to publish new versions
4+
# - You have a INTEGRATION_VERSION constant in custom_components/{INTEGRATION_NAME}/const.py
5+
6+
name: Release Workflow
7+
8+
on:
9+
release:
10+
types: [published]
11+
12+
jobs:
13+
release:
14+
name: Release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: 📥 Checkout the repository
18+
uses: actions/checkout@v2
19+
20+
- name: 🔢 Get release version
21+
id: version
22+
uses: home-assistant/actions/helpers/version@master
23+
24+
- name: ℹ️ Get integration information
25+
id: information
26+
run: |
27+
name=$(find custom_components/ -type d -maxdepth 1 | tail -n 1 | cut -d "/" -f2)
28+
echo "::set-output name=name::$name"
29+
30+
- name: 🖊️ Set version number
31+
run: |
32+
sed -i '/INTEGRATION_VERSION = /c\INTEGRATION_VERSION = "${{ steps.version.outputs.version }}"' \
33+
"${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py"
34+
jq '.version = "${{ steps.version.outputs.version }}"' \
35+
"${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json" > tmp \
36+
&& mv -f tmp "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json"
37+
38+
- name: 👀 Validate data
39+
run: |
40+
if ! grep -q 'INTEGRATION_VERSION = "${{ steps.version.outputs.version }}"' ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py; then
41+
echo "The version in custom_components/${{ steps.information.outputs.name }}/const.py was not correct"
42+
cat ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py | grep INTEGRATION_VERSION
43+
exit 1
44+
fi
45+
manifestversion=$(jq -r '.version' ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json)
46+
if [ "$manifestversion" != "${{ steps.version.outputs.version }}" ]; then
47+
echo "The version in custom_components/${{ steps.information.outputs.name }}/manifest.json was not correct"
48+
echo "$manifestversion"
49+
exit 1
50+
fi
51+
52+
- name: 📦 Create zip file for the integration
53+
run: |
54+
cd "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}"
55+
zip ${{ steps.information.outputs.name }}.zip -r ./
56+
57+
- name: 📤 Upload the zip file as a release asset
58+
uses: actions/upload-release-asset@v1
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
with:
62+
upload_url: ${{ github.event.release.upload_url }}
63+
asset_path: "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/${{ steps.information.outputs.name }}.zip"
64+
asset_name: ${{ steps.information.outputs.name }}.zip
65+
asset_content_type: application/zip
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Constants for authenticated."""
2+
3+
DOMAIN = "authenticated"
4+
INTEGRATION_VERSION = "main"
5+
ISSUE_URL = "https://github.com/custom-components/authenticated/issues"
6+
7+
STARTUP = f"""
8+
-------------------------------------------------------------------
9+
{DOMAIN}
10+
Version: {INTEGRATION_VERSION}
11+
This is a custom component
12+
If you have any issues with this you need to open an issue here:
13+
https://github.com/custom-components/authenticated/issues
14+
-------------------------------------------------------------------
15+
"""
16+
17+
18+
CONF_NOTIFY = "enable_notification"
19+
CONF_EXCLUDE = "exclude"
20+
CONF_EXCLUDE_CLIENTS = "exclude_clients"
21+
CONF_PROVIDER = "provider"
22+
CONF_LOG_LOCATION = "log_location"
23+
24+
OUTFILE = ".ip_authenticated.yaml"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"domain": "authenticated",
33
"name": "Authenticated",
4+
"version": "v0.0.0",
45
"documentation": "https://github.com/custom-components/authenticated",
56
"dependencies": [],
67
"codeowners": ["@ludeeus"],
78
"requirements": []
8-
}
9+
}

custom_components/authenticated/sensor.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@
1818
from homeassistant.helpers.entity import Entity
1919

2020
from .providers import PROVIDERS
21+
from .const import OUTFILE, CONF_NOTIFY, CONF_EXCLUDE, CONF_EXCLUDE_CLIENTS, CONF_PROVIDER, CONF_LOG_LOCATION, STARTUP
2122

2223
_LOGGER = logging.getLogger(__name__)
2324

24-
CONF_NOTIFY = "enable_notification"
25-
CONF_EXCLUDE = "exclude"
26-
CONF_EXCLUDE_CLIENTS = "exclude_clients"
27-
CONF_PROVIDER = "provider"
28-
CONF_LOG_LOCATION = "log_location"
29-
3025
ATTR_HOSTNAME = "hostname"
3126
ATTR_COUNTRY = "country"
3227
ATTR_REGION = "region"
@@ -39,10 +34,6 @@
3934
SCAN_INTERVAL = timedelta(minutes=1)
4035

4136
PLATFORM_NAME = "authenticated"
42-
43-
LOGFILE = "home-assistant.log"
44-
OUTFILE = ".ip_authenticated.yaml"
45-
4637
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
4738
{
4839
vol.Optional(CONF_PROVIDER, default="ipapi"): vol.In(
@@ -62,6 +53,9 @@ def humanize_time(timestring):
6253

6354

6455
def setup_platform(hass, config, add_devices, discovery_info=None):
56+
# Print startup message
57+
_LOGGER.info(STARTUP)
58+
6559
"""Create the sensor"""
6660
notify = config.get(CONF_NOTIFY)
6761
exclude = config.get(CONF_EXCLUDE)

0 commit comments

Comments
 (0)