Update, refactor and restructure repo (#1)

* Remove unused files

* Update dev env

* Update config

* Update docker config

* Add translations

* Update run script

* Auto-gen enc key if not set

* Replace workflows

* Replace dependabot with renovate

* Remove armhf

* Lint

* Remove armhf

* Whoops

* Remove stray comma

* Add image

* Reorder options

* Split and improve docs

* Add back image line

* Update cw

* Typo

* Use correct org

* Move bootstrap to run

* Update scripts

* Update config

* Add note about database

* Label in dockerfile

* tmp force devcontainer version

* Start implementing db creation if not exists

* Create DB if doesn't exist

* Update words

* Remove unused file
This commit is contained in:
Colin Seymour
2024-05-26 10:28:12 +01:00
committed by GitHub
parent 5f849a6fbc
commit ae479687f4
27 changed files with 674 additions and 623 deletions
-20
View File
@@ -1,20 +0,0 @@
---
name: "Bug report \U0001F41B"
about: Report errors or unexpected behaviour
title: 'Bug Report'
labels: bug
assignees: 'matt-FFFFFF'
---
<!-- Please search existing issues to avoid creating duplicates. -->
**Describe the bug**
**Steps to reproduce**
1.
2.
**Screenshots**
-12
View File
@@ -1,12 +0,0 @@
---
name: "Feature request \U0001F680"
about: Suggest an idea for this project
title: 'Feature Request'
labels: enhancement
assignees: 'matt-FFFFFF'
---
<!-- Please search existing issues to avoid creating duplicates. -->
**Describe the solution you'd like**
-8
View File
@@ -1,8 +0,0 @@
---
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
+27
View File
@@ -0,0 +1,27 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
":disableDependencyDashboard"
],
"prHourlyLimit": 4,
"prBodyTemplate": "{{{table}}}{{{warnings}}}{{{notes}}}{{{changelogs}}}",
"semanticCommits": "disabled",
"commitMessageTopic": "{{#if (containsString depName 'teslamate')}}TeslaMate{{else}}{{depName}}{{/if}}",
"customManagers": [
{
"customType": "regex",
"fileMatch": "^build\\.json$",
"matchStrings": [
"\"teslamate_version\": \"(?<currentValue>\\d+\\.\\d+\\.\\d+)\""
],
"datasourceTemplate": "github-releases",
"depNameTemplate": "teslamate-org/teslamate"
}
],
"prBodyColumns": [
"Package",
"Update",
"Change"
]
}
+32
View File
@@ -0,0 +1,32 @@
name: Lint
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
name: Lint add-on
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4.1.4
- name: 🚀 Run Home Assistant Add-on Lint
uses: frenck/action-addon-linter@v2
with:
path: "./"
- name: Check versions match
run: |
docker_ver=$(grep "FROM teslamate/teslamate" Dockerfile | cut -d':' -f2)
build_ver=$(jq -r ".args.teslamate_version" build.json)
if [ "$docker_ver" != "$build_ver" ]; then
echo -e "\033[31;1mTeslaMate versions don't match: Dockerfile => ${docker_ver} | build.json => ${build_ver}\033[0m"
exit 1
fi
echo -e "\033[32;1mTeslaMate versions match: Dockerfile => ${docker_ver} | build.json => ${build_ver}\033[0m"
+51
View File
@@ -0,0 +1,51 @@
name: "Publish"
on:
release:
types: [published]
workflow_dispatch:
workflow_call:
inputs:
version:
required: false
type: string
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
arch: ["amd64", "armv7", "aarch64"]
steps:
- name: Checkout the repository
uses: actions/checkout@v4.1.4
- name: Get version
run: |
version=${{ inputs.version }}
if [ -n "$version" ]; then
echo "latest_release=$version" >> $GITHUB_ENV
else
echo "latest_release=$(curl --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --silent https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r .tag_name | sed s/v// )" >> $GITHUB_ENV
fi
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish
uses: home-assistant/builder@master
with:
args: |
--${{ matrix.arch }} \
--version ${{ env.latest_release }} \
--target /data/ \
--addon
@@ -6,20 +6,26 @@ on:
required: true
default: i
name: Create release
name: Releaser
jobs:
build:
name: create_release
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.semver.outputs.semver }}
permissions:
contents: write
packages: write
steps:
- name: Checkout Teslamate
- name: Checkout repository
uses: actions/checkout@v4
with:
path: teslamate
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get latest release
run: |
echo "latest_release=$(curl --silent https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r .tag_name | sed s/v// )" >> $GITHUB_ENV
echo "latest_release=$(curl --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --silent https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r .tag_name | sed s/v// )" >> $GITHUB_ENV
- name: Increment semver
id: semver
uses: matt-FFFFFF/simple-semver@v0.1.1
@@ -33,34 +39,42 @@ jobs:
git tag -a v${{ steps.semver.outputs.semver }} -m 'Release automation'
git push --tags
working-directory: ${{ github.workspace }}/teslamate
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.REPO_PAT }}
- name: Create release
uses: softprops/action-gh-release@v2.0.4
with:
tag_name: v${{ steps.semver.outputs.semver }}
release_name: Release v${{ steps.semver.outputs.semver }}
body_path: ${{ github.workspace }}/teslamate/CHANGELOG.md
generate_release_notes: true
draft: false
prerelease: false
- name: Checkout repository
uses: actions/checkout@v4
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout addon repo
uses: actions/checkout@v4.1.4
with:
path: repo
repository: matt-FFFFFF/hassio-addon-repository
token: ${{ secrets.REPO_PAT }}
repository: lildude/ha-addons
token: ${{ secrets.HA_ADDONS_PAT }}
- name: Update addon repo
run: |
cp -vf ${{ github.workspace }}/teslamate/*.png ${{ github.workspace }}/repo/teslamate
cp -vf ${{ github.workspace }}/teslamate/*.png ${{ github.workspace }}/repo/teslamate
cp -vf ${{ github.workspace }}/teslamate/*.md ${{ github.workspace }}/repo/teslamate
jq '.version="${{ steps.semver.outputs.semver }}"' < ${{ github.workspace }}/teslamate/config.json > ${{ github.workspace }}/repo/teslamate/config.json
echo "$(curl --silent --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r .body)" > ${{ github.workspace }}/repo/teslamate/CHANGELOG.md
- name: Add changes to addon repo
run: |
if [ "$(git status -s)" ]; then
git add .
git commit -m 'Update from hassio-addon-teslamate'
git commit -m 'Update ha-addon-teslamate to v${{ steps.semver.outputs.semver }}'
git push
fi
working-directory: ${{ github.workspace }}/repo/teslamate
build:
name: Build addon
needs: release
permissions:
contents: read
packages: write
uses: ./.github/workflows/publisher.yaml
with:
version: ${{ needs.release.outputs.version }}
-117
View File
@@ -1,117 +0,0 @@
name: Teslamate CI/CD
on:
push:
branches:
- main
paths:
- '**'
- '!**.md'
- '!.github/**'
release:
types: [published]
pull_request:
paths:
- '**'
- '!**.md'
env:
DOCKER_USERNAME: mattffffff
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, armhf, armv7, aarch64]
fail-fast: true
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set TESLAMATE_TAG
run: |
echo "TESLAMATE_TAG=$(jq -r '.args.TESLAMATE_TAG ' < build.json)" >> $GITHUB_ENV
- name: Docker version
run: docker version
- name: Setup qemu
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Install buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Set PLATFORM & ARCH variables
run: |
case "${{ matrix.arch }}" in
"amd64" )
echo "PLATFORM=linux/amd64" >> $GITHUB_ENV
echo "ARCH=amd64" >> $GITHUB_ENV
;;
"aarch64" )
echo "PLATFORM=linux/arm64" >> $GITHUB_ENV
echo "ARCH=aarch64" >> $GITHUB_ENV
;;
"armhf" )
echo "PLATFORM=linux/arm/v7" >> $GITHUB_ENV
echo "ARCH=armhf" >> $GITHUB_ENV
;;
"armv7" )
echo "PLATFORM=linux/arm/v7" >> $GITHUB_ENV
echo "ARCH=arm" >> $GITHUB_ENV
;;
esac
- name: Update config.json if release
run: |
export RELEASE=$( echo $GITHUB_REF | cut -d/ -f3 | sed s/v// )
jq ".version=\"$RELEASE\"" < config.json > config_release.json
rm config.json && mv config_release.json config.json
if: ${{ github.event_name == 'release' }}
- name: Set environment variables from config.json
run: |
echo "ADDON_VERSION=$(jq -r .version < config.json)" >> $GITHUB_ENV
echo "ADDON_NAME=$(jq -r .name < config.json)" >> $GITHUB_ENV
echo "ADDON_DESCRIPTION=$(jq -r .description < config.json)" >> $GITHUB_ENV
- name: Login to docker hub
run: sudo docker login -u $DOCKER_USERNAME -p ${{ secrets.DOCKER_PASSWORD }}
- name: Buildx build (if not main)
run: |
DOCKER_CLI_EXPERIMENTAL=enabled sudo docker buildx build \
--pull \
--platform=$PLATFORM \
--build-arg TESLAMATE_TAG=$TESLAMATE_TAG \
--build-arg ARCH=$ARCH \
--label io.hass.type="addon" \
--label io.hass.name="$ADDON_NAME" \
--label io.hass.description="$ADDON_DESCRIPTION" \
--label io.hass.version="$ADDON_VERSION" \
--label io.hass.arch="${{ matrix.arch }}" \
--label io.hass.url="https://github.com/matt-FFFFFF/hassio-addon-repository/blob/main/teslamate/README.md" \
-t $DOCKER_USERNAME/teslamate-${{ matrix.arch }}:$ADDON_VERSION \
./
if: ${{ github.ref != 'refs/heads/main' }}
- name: Buildx build --push (if main or release)
run: |
DOCKER_CLI_EXPERIMENTAL=enabled sudo docker buildx build \
--pull \
--push \
--platform=$PLATFORM \
--build-arg TESLAMATE_TAG=$TESLAMATE_TAG \
--build-arg ARCH=$ARCH \
--label io.hass.type="addon" \
--label io.hass.name="$ADDON_NAME" \
--label io.hass.description="$ADDON_DESCRIPTION" \
--label io.hass.version="$ADDON_VERSION" \
--label io.hass.arch="${{ matrix.arch }}" \
--label io.hass.url="https://github.com/matt-FFFFFF/hassio-addon-repository/blob/main/teslamate/README.md" \
-t $DOCKER_USERNAME/teslamate-${{ matrix.arch }}:$ADDON_VERSION \
./
if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
+44
View File
@@ -0,0 +1,44 @@
name: Test
on:
push:
branches:
- main
paths:
- build.yaml
- config.yaml
- build.json
- config.json
- Dockerfile
- rootfs/**
pull_request:
branches:
- main
paths:
- build.yaml
- config.yaml
- build.json
- config.json
- Dockerfile
- rootfs/**
jobs:
build:
runs-on: ubuntu-latest
name: Build add-on
strategy:
matrix:
arch: ["amd64", "armv7", "aarch64"]
steps:
- name: Check out repository
uses: actions/checkout@v4.1.4
- name: Build add-on
uses: home-assistant/builder@master
with:
args: |
--test \
--${{ matrix.arch }} \
--target /data/ \
--addon