Skip to content

Commit

Permalink
test github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
despokd committed Sep 15, 2024
1 parent f6ff9da commit a8cfa04
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

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

jobs:
black:
name: Python Code Format Check
runs-on: ubuntu-latest
steps:
- name: Check out code from GitHub
uses: "actions/checkout@main"
- name: Black Code Format Check
uses: lgeiger/black-action@master
with:
args: ". --check --fast --diff"

validate:
name: Check hassfest
runs-on: "ubuntu-latest"
steps:
- name: Check out code from GitHub
uses: "actions/checkout@main"
- name: Run hassfest
uses: home-assistant/actions/hassfest@master
18 changes: 18 additions & 0 deletions .github/workflows/hacs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: HACS Validate

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

jobs:
hacs:
name: HACS Action
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: "Auto Release"

on:
push:
branches:
- 'main'
- 'master'
paths:
- 'custom_components/*/manifest.json'

jobs:
auto-release:
name: "Auto Release"
runs-on: "ubuntu-latest"
steps:
- name: "✏️ Checkout code"
uses: actions/checkout@v4
with:
path: './'

- name: "🏷️ Get version tag"
id: set_var
run: echo "COMPONENT_VERSION=$(jq -r .version custom_components/*/manifest.json)" >> $GITHUB_ENV

- name: "🏷️ Check if tag exists already"
uses: mukunku/tag-exists-action@v1.6.0
id: "check_tag"
with:
tag: "v${{ env.COMPONENT_VERSION }}"

- name: "❌ Cancel if tag is already present"
run: |
echo "Tag already present: v${{ env.COMPONENT_VERSION }}. Not creating a new release"
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.check_tag.outputs.exists == 'true'

- name: "🗝️ Get previous release version"
id: last_release
uses: InsonusK/get-latest-release@v1.1.0
with:
myToken: ${{ github.token }}
exclude_types: "draft|prerelease"

- name: "🏷️ Create new tag"
uses: rickstaa/action-create-tag@v1
id: "tag_create"
with:
tag: "v${{ env.COMPONENT_VERSION }}"
tag_exists_error: false
message: "Version ${{ env.COMPONENT_VERSION }}"
# if: steps.check_tag.outputs.exists == 'false'

- name: "🗒️ Generate release changelog"
id: changelog
uses: heinrichreimer/github-changelog-generator-action@v2.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
sinceTag: ${{ steps.last_release.outputs.tag_name }}
headerLabel: "# Notable changes since ${{ steps.last_release.outputs.tag_name }}"
stripGeneratorNotice: true

- name: 👍 Create Stable release
uses: softprops/action-gh-release@v2
with:
prerelease: false
body: "${{ steps.changelog.outputs.changelog }}"
name: "Version ${{ env.COMPONENT_VERSION }}"
tag_name: "v${{ env.COMPONENT_VERSION }}"
if: contains(env.COMPONENT_VERSION, 'beta') == false

- name: 🤞 Create Beta release
uses: softprops/action-gh-release@v2
with:
prerelease: true
body: "${{ steps.changelog.outputs.changelog }}"
name: "Version ${{ env.COMPONENT_VERSION }}"
tag_name: "v${{ env.COMPONENT_VERSION }}"
if: contains(env.COMPONENT_VERSION, 'beta') == true
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ Custom component for Home Assistant that integrates todo lists of Zenkit
- [ ] implement state change
- [ ] make due date editable
- [ ] check why new ToDos are not instantly shown in HA

## Releases

- auto released by workflow
- managed by `COMPONENT_VERSION` variable at GitHub Actions

0 comments on commit a8cfa04

Please sign in to comment.