diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..3a549a2 --- /dev/null +++ b/.github/release-drafter.yml @@ -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/.+/" \ No newline at end of file diff --git a/.github/update_hacs_manifest.py b/.github/update_hacs_manifest.py new file mode 100644 index 0000000..4520d47 --- /dev/null +++ b/.github/update_hacs_manifest.py @@ -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() diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 0000000..1b1523e --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -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 }}" \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..7e2161a --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 \ No newline at end of file