v0.1.2
- Fix routing, remove the awkward symlinking system for index.html - Automatic binary build with GH Actions
This commit is contained in:
parent
8278bc9445
commit
d1f734dd32
|
@ -12,17 +12,16 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '1.18.0'
|
go-version: '1.18.0'
|
||||||
|
- name: Add to release
|
||||||
# Install all the dependencies
|
uses: goreleaser/goreleaser-action@v5
|
||||||
- name: Install dependencies
|
with:
|
||||||
run: go version
|
distribution: goreleaser
|
||||||
|
version: latest
|
||||||
|
args: release --clean
|
||||||
# Run build of the application
|
env:
|
||||||
- name: Build x86_64
|
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }}
|
||||||
run: ./build.sh
|
|
|
@ -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:"
|
|
@ -25,10 +25,6 @@ has been used.
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
- clone or download the repo
|
- 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):
|
- Build for the correct architecture, e.g. for Linux 32-bit ARM (Rpi Zero W 1):
|
||||||
```
|
```
|
||||||
cd /path/to/repo
|
cd /path/to/repo
|
||||||
|
|
15
build.sh
15
build.sh
|
@ -1,4 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash -x
|
||||||
|
|
||||||
|
pwd
|
||||||
|
|
||||||
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
|
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
|
||||||
echo -e "Usage: $0 [ARCH|-h|--help]"
|
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 '"')
|
VERSION=$(grep -e 'version.*=' main.go | awk '{print $3}' | tr -d '"')
|
||||||
|
|
||||||
pushd TMP &> /dev/null || exit 1
|
CGO_ENABLED=0 GOOS=linux GOARCH="$ARCH" go build -o "../BUILD/enervent-ctrl-${VERSION}.linux-$ARCH" .
|
||||||
|
|
||||||
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
|
|
4
main.go
4
main.go
|
@ -25,7 +25,7 @@ import (
|
||||||
var static embed.FS
|
var static embed.FS
|
||||||
|
|
||||||
var (
|
var (
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
device pingvin.Pingvin
|
device pingvin.Pingvin
|
||||||
config Conf
|
config Conf
|
||||||
usernamehash [32]byte
|
usernamehash [32]byte
|
||||||
|
@ -64,6 +64,8 @@ func serve(cert, key *string) {
|
||||||
}
|
}
|
||||||
htmlroot := http.FileServer(http.FS(html))
|
htmlroot := http.FileServer(http.FS(html))
|
||||||
http.HandleFunc("/", authHandler(htmlroot))
|
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)
|
logdst, err := os.OpenFile(os.DevNull, os.O_WRONLY, os.ModeAppend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../index.html
|
|
|
@ -1 +0,0 @@
|
||||||
../index.html
|
|
Loading…
Reference in New Issue