Skip to content

Commit

Permalink
feat(ha): init ha addons
Browse files Browse the repository at this point in the history
  • Loading branch information
atbore-phx committed Mar 8, 2024
1 parent 13c62cb commit 54b790a
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 16 deletions.
26 changes: 19 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
permissions:
contents: write
packages: write
id-token: write

jobs:
goreleaser:
Expand All @@ -19,17 +20,28 @@ jobs:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: copy binary to local ha folder
run: |
mkdir home-assistant/addons/sbam/bin/
cp -v dist/sbam_linux_amd64_v1/bin/sbam home-assistant/addons/sbam/bin/
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish build - Home Assistant builder
uses: home-assistant/builder@master
with:
args: |
--amd64 \
--target /data/home-assistant/addons/sbam
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*.so
*.dylib
bin/

home-assistant/addons/sbam/bin/
# Test binary, built with `go test -c`
*.test

Expand Down
7 changes: 3 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ before:
hooks:
- go mod tidy

release:
prerelease: true

builds:
- id: "sbam"
binary: bin/sbam
env:
- CGO_ENABLED=0
dockers:
- image_templates:
- "ghcr.io/atbore-phx/{{ .ProjectName }}-amd64:{{ .Version }}"
- "ghcr.io/atbore-phx/{{ .ProjectName }}-amd64:latest"

changelog:
sort: asc
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile

This file was deleted.

3 changes: 3 additions & 0 deletions home-assistant/addons/sbam/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ FROM $BUILD_FROM
COPY run.sh /
RUN chmod a+x /run.sh

COPY bin/sbam /usr/bin/
RUN chmod a+x /usr/bin/sbam

CMD [ "/run.sh" ]
4 changes: 4 additions & 0 deletions home-assistant/addons/sbam/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build_from:
amd64: "homeassistant/amd64-base-debian:buster"
squash: false,
args: {}
Empty file modified home-assistant/addons/sbam/run.sh
100644 → 100755
Empty file.
24 changes: 24 additions & 0 deletions home-assistant/addons/test_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

BUILDCONTAINER_DATA_PATH="/data"
PATHTOBUILD="$BUILDCONTAINER_DATA_PATH"
ARCH=amd64


PROJECTDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/sbam
ROOTDIR=$PROJECTDIR/../../../
cd $PRROOTDIROJECTDIR/../../../
make build
cd -


rm -rf $PROJECTDIR/bin
mkdir -p $PROJECTDIR/bin
cp $ROOTDIR/bin/sbam $PROJECTDIR/bin/

echo "project directory is $PROJECTDIR"
echo "build container data path is $BUILDCONTAINER_DATA_PATH"
echo "build container target build path is $PATHTOBUILD"
CMD="docker run --rm -ti --name hassio-builder --privileged -v $PROJECTDIR:$BUILDCONTAINER_DATA_PATH -v /var/run/docker.sock:/var/run/docker.sock:ro homeassistant/amd64-builder --target $PATHTOBUILD --$ARCH --test --docker-hub local"
echo "$CMD"
$CMD
3 changes: 3 additions & 0 deletions repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: "sbam Smart Battery Manager",
url: "https://github.com/atbore-phx/sbam",
maintainer": "atbore-phx"

0 comments on commit 54b790a

Please sign in to comment.