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

Add Version to Manifest #66

Merged
merged 4 commits into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This GitHub action workflow is meant to be copyable to any repo that have the same structure.
# - Your integration exist under custom_components/{INTEGRATION_NAME}/[integration files]
# - You are using GitHub releases to publish new versions
# - You have a INTEGRATION_VERSION constant in custom_components/{INTEGRATION_NAME}/const.py

name: Release Workflow

on:
release:
types: [published]

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout the repository
uses: actions/checkout@v2

- name: 🔢 Get release version
id: version
uses: home-assistant/actions/helpers/version@master

- name: ℹ️ Get integration information
id: information
run: |
name=$(find custom_components/ -type d -maxdepth 1 | tail -n 1 | cut -d "/" -f2)
echo "::set-output name=name::$name"

- name: 🖊️ Set version number
run: |
sed -i '/INTEGRATION_VERSION = /c\INTEGRATION_VERSION = "${{ steps.version.outputs.version }}"' \
"${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py"
jq '.version = "${{ steps.version.outputs.version }}"' \
"${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json" > tmp \
&& mv -f tmp "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json"

- name: 👀 Validate data
run: |
if ! grep -q 'INTEGRATION_VERSION = "${{ steps.version.outputs.version }}"' ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py; then
echo "The version in custom_components/${{ steps.information.outputs.name }}/const.py was not correct"
cat ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py | grep INTEGRATION_VERSION
exit 1
fi
manifestversion=$(jq -r '.version' ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json)
if [ "$manifestversion" != "${{ steps.version.outputs.version }}" ]; then
echo "The version in custom_components/${{ steps.information.outputs.name }}/manifest.json was not correct"
echo "$manifestversion"
exit 1
fi

- name: 📦 Create zip file for the integration
run: |
cd "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}"
zip ${{ steps.information.outputs.name }}.zip -r ./

- name: 📤 Upload the zip file as a release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/${{ steps.information.outputs.name }}.zip"
asset_name: ${{ steps.information.outputs.name }}.zip
asset_content_type: application/zip
24 changes: 24 additions & 0 deletions custom_components/authenticated/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Constants for authenticated."""

DOMAIN = "authenticated"
INTEGRATION_VERSION = "main"
ISSUE_URL = "https://github.com/custom-components/authenticated/issues"

STARTUP = f"""
-------------------------------------------------------------------
{DOMAIN}
Version: {INTEGRATION_VERSION}
This is a custom component
If you have any issues with this you need to open an issue here:
https://github.com/custom-components/authenticated/issues
-------------------------------------------------------------------
"""


CONF_NOTIFY = "enable_notification"
CONF_EXCLUDE = "exclude"
CONF_EXCLUDE_CLIENTS = "exclude_clients"
CONF_PROVIDER = "provider"
CONF_LOG_LOCATION = "log_location"

OUTFILE = ".ip_authenticated.yaml"
3 changes: 2 additions & 1 deletion custom_components/authenticated/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"domain": "authenticated",
"name": "Authenticated",
"version": "v0.0.0",
"documentation": "https://github.com/custom-components/authenticated",
"dependencies": [],
"codeowners": ["@ludeeus"],
"requirements": []
}
}
14 changes: 4 additions & 10 deletions custom_components/authenticated/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@
from homeassistant.helpers.entity import Entity

from .providers import PROVIDERS
from .const import OUTFILE, CONF_NOTIFY, CONF_EXCLUDE, CONF_EXCLUDE_CLIENTS, CONF_PROVIDER, CONF_LOG_LOCATION, STARTUP

_LOGGER = logging.getLogger(__name__)

CONF_NOTIFY = "enable_notification"
CONF_EXCLUDE = "exclude"
CONF_EXCLUDE_CLIENTS = "exclude_clients"
CONF_PROVIDER = "provider"
CONF_LOG_LOCATION = "log_location"

ATTR_HOSTNAME = "hostname"
ATTR_COUNTRY = "country"
ATTR_REGION = "region"
Expand All @@ -39,10 +34,6 @@
SCAN_INTERVAL = timedelta(minutes=1)

PLATFORM_NAME = "authenticated"

LOGFILE = "home-assistant.log"
OUTFILE = ".ip_authenticated.yaml"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_PROVIDER, default="ipapi"): vol.In(
Expand All @@ -62,6 +53,9 @@ def humanize_time(timestring):


def setup_platform(hass, config, add_devices, discovery_info=None):
# Print startup message
_LOGGER.info(STARTUP)

"""Create the sensor"""
notify = config.get(CONF_NOTIFY)
exclude = config.get(CONF_EXCLUDE)
Expand Down