Skip to content

Commit

Permalink
Adds github actions (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohNan authored Sep 13, 2023
1 parent 47e7c25 commit f3b8882
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 3 deletions.
35 changes: 35 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
change-template: '- #$NUMBER $TITLE @$AUTHOR'
sort-direction: ascending
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'

- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'

- title: '🧰 Maintenance'
label: 'chore'

version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
[![Downloads for this release](https://img.shields.io/github/downloads/JohNan/home-assistant-flichub/v$RESOLVED_VERSION/total.svg)](https://github.com/JohNan/home-assistant-flichub/releases/v$RESOLVED_VERSION)
## Changes
$CHANGES
36 changes: 36 additions & 0 deletions .github/workflows/cron.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Cron actions 16:30 every 4 days"
on:
schedule:
- cron: '30 16 */4 * *'

jobs:
validate-hassfest:
name: With hassfest
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: "Update manifest.json"
run: |
python3 ${{ github.workspace }}/manage/update_manifest.py
- name: Hassfest validation
uses: home-assistant/actions/hassfest@master

validate-hacs:
name: With HACS action
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: "Update manifest.json"
run: |
python3 ${{ github.workspace }}/manage/update_manifest.py
- name: HACS Validation
uses: hacs/action@main
with:
category: integration
comment: False
18 changes: 18 additions & 0 deletions .github/workflows/release-drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release Drafter

on:
push:
branches:
- main

jobs:
update_release_draft:
name: Update release draft
runs-on: ubuntu-latest
steps:
- name: Create Release
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


35 changes: 35 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on:
release:
types: [published]

jobs:
release_zip_file:
name: Prepare release asset
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2

- 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: Create zip
run: |
cd custom_components/flichub
zip flichub.zip -r ./
- name: Upload zip to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./custom_components/flichub/flichub.zip
asset_name: flichub.zip
tag: ${{ github.ref }}
overwrite: true
42 changes: 42 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Validate"

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
validate-hassfest:
name: With hassfest
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: "Update manifest.json"
run: |
python3 ${{ github.workspace }}/manage/update_manifest.py
- name: Hassfest validation
uses: home-assistant/actions/hassfest@master

validate-hacs:
name: With HACS action
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: "Update manifest.json"
run: |
python3 ${{ github.workspace }}/manage/update_manifest.py
- name: HACS Validation
uses: hacs/action@main
with:
ignore: brands
category: integration
comment: True
7 changes: 4 additions & 3 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "Flic Hub",
"hacs": "1.6.0",
"domains": ["binary_sensor", "sensor", "switch"],
"iot_class": "Cloud Polling",
"homeassistant": "0.118.0"
"homeassistant": "2021.12.0",
"hide_default_branch": true,
"zip_release": true,
"filename": "flichub.zip"
}
25 changes: 25 additions & 0 deletions manage/update_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Update the manifest file."""
import sys
import json
import os


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/flichub/manifest.json") as manifestfile:
manifest = json.load(manifestfile)

manifest["version"] = version

with open(
f"{os.getcwd()}/custom_components/flichub/manifest.json", "w"
) as manifestfile:
manifestfile.write(json.dumps(manifest, indent=4, sort_keys=True))


update_manifest()

0 comments on commit f3b8882

Please sign in to comment.