diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..f8a1bf9 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,22 @@ +--- +name: Perform a release + +on: [workflow_dispatch] # yamllint disable-line rule:truthy +jobs: + build-images: + runs-on: ubuntu-latest + steps: + - id: version + name: Get version string + run: echo "::set-output name=VERSION::v$(date +'+%Y.%m.%d').${{ github.run_number }}" + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.VERSION }} + release_name: Release ${{ github.ref }} + draft: true + prerelease: true diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..e2e49cd --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,19 @@ +--- +name: Test image build + +on: [push] # yamllint disable-line rule:truthy +jobs: + build-images: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: "Build images" + run: | + docker buildx bake ci diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..30a9a88 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "infinitude-src"] + path = infinitude-src + url = https://github.com/nebulous/infinitude diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9933685..cb4e05c 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,19 +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": [] - } - ] - } + "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": [] + } + ] +} diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..0d6152d --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,8 @@ +--- +extends: default + +rules: + line-length: disable + +ignore: + - infinitude-src/ diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..f7c66e3 --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,38 @@ +variable "VERSION" { +} + +target "ci" { + pull = true + + platforms = ["linux/amd64", "linux/arm64"] + + context = "docker" +} + +target "infinitude" { + pull = true + + platforms = ["linux/amd64", "linux/arm64"] + + context = "infinitude-src" + + tags = [ + "docker.io/sosheskaz/infinitude:${VERSION}", + ] + +} + +target "release" { + pull = true + + platforms = ["linux/amd64", "linux/arm64"] + + context { + dockerfile = "Dockerfile" + } + + tags = [ + "docker.io/sosheskaz/ha-infinitude:${VERSION}", + // "docker.io/sosheskaz/ha-infinitude:latest" + ] +} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..15a2958 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,13 @@ +FROM docker.io/nebulous/infinitude:latest + +RUN apt-get update && apt-get install -y \ + bash \ + jq \ + tini \ + && rm -rf /var/lib/apt/lists/* + +COPY run.sh / + +MAINTAINER "Eric Miller (sosheskaz)" + +ENTRYPOINT ["tini", "--", "/run.sh"] diff --git a/docker/run.sh b/docker/run.sh new file mode 100755 index 0000000..bac793c --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +set -e + +CONFIG_PATH=/data/options.json + +cfg() { + jq -r --arg key "$1" '.[$key]' < "${CONFIG_PATH}" +} + +MODE="$(cfg 'mode')" + +if [[ "${MODE}" = "Development" ]] +then + set -x +fi + +APP_SECRET="$(cfg 'app_secret')" +PASS_REQS="$(cfg 'pass_reqs')" +SERIAL_TTY="$(cfg 'serial_tty')" +SERIAL_SOCKET="$(cfg 'serial_socket')" + +CFG="$(jq -s \ + --arg APP_SECRET "${APP_SECRET}" \ + --argjson PASS_REQS "${PASS_REQS}" \ + '{"app_secret":$APP_SECRET,"pass_reqs":$PASS_REQS}' \ + < /dev/null)" + +if [[ -n "${SERIAL_TTY}" ]] +then + CFG="$(jq \ + --arg SERIAL_TTY "${SERIAL_TTY}" \ + '. + {"serial_tty":$SERIAL_TTY}' \ + <<< "${CFG}")" +fi + +if [[ -n "${SERIAL_SOCKET}" ]] +then + CFG="$(jq \ + --arg SERIAL_SOCKET "${SERIAL_SOCKET}" \ + '. + {"serial_tty":$SERIAL_SOCKET}' \ + <<< "${CFG}")" +fi + +echo "${CFG}" > /infinitude/infinitude.json + +rm -rf /infinitude/state +mkdir -p /data/infinitude/state +ln -sfT /data/infinitude/state /infinitude/state + +cd /infinitude +exec ./infinitude daemon -m "${MODE}" "$@" diff --git a/infinitude-src b/infinitude-src new file mode 160000 index 0000000..690f68e --- /dev/null +++ b/infinitude-src @@ -0,0 +1 @@ +Subproject commit 690f68e3f873163daa196887a3d194422d7d2508