mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-11 17:33:38 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ed14cb783 |
@@ -21,7 +21,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: set environment variables
|
||||
run: echo "SHOWBRIDGE_VERSION=${GITHUB_SHA::7}" >> $GITHUB_ENV
|
||||
run: echo "SHOWBRIDGE_VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
|
||||
- name: clean tag
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: echo "SHOWBRIDGE_VERSION=${SHOWBRIDGE_VERSION#v}" >> $GITHUB_ENV
|
||||
@@ -37,37 +37,6 @@ jobs:
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
build_webui:
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup_release
|
||||
env:
|
||||
SHOWBRIDGE_VERSION: ${{ needs.setup_release.outputs.version }}
|
||||
SHORT_COMMIT: ${{ needs.setup_release.outputs.short_commit }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
repository: jwetzell/showbridge-webui
|
||||
ref: main
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version-file: ".nvmrc"
|
||||
cache: "npm"
|
||||
cache-dependency-path: "package-lock.json"
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: npm ci
|
||||
|
||||
- run: npm run build -- --base-href=/ui/
|
||||
|
||||
- name: upload webui artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: dist/webui/
|
||||
|
||||
linux_amd64:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_release
|
||||
@@ -85,11 +54,6 @@ jobs:
|
||||
go-version-file: "go.mod"
|
||||
- name: install alsa lib
|
||||
run: sudo apt-get install -y libasound2-dev
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build
|
||||
run: |
|
||||
CGO_ENABLED=1 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
@@ -124,14 +88,9 @@ jobs:
|
||||
go-version-file: "go.mod"
|
||||
- name: install alsa lib
|
||||
run: sudo apt-get install -y libasound2-dev
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build
|
||||
run: |
|
||||
CGO_ENABLED=1 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
CGO_ENABLED=1 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
tar -czf showbridge_${SHOWBRIDGE_VERSION}_linux-arm64.tar.gz showbridge
|
||||
- name: upload linux artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
@@ -165,18 +124,13 @@ jobs:
|
||||
uses: mlugg/setup-zig@v2
|
||||
with:
|
||||
version: 0.16.0
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build amd64
|
||||
run: |
|
||||
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="zig cc -target x86_64-windows-gnu" CXX="zig c++ -target x86_64-windows-gnu" go build -o showbridge.exe -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="zig cc -target x86_64-windows-gnu" CXX="zig c++ -target x86_64-windows-gnu" go build -o showbridge.exe -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
zip showbridge_${SHOWBRIDGE_VERSION}_windows-amd64.zip showbridge.exe
|
||||
- name: build arm64
|
||||
run: |
|
||||
CGO_ENABLED=1 GOOS=windows GOARCH=arm64 CC="zig cc -target aarch64-windows-gnu" CXX="zig c++ -target aarch64-windows-gnu" go build -o showbridge.exe -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
CGO_ENABLED=1 GOOS=windows GOARCH=arm64 CC="zig cc -target aarch64-windows-gnu" CXX="zig c++ -target aarch64-windows-gnu" go build -o showbridge.exe -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
zip showbridge_${SHOWBRIDGE_VERSION}_windows-arm64.zip showbridge.exe
|
||||
- name: upload windows artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
@@ -206,14 +160,9 @@ jobs:
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version-file: "go.mod"
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build
|
||||
run: |
|
||||
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
tar -czf showbridge_${SHOWBRIDGE_VERSION}_macOS-arm64.tar.gz showbridge
|
||||
- name: upload macos artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
@@ -230,7 +179,7 @@ jobs:
|
||||
files: showbridge_*.tar.gz
|
||||
macos_amd64:
|
||||
runs-on: macos-26-intel
|
||||
needs: [setup_release, build_webui]
|
||||
needs: setup_release
|
||||
env:
|
||||
SHOWBRIDGE_VERSION: ${{ needs.setup_release.outputs.version }}
|
||||
SHORT_COMMIT: ${{ needs.setup_release.outputs.short_commit }}
|
||||
@@ -243,14 +192,9 @@ jobs:
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version-file: "go.mod"
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build
|
||||
run: |
|
||||
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
tar -czf showbridge_${SHOWBRIDGE_VERSION}_macOS-amd64.tar.gz showbridge
|
||||
- name: upload macos artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
|
||||
@@ -21,7 +21,7 @@ require (
|
||||
gitlab.com/gomidi/midi/v2 v2.3.24
|
||||
go.bug.st/serial v1.8.0
|
||||
golang.org/x/time v0.15.0
|
||||
modernc.org/quickjs v0.22.0
|
||||
modernc.org/quickjs v0.23.0
|
||||
modernc.org/sqlite v1.55.0
|
||||
sigs.k8s.io/yaml v1.6.0
|
||||
)
|
||||
@@ -69,8 +69,8 @@ require (
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
gopkg.in/hraban/opus.v2 v2.0.0-20230925203106-0188a62cb302 // indirect
|
||||
modernc.org/libc v1.74.3 // indirect
|
||||
modernc.org/libquickjs v0.12.10 // indirect
|
||||
modernc.org/libc v1.74.4 // indirect
|
||||
modernc.org/libquickjs v0.13.1 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.11.0 // indirect
|
||||
)
|
||||
|
||||
@@ -163,22 +163,22 @@ modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
|
||||
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
|
||||
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
|
||||
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||
modernc.org/gc/v3 v3.1.4 h1:2g65LGVSmFQrXeITAw97x7hCRvZFcyE1uDP+7Vng7JI=
|
||||
modernc.org/gc/v3 v3.1.4/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/gc/v3 v3.1.5 h1:21ldfPfRYE31Tb7B3mwAK8gy1AxP4+dKjrOQPfqakoc=
|
||||
modernc.org/gc/v3 v3.1.5/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||
modernc.org/libc v1.74.3 h1:a4J+Z8aVaxPyjyxRAdJzw246PqpcFGvVPnfT/AuM5Ws=
|
||||
modernc.org/libc v1.74.3/go.mod h1:4H7h/MJ8wnjL8RAbp9v3OXgnk22X7MouHIhDbvP3gj4=
|
||||
modernc.org/libquickjs v0.12.10 h1:nhfXth/BywJmx3Flid/r7iQYdPzc/+B4LDigA9YIKtQ=
|
||||
modernc.org/libquickjs v0.12.10/go.mod h1:UedJnNW5BS4PbItZnk0Zg4tUI7m0ImmmtJAI3yqoF30=
|
||||
modernc.org/libc v1.74.4 h1:fX1Omw4o2/1C2iRkkIsrQTasJQldLhRmuPreXLoWs9k=
|
||||
modernc.org/libc v1.74.4/go.mod h1:eeQAS9W3sZeKYMFubydxJpII9ybHWshk+7or7bLG9co=
|
||||
modernc.org/libquickjs v0.13.1 h1:uCb9AYyEyL1JS2dnKtLZKWH/vDb36cx1Mr1SIdbzb8A=
|
||||
modernc.org/libquickjs v0.13.1/go.mod h1:tCEsA1Zda1+C5JagFIJGqjYZOxDPFOUYjK3dGhEeq0g=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
|
||||
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/quickjs v0.22.0 h1:4YhaspgX4Nc+YN84ZTQdlVMnQCY7M5GloF+D+UvEg7I=
|
||||
modernc.org/quickjs v0.22.0/go.mod h1:kRfDSgneM1WAd/niu2O3tqpTy+HB6+25DmTNKr+DqDA=
|
||||
modernc.org/quickjs v0.23.0 h1:k+px+rFrMqHm2LPMvrd+vCR+8m6eogiTkROz+YJHkj8=
|
||||
modernc.org/quickjs v0.23.0/go.mod h1:bFvjVk4JGlbqLYXVFt72YvwdnHbwtNIE9nQ+eh4fdi0=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||
modernc.org/sqlite v1.55.0 h1:hIFh0MCH0rGinQ/4KYb5/UbCkRkb+UP+OkLCVWa5MTM=
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
webui/
|
||||
@@ -48,8 +48,6 @@ func (as *ApiServer) Start(config config.ApiConfig) {
|
||||
mux.HandleFunc("/schema/routes.schema.json", handleRoutesSchema)
|
||||
mux.HandleFunc("/schema/modules.schema.json", handleModulesSchema)
|
||||
mux.HandleFunc("/schema/processors.schema.json", handleProcessorsSchema)
|
||||
mux.HandleFunc("/ui", handleWebUI)
|
||||
mux.HandleFunc("/ui/", handleWebUI)
|
||||
|
||||
as.serverMu.Lock()
|
||||
defer as.serverMu.Unlock()
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
//go:build !showbridge_webui
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func handleWebUI(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
http.Error(w, "Web UI is not enabled", http.StatusNotImplemented)
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
//go:build showbridge_webui
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"errors"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed webui
|
||||
var webUIFS embed.FS
|
||||
|
||||
var fsPrefix = "webui/browser"
|
||||
|
||||
var index = path.Join(fsPrefix, "index.html")
|
||||
|
||||
func handleWebUI(w http.ResponseWriter, req *http.Request) {
|
||||
requestedPath := strings.TrimLeft(req.URL.Path, "/ui")
|
||||
switch req.Method {
|
||||
case http.MethodGet:
|
||||
var pathToLoad string
|
||||
stat, err := fs.Stat(webUIFS, path.Join(fsPrefix, requestedPath))
|
||||
if err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
pathToLoad = index
|
||||
} else {
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
if stat != nil {
|
||||
if stat.IsDir() {
|
||||
pathToLoad = index
|
||||
} else {
|
||||
pathToLoad = path.Join(fsPrefix, requestedPath)
|
||||
}
|
||||
}
|
||||
file, err := webUIFS.ReadFile(pathToLoad)
|
||||
if err != nil {
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
|
||||
switch path.Ext(pathToLoad) {
|
||||
case ".js":
|
||||
w.Header().Set("Content-Type", "application/javascript")
|
||||
case ".css":
|
||||
w.Header().Set("Content-Type", "text/css")
|
||||
case ".html":
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
case ".ico":
|
||||
w.Header().Set("Content-Type", "image/x-icon")
|
||||
}
|
||||
w.Write(file)
|
||||
return
|
||||
|
||||
case http.MethodOptions:
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
default:
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user