Skip to content

Commit

Permalink
chore: add release-drafter and try releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
vermut committed May 4, 2024
1 parent f381344 commit e16c408
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions .github/scripts/update_manifest.py
Original file line number Diff line number Diff line change
@@ -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()
16 changes: 16 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/update-manifest.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"name": "AMC Alarm",
"render_readme": true
"render_readme": true,
"zip_release": true,
"filename": "amc_alarm.zip"
}

0 comments on commit e16c408

Please sign in to comment.