Skip to content

Commit

Permalink
👷 Add actions
Browse files Browse the repository at this point in the history
  • Loading branch information
anarion80 committed Mar 8, 2024
1 parent a93724f commit 967d5ca
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
change-template: '- #$NUMBER $TITLE @$AUTHOR'
sort-direction: ascending
exclude-contributors:
- 'github-actions[bot]'
- 'github-actions'
- 'renovate[bot]'
- 'renovate'
exclude-labels:
- 'skip-changelog'
- 'dependencies'
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: |
## Changes
$CHANGES
$CONTRIBUTORS
autolabeler:
- label: 'bug'
branch:
- '/fix\/.+/'
- label: 'enhancement'
branch:
- '/feature\/.+/'
- '/feat\/.+/'
28 changes: 28 additions & 0 deletions .github/scripts/update_hacs_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Update the manifest file."""
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/tech/manifest.json",
) as manifestfile:
manifest = json.load(manifestfile)

manifest["version"] = version

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


update_manifest()
27 changes: 27 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release Drafter

on:
push:
branches:
- main
pull_request:
types: [opened, reopened, synchronize]

jobs:
update_release_draft:
name: Update release draft
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Release
uses: release-drafter/release-drafter@v6
with:
disable-releaser: github.ref != 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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@v4
- name: "Set manifest version number"
run: |
python3 ${{ github.workspace }}/.github/scripts/update_hacs_manifest.py --version ${{ github.ref_name }}
- name: Create zip
run: |
cd custom_components/tech
zip tech.zip -r ./
- name: Upload zip to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./custom_components/tech/tech.zip
asset_name: tech.zip
tag: ${{ github.ref }}
overwrite: true
23 changes: 23 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Validate

on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
validate-hassfest:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: home-assistant/actions/hassfest@master
validate-hacs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"

0 comments on commit 967d5ca

Please sign in to comment.