diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..5ae4a3e --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,41 @@ +{ + "name": "hacs/addons", + "image": "ghcr.io/home-assistant/devcontainer:addons", + "appPort": [ + "7123:8123", + "7357:4357" + ], + "postStartCommand": "bash devcontainer_bootstrap", + "runArgs": [ + "-e", + "GIT_EDITOR=code --wait", + "--privileged" + ], + "remoteUser": "root", + "containerEnv": { + "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" + }, + "customizations": { + "vscode": { + "extensions": [ + "timonwong.shellcheck", + "esbenp.prettier-vscode" + ], + "mounts": [ + "type=volume,target=/var/lib/docker" + ], + "settings": { + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/usr/bin/zsh" + } + }, + "terminal.integrated.defaultProfile.linux": "zsh", + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true + } + } + } +} \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ca2acff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: HACS Issue tracker + url: https://github.com/hacs/integration/issues + about: For issues and feature requests related to HACS diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml new file mode 100644 index 0000000..e69811d --- /dev/null +++ b/.github/workflows/builder.yaml @@ -0,0 +1,117 @@ +name: Builder + +env: + BUILD_ARGS: "--test" + MONITORED_FILES: "build.yaml config.yaml Dockerfile rootfs" + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + init: + runs-on: ubuntu-latest + name: Initialize builds + outputs: + changed_addons: ${{ steps.changed_addons.outputs.addons }} + changed: ${{ steps.changed_addons.outputs.changed }} + steps: + - name: Check out the repository + uses: actions/checkout@v4.1.7 + + - name: Get changed files + id: changed_files + uses: jitterbit/get-changed-files@v1 + + - name: Find add-on directories + id: addons + uses: home-assistant/actions/helpers/find-addons@master + + - name: Get changed add-ons + id: changed_addons + run: | + declare -a changed_addons + for addon in ${{ steps.addons.outputs.addons }}; do + if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon ]]; then + for file in ${{ env.MONITORED_FILES }}; do + if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon/$file ]]; then + if [[ ! "${changed_addons[@]}" =~ $addon ]]; then + changed_addons+=("\"${addon}\","); + fi + fi + done + fi + done + + changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev) + + if [[ -n ${changed} ]]; then + echo "Changed add-ons: $changed"; + echo "changed=true" >> $GITHUB_OUTPUT; + echo "addons=[$changed]" >> $GITHUB_OUTPUT; + else + echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})"; + fi + build: + needs: init + runs-on: ubuntu-latest + if: needs.init.outputs.changed == 'true' + name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on + strategy: + matrix: + addon: ${{ fromJson(needs.init.outputs.changed_addons) }} + arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] + permissions: + contents: read + packages: write + + steps: + - name: Check out repository + uses: actions/checkout@v4.1.7 + + - name: Get information + id: info + uses: home-assistant/actions/helpers/info@master + with: + path: "./${{ matrix.addon }}" + + - name: Check if add-on should be built + id: check + run: | + if [[ "${{ steps.info.outputs.image }}" == "null" ]]; then + echo "Image property is not defined, skipping build" + echo "build_arch=false" >> $GITHUB_OUTPUT; + elif [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then + echo "build_arch=true" >> $GITHUB_OUTPUT; + echo "image=$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)" >> $GITHUB_OUTPUT; + if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then + echo "BUILD_ARGS=" >> $GITHUB_ENV; + fi + else + echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"; + echo "build_arch=false" >> $GITHUB_OUTPUT; + fi + + - name: Login to GitHub Container Registry + if: env.BUILD_ARGS != '--test' + uses: docker/login-action@v3.2.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build ${{ matrix.addon }} add-on + if: steps.check.outputs.build_arch == 'true' + uses: home-assistant/builder@2024.03.5 + with: + args: | + ${{ env.BUILD_ARGS }} \ + --${{ matrix.arch }} \ + --target /data/${{ matrix.addon }} \ + --image "${{ steps.check.outputs.image }}" \ + --docker-hub "ghcr.io/${{ github.repository_owner }}" \ + --addon diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..da75f2e --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,41 @@ +name: Lint + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: {} + +jobs: + find: + name: Find add-ons + runs-on: ubuntu-latest + outputs: + addons: ${{ steps.addons.outputs.addons_list }} + steps: + - name: Check out code from GitHub + uses: actions/checkout@v4.1.6 + + - name: Find add-on directories + id: addons + uses: home-assistant/actions/helpers/find-addons@master + + lint: + name: Lint add-on ${{ matrix.path }} + runs-on: ubuntu-latest + needs: find + strategy: + matrix: + path: ${{ fromJson(needs.find.outputs.addons) }} + steps: + - name: Check out code from GitHub + uses: actions/checkout@v4.1.6 + + - name: Run Home Assistant Add-on Lint + uses: frenck/action-addon-linter@v2.15.1 + with: + path: "./${{ matrix.path }}" diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..f8f5fc2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,19 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Start Home Assistant", + "type": "shell", + "command": "supervisor_run", + "group": { + "kind": "test", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..46bcfc9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,20 @@ +Copyright (c) 2024 HACS. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 6512774..85d9ed3 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# addons \ No newline at end of file +# HACS Add-ons Repository + +This repository contains the source code for the HACS add-ons. diff --git a/repository.yaml b/repository.yaml new file mode 100644 index 0000000..39c30e0 --- /dev/null +++ b/repository.yaml @@ -0,0 +1,3 @@ +name: HACS Add-ons Repository +url: 'https://github.com/hacs/addons' +maintainer: HACS \ No newline at end of file