forked from home-assistant/os-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate GitHub build action to use GoReleaser (home-assistant#27)
* Migrate GitHub build action to use GoReleaser * Update README * Fix indent error in build.yaml * Build snapshot in PR * Add comment for force-depth Co-authored-by: Joakim Sørensen <[email protected]> * Add udisks2 dependency Co-authored-by: Joakim Sørensen <[email protected]>
- Loading branch information
Showing
7 changed files
with
188 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,44 +8,78 @@ on: | |
|
||
env: | ||
GOLANG_VERSION: "1.15" | ||
BINARY_NAME: "os-agent-debian-amd64.bin" | ||
|
||
jobs: | ||
build_debian: | ||
name: Build amd64 debian | ||
build: | ||
name: Build OS-Agent | ||
runs-on: ubuntu-latest | ||
container: buildpack-deps:buster | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
|
||
- name: Setup go ${{ env.GOLANG_VERSION }} | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ env.GOLANG_VERSION }} | ||
|
||
- name: Build binary | ||
run: | | ||
version=$(echo "${{ github.ref }}" | awk -F"/" '{print $NF}') | ||
go build -ldflags="-s -w -X main.version=${version}" -o "${{ env.BINARY_NAME }}" | ||
du -hs os-agent-debian-amd64.bin | ||
- name: Upload release asset | ||
if: github.event_name == 'release' | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: "${{ github.workspace }}/${{ env.BINARY_NAME }}" | ||
asset_name: ${{ env.BINARY_NAME }} | ||
asset_content_type: application/x-binary | ||
|
||
- name: Signing asset | ||
if: github.event_name == 'release' | ||
uses: home-assistant/actions/helpers/codenotary@master | ||
with: | ||
source: "${{ github.workspace }}/${{ env.BINARY_NAME }}" | ||
user: ${{ secrets.VCN_USER }} | ||
password: ${{ secrets.VCN_PASSWORD }} | ||
organisation: ${{ secrets.VCN_ORG }} | ||
- name: Checkout the repository | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 # Needed for changelog generation | ||
|
||
- name: Setup go ${{ env.GOLANG_VERSION }} | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ env.GOLANG_VERSION }} | ||
|
||
- name: Run GoReleaser build | ||
uses: goreleaser/[email protected] | ||
if: github.event_name == 'pull_request' | ||
with: | ||
args: build --snapshot --rm-dist | ||
|
||
- name: Run GoReleaser release | ||
uses: goreleaser/[email protected] | ||
if: github.event_name == 'release' | ||
with: | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Signing asset amd64 | ||
if: github.event_name == 'release' | ||
uses: home-assistant/actions/helpers/codenotary@master | ||
with: | ||
source: "${{ github.workspace }}/dist/os-agent_linux_amd64/os-agent" | ||
user: ${{ secrets.VCN_USER }} | ||
password: ${{ secrets.VCN_PASSWORD }} | ||
organisation: ${{ secrets.VCN_ORG }} | ||
|
||
- name: Signing asset armv5 | ||
if: github.event_name == 'release' | ||
uses: home-assistant/actions/helpers/codenotary@master | ||
with: | ||
source: "${{ github.workspace }}/dist/os-agent_linux_arm_5/os-agent" | ||
user: ${{ secrets.VCN_USER }} | ||
password: ${{ secrets.VCN_PASSWORD }} | ||
organisation: ${{ secrets.VCN_ORG }} | ||
|
||
- name: Signing asset armv7 | ||
if: github.event_name == 'release' | ||
uses: home-assistant/actions/helpers/codenotary@master | ||
with: | ||
source: "${{ github.workspace }}/dist/os-agent_linux_arm_7/os-agent" | ||
user: ${{ secrets.VCN_USER }} | ||
password: ${{ secrets.VCN_PASSWORD }} | ||
organisation: ${{ secrets.VCN_ORG }} | ||
|
||
- name: Signing asset aarch64 | ||
if: github.event_name == 'release' | ||
uses: home-assistant/actions/helpers/codenotary@master | ||
with: | ||
source: "${{ github.workspace }}/dist/os-agent_linux_arm64/os-agent" | ||
user: ${{ secrets.VCN_USER }} | ||
password: ${{ secrets.VCN_PASSWORD }} | ||
organisation: ${{ secrets.VCN_ORG }} | ||
|
||
- name: Signing asset i386 | ||
if: github.event_name == 'release' | ||
uses: home-assistant/actions/helpers/codenotary@master | ||
with: | ||
source: "${{ github.workspace }}/dist/os-agent_linux_386/os-agent" | ||
user: ${{ secrets.VCN_USER }} | ||
password: ${{ secrets.VCN_PASSWORD }} | ||
organisation: ${{ secrets.VCN_ORG }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
before: | ||
hooks: | ||
- go mod tidy | ||
- go generate ./... | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
binary: os-agent | ||
ldflags: | ||
- -s -w | ||
- -X main.version={{.Version}} | ||
goos: | ||
- linux | ||
goarch: | ||
- 386 | ||
- amd64 | ||
- arm | ||
- arm64 | ||
goarm: | ||
- 5 | ||
- 7 | ||
|
||
archives: | ||
- replacements: | ||
386: i386 | ||
amd64: x86_64 | ||
arm64: aarch64 | ||
wrap_in_directory: true | ||
files: | ||
- LICENSE | ||
- contrib/haos-agent.service | ||
- contrib/io.hass.conf | ||
|
||
checksum: | ||
name_template: checksums.txt | ||
algorithm: sha512 | ||
|
||
changelog: | ||
sort: asc | ||
|
||
nfpms: | ||
- maintainer: Home Assistant <[email protected]> | ||
description: Home Assistant OS Agent | ||
homepage: https://www.home-assistant.io | ||
license: Apache 2.0 | ||
section: default | ||
priority: extra | ||
bindir: /usr/bin | ||
formats: | ||
- deb | ||
dependencies: | ||
- udisks2 | ||
replacements: | ||
386: i386 | ||
amd64: x86_64 | ||
arm64: aarch64 | ||
contents: | ||
- src: contrib/haos-agent.service | ||
dst: /usr/lib/systemd/system/haos-agent.service | ||
- src: contrib/io.hass.conf | ||
dst: /etc/dbus-1/system.d/io.hass.conf | ||
scripts: | ||
postinstall: contrib/debian/postinstall.sh | ||
preremove: contrib/debian/preremove.sh | ||
postremove: contrib/debian/postremove.sh | ||
|
||
release: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,50 @@ | ||
# Agent for Home Assistant OS | ||
|
||
## Compile | ||
This is the OS Agent for Home Assistant. It is used for Home Assistant | ||
OS and Home Assistant Supervised installation types and it allows the | ||
Home Assistant Supervisor to communicate with the host operating system. | ||
|
||
## Installation & Update | ||
|
||
### Using the Home Assistant Operating System | ||
|
||
The OS Agent is pre-installed with the Home Assistant Operating System. | ||
|
||
Updates are part of the Home Assistant Operating System updates, which | ||
the Home Assistant UI will offer to upgrade to when there is a new version | ||
available. | ||
|
||
### Using Home Assistant Supervised on Debian | ||
|
||
Download the latest Debian package from OS Agent GitHub release page at: | ||
|
||
<https://github.com/home-assistant/os-agent/releases/latest> | ||
|
||
Next, install (or update) the downloaded Debian package using: | ||
|
||
```shell | ||
sudo dpkg -i os-agent_1.0.0_linux_x86_64.deb | ||
``` | ||
go build -ldflags "-X main.version=" | ||
|
||
Note: Replace the `deb` file in the above example with the file you | ||
have downloaded from the releases page. | ||
|
||
You can test if the installation was successful by running: | ||
|
||
```bash | ||
gdbus introspect --system --dest io.hass.os --object-path /io/hass/os | ||
``` | ||
|
||
## Development | ||
|
||
### Compile | ||
|
||
```shell | ||
go build -ldflags "-X main.version=" | ||
``` | ||
|
||
## Tests | ||
### Tests | ||
|
||
```sh | ||
$ gdbus introspect --system --dest io.hass.os --object-path /io/hass/os | ||
```shell | ||
gdbus introspect --system --dest io.hass.os --object-path /io/hass/os | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
systemctl daemon-reload | ||
systemctl enable haos-agent | ||
systemctl start haos-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
systemctl daemon-reload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
systemctl stop haos-agent | ||
systemctl disable haos-agent |