diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..63a66eb --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,25 @@ +name-template: "v$RESOLVED_VERSION 🌈" +tag-template: "v$RESOLVED_VERSION" +sort-direction: ascending +categories: + - title: "⚠ Breaking changes" + label: "breaking change" + - title: "🚀 Features" + labels: + - "feature" + - title: "🔧 Code enhancements" + labels: + - "enhancement" + - title: "🐛 Bug Fixes" + labels: + - "fix" + - "bugfix" + - "bug" + - title: "🈵 Translations" + label: "translation" + - title: "📄 Documentation" + label: "documentation" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +template: | + $CHANGES diff --git a/.github/scripts/update_manifest.py b/.github/scripts/update_manifest.py new file mode 100644 index 0000000..e545377 --- /dev/null +++ b/.github/scripts/update_manifest.py @@ -0,0 +1,41 @@ +"""Update the manifest file.""" + +# pylint: skip-file + +import json +import os +import sys + + +def update_manifest(): + """Update the manifest file.""" + version = "v0.0.0" + for index, value in enumerate(sys.argv): + if value in ["--version", "-V"]: + version = sys.argv[index + 1] + + version_striped = version.replace("v", "") + + print("Version number being inserted: " + str(version_striped)) + + print("Opening file...") + + with open(f"{os.getcwd()}/custom_components/amc_alarm/manifest.json") as manifestfile: + manifest = json.load(manifestfile) + + manifest["version"] = version_striped + + print("Manifest file after inserting new version number:") + print(manifest) + + print("Saving file...") + + with open( + f"{os.getcwd()}/custom_components/amc_alarm/manifest.json", "w" + ) as manifestfile: + manifestfile.write(json.dumps(manifest, indent=4, sort_keys=True)) + + print("Done!") + + +update_manifest() diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..de5ac1c --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,16 @@ +name: Draft a release note + +on: + push: + branches: + - master + +jobs: + draft_release: + name: Release Drafter + runs-on: ubuntu-latest + steps: + - name: Run release-drafter + uses: release-drafter/release-drafter@v5.15.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-manifest.yml b/.github/workflows/update-manifest.yml new file mode 100644 index 0000000..0197311 --- /dev/null +++ b/.github/workflows/update-manifest.yml @@ -0,0 +1,33 @@ +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 }}/.github/scripts/update_manifest.py --version ${{ steps.version.outputs.version }} + - name: Create zip + run: | + cd custom_components/amc_alarm + zip amc_alarm.zip -r ./ + - name: Upload zip to release + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./custom_components/amc_alarm/amc_alarm.zip + asset_name: amc_alarm.zip + tag: ${{ github.ref }} + overwrite: true diff --git a/hacs.json b/hacs.json index efb0f49..c6fb193 100644 --- a/hacs.json +++ b/hacs.json @@ -1,4 +1,6 @@ { "name": "AMC Alarm", - "render_readme": true + "render_readme": true, + "zip_release": true, + "filename": "amc_alarm.zip" }