- Fix routing, remove the awkward symlinking system for index.html
- Automatic binary build with GH Actions
This commit is contained in:
Jarno Rankinen 2024-03-08 00:20:02 +02:00
parent 8278bc9445
commit d1f734dd32
7 changed files with 48 additions and 29 deletions

View File

@ -12,17 +12,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: '1.18.0'
# Install all the dependencies
- name: Install dependencies
run: go version
# Run build of the application
- name: Build x86_64
run: ./build.sh
- name: Add to release
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }}

31
.goreleaser.yaml Normal file
View File

@ -0,0 +1,31 @@
version: 1
before:
hooks:
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
- arm
archives:
- format: binary
name_template: >-
{{ .ProjectName }}-
{{- .Os }}-
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

View File

@ -25,10 +25,6 @@ has been used.
### Building
- clone or download the repo
- `static/html/index.html` is symlinked to `coils` and `registers`
for development purposes, the symlinks need to be dereferenced before
building the binary on filesystems that support symlinks
- Replace symlinks with copies of the files or use e.g. `tar -h`
- Build for the correct architecture, e.g. for Linux 32-bit ARM (Rpi Zero W 1):
```
cd /path/to/repo

View File

@ -1,4 +1,6 @@
#!/bin/bash
#!/bin/bash -x
pwd
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo -e "Usage: $0 [ARCH|-h|--help]"
@ -10,13 +12,4 @@ ARCH=${1:-"amd64"}
VERSION=$(grep -e 'version.*=' main.go | awk '{print $3}' | tr -d '"')
pushd TMP &> /dev/null || exit 1
tar --exclude ../TMP -ch ../* | tar xf -
#env GOOS=linux GOARCH=arm go build -o ../BUILD/enervent-ctrl-${VERSION}.linux-arm32 .
CGO_ENABLED=0 GOOS=linux GOARCH="$ARCH" go build -o "../BUILD/enervent-ctrl-${VERSION}.linux-$ARCH" .
rm -rf ./*
popd &> /dev/null || exit 1
CGO_ENABLED=0 GOOS=linux GOARCH="$ARCH" go build -o "../BUILD/enervent-ctrl-${VERSION}.linux-$ARCH" .

View File

@ -25,7 +25,7 @@ import (
var static embed.FS
var (
version = "0.1.1"
version = "0.1.2"
device pingvin.Pingvin
config Conf
usernamehash [32]byte
@ -64,6 +64,8 @@ func serve(cert, key *string) {
}
htmlroot := http.FileServer(http.FS(html))
http.HandleFunc("/", authHandler(htmlroot))
http.HandleFunc("/coils/", authHandler(http.StripPrefix("/coils/", htmlroot)))
http.HandleFunc("/registers/", authHandler(http.StripPrefix("/registers/", htmlroot)))
logdst, err := os.OpenFile(os.DevNull, os.O_WRONLY, os.ModeAppend)
if err != nil {
log.Fatal(err)

View File

@ -1 +0,0 @@
../index.html

View File

@ -1 +0,0 @@
../index.html