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 c9d365b
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 17 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ on:
permissions:
contents: write
packages: write
id-token: write

jobs:
goreleaser:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
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/[email protected]
with:
args: |
--amd64 \
--target /data/home-assistant/addons/sbam \
--addon
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" ]
5 changes: 5 additions & 0 deletions home-assistant/addons/sbam/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"build_from": {
"amd64": "ghcr.io/home-assistant/amd64-base:3.18"
}
}
9 changes: 9 additions & 0 deletions home-assistant/addons/sbam/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "sbam",
"version": "1.3.0",
"slug": "sbam",
"description": "Smart Battery Avanced Manager",
"arch": ["amd64"],
"url": "https://github.com/atbore-phx/sbam",
"image": "ghcr.io/atbore-phx/ha-sbam"
}
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
5 changes: 5 additions & 0 deletions repository.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "sbam Smart Battery Manager",
"url": "https://github.com/atbore-phx/sbam",
"maintainer": "atbore-phx"
}

0 comments on commit c9d365b

Please sign in to comment.