diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a9ababc..c940e17 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 \ No newline at end of file + - name: Add to release + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..1257518 --- /dev/null +++ b/.goreleaser.yaml @@ -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:" diff --git a/README.md b/README.md index 165efc0..7c0a7cb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.sh b/build.sh index 5ab485d..ef434bf 100755 --- a/build.sh +++ b/build.sh @@ -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 \ No newline at end of file +CGO_ENABLED=0 GOOS=linux GOARCH="$ARCH" go build -o "../BUILD/enervent-ctrl-${VERSION}.linux-$ARCH" . \ No newline at end of file diff --git a/main.go b/main.go index 527374f..962e8bc 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/static/html/coils/index.html b/static/html/coils/index.html deleted file mode 120000 index 79c5d6f..0000000 --- a/static/html/coils/index.html +++ /dev/null @@ -1 +0,0 @@ -../index.html \ No newline at end of file diff --git a/static/html/registers/index.html b/static/html/registers/index.html deleted file mode 120000 index 79c5d6f..0000000 --- a/static/html/registers/index.html +++ /dev/null @@ -1 +0,0 @@ -../index.html \ No newline at end of file