Skip to content

Commit

Permalink
Add workflows for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
wbyoung committed Jun 22, 2024
1 parent 8ced4b9 commit 72e167a
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name-template: "v$RESOLVED_VERSION 🏳️‍🌈"
tag-template: "v$RESOLVED_VERSION"
change-template: "- #$NUMBER $TITLE @$AUTHOR"
sort-direction: "ascending"
categories:
- title: "⚠️ Breaking changes"
label: "breaking change"
- title: "💡 Features"
label: ":bulb: feature"
- title: "✨ Code enhancements"
label: ":sparkles: enhancement"
- title: "💡 New Custom Cards"
label: ":bulb: custom feature"
- title: "✨ Custom Card enhancements"
label: ":sparkles: custom enhancement"
- title: "🐛 Bug Fixes"
label: ":bug: bug"
- title: "💬 Translations"
label: ":speech_balloon: translation"
- title: "📝 Documentation"
label: ":memo: documentation"
version-resolver:
major:
labels:
- "major"
minor:
labels:
- "minor"
patch:
labels:
- "patch"
default: "patch"
template: |
## Changes
$CHANGES
## Contributors
$CONTRIBUTORS
exclude-contributors:
- "github-actions"

autolabeler:
- label: ":bug: bug"
branch:
- "/fix/.+/"
- label: ":bulb: feature"
branch:
- "/feature/.+/"
28 changes: 28 additions & 0 deletions .github/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/watersmart/manifest.json"
) as manifestfile:
manifest = json.load(manifestfile)

manifest["version"] = version

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


update_manifest()
15 changes: 15 additions & 0 deletions .github/workflows/release-drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Draft a release note"

on:
push:
branches: ["main", "release"]

jobs:
draft_release:
name: "Release Drafter"
runs-on: "ubuntu-latest"
steps:
- name: "Run release-drafter"
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:
update_hacs_manifest:
name: "Prepare release asset"
runs-on: "ubuntu-latest"
steps:
- name: "Check out repository"
uses: "actions/checkout@v3"

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

- name: "Set manifest version number"
run: |
python3 ${{ github.workspace }}/.github/update_hacs_manifest.py --version ${{ steps.version.outputs.version }}
- name: "Create zip"
run: |
cd custom_components/watersmart
zip watersmart.zip -r ./
- name: "Upload zip to release"
uses: "svenstaro/upload-release-action@v1-release"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
file: "./custom_components/watersmart/watersmart.zip"
asset_name: "watersmart.zip"
tag: "${{ github.ref }}"
overwrite: true

0 comments on commit 72e167a

Please sign in to comment.