Fix for HA 2024.12+ #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
validate: | |
runs-on: "ubuntu-latest" | |
name: Validate | |
outputs: | |
PACKAGE_VERSION: ${{ steps.version-number.outputs.PACKAGE_VERSION }} | |
steps: | |
- name: 📥 Check out code from GitHub | |
uses: "actions/checkout@v3" | |
- name: 🛠️ Setup Python | |
uses: "actions/setup-python@v4" | |
with: | |
python-version: "3.x" | |
- name: ⚒️ HACS validation | |
uses: "hacs/action@main" | |
with: | |
category: "integration" | |
ignore: brands | |
- name: 🏠 Hassfest validation | |
uses: "home-assistant/actions/hassfest@master" | |
- name: 🔍 Get Commit Date | |
uses: actions/[email protected] | |
id: author-date | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const commit_details = await github.git.getCommit({owner: context.repo.owner, repo: context.repo.repo, commit_sha: context.sha}); | |
return commit_details.data.author.date | |
- name: 🔍 Find Version Number | |
id: version-number | |
run: | | |
echo "VERSION_NUMBER=$(date -d ${{ steps.author-date.outputs.result }} +%Y.%m.%d.%H%M)" >> $GITHUB_ENV | |
PACKAGE_VERSION=$(cat "$PACKAGE_PROJECT" | grep -oPm1 "(?<=<PackageVersion>)[^<]+") | |
echo "PACKAGE_VERSION=$PACKAGE_VERSION.${{ github.run_number }}" >> $GITHUB_ENV | |
echo "::set-output name=PACKAGE_VERSION::$PACKAGE_VERSION.${{ github.run_number }}" | |
style: | |
runs-on: "ubuntu-latest" | |
name: Check style formatting | |
steps: | |
- name: 📥 Check out code from GitHub | |
uses: "actions/checkout@v3" | |
- name: 🛠️ Setup Python | |
uses: "actions/setup-python@v4" | |
with: | |
python-version: "3.x" | |
- name: 🛠️ Setup Python Requirements | |
run: python3 -m pip install black | |
- name: 🔍 Check style | |
run: black . | |
tests: | |
runs-on: "ubuntu-latest" | |
name: Run tests | |
steps: | |
- name: 📥 Check out code from GitHub | |
uses: "actions/checkout@v3" | |
- name: 🛠️ Setup Python | |
uses: "actions/setup-python@v4" | |
with: | |
python-version: "3.x" | |
# - name: Install requirements | |
# run: python3 -m pip install -r requirements_test.txt | |
# - name: Run tests | |
# run: | | |
# pytest \ | |
# -qq \ | |
# --timeout=9 \ | |
# --durations=10 \ | |
# -n auto \ | |
# --cov custom_components.torque_logger \ | |
# -o console_output_style=count \ | |
# -p no:sugar \ | |
# tests | |
deploy: | |
name: "release" | |
runs-on: "ubuntu-latest" | |
needs: | |
- validate | |
- style | |
- tests | |
# only create a release if pushed to main already | |
if: ${{ github.ref == 'refs/heads/main' && !contains(github.event.push.commits.*.message, 'readme') }} | |
environment: | |
name: hacs | |
steps: | |
- name: 📥 Checkout the repository | |
uses: actions/[email protected] | |
- name: 🛠️ Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
cache: 'pip' | |
- name: ⚙️ Set version number | |
uses: maxgfr/actions-change-json@main | |
with: | |
key: 'version' | |
value: '${{ needs.validate.outputs.PACKAGE_VERSION }}' | |
path: custom_components/torque_logger/manifest.json | |
- name: 📦 Zip | |
run: | | |
cd ${{ github.workspace }}/custom_components/torque_logger | |
zip torque_logger.zip -r ./ | |
- name: 🚀 Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: "v${{ needs.validate.outputs.PACKAGE_VERSION }}" | |
draft: false | |
prerelease: false | |
body: | | |
Changes in this Release | |
${{ github.event.head_commit.message }} | |
files: ${{ github.workspace }}/custom_components/torque_logger/torque_logger.zip |