diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 30d46440..46f4c1e4 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -11,8 +11,9 @@ version: 1 before: hooks: - go mod tidy - - go generate ./... - - sh -c "ls && cd ./webui && npm i && npm run build && gzip ./dist/*" + - npm --prefix webui install + - sh -c "GOOS=linux go generate ./..." + - sh -c "GOOS=windows go generate ./..." builds: - main: . diff --git a/README.md b/README.md index 1862996b..acfc212f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Backrest is a web-accessible backup solution built on top of [restic](https://restic.net/). Backrest provides a WebUI which wraps the restic CLI and makes it easy to create repos, browse snapshots, and restore files. Additionally, Backrest can run in the background and take an opinionated approach to scheduling snapshots and orchestrating repo health operations. -By building on restic Backrest gets the advantages of restic mature feature set: restic provides fast, reliable (used by tens of thousands of individuals and by corporations in production environments), and secure backup operations. Backrest itself is built in Golang (matching restic's implementation) and is shipped as a self-contained and light weight (<20 MB on all platforms) binary with no dependecies other than restic (which backrest can download for you and keep up to date). +By building on restic, Backrest leverages restic's mature feature set. Restic provides fast, reliable (used by tens of thousands of individuals and by corporations in production environments), and secure backup operations. Backrest itself is built in Golang (matching restic's implementation) and is shipped as a self-contained and light weight (<20 MB on all platforms) binary with no dependecies other than restic (which backrest can download for you and keep up to date). This project aims to be the easiest way to setup and get started with backups on any system. You can expect to be able to perform all operations from the web interface but should you ever need more poworeful control, you are free to browse your repo and perform operations using the [restic cli](https://restic.readthedocs.io/en/latest/manual_rest.html). Backrest safely detects and imports external operations (e.g. manual backups). diff --git a/backrest.go b/backrest.go index 7cab4614..baf8b048 100644 --- a/backrest.go +++ b/backrest.go @@ -13,7 +13,6 @@ import ( "sync" "syscall" - rice "github.com/GeertJohan/go.rice" "github.com/garethgeorge/backrest/gen/go/v1/v1connect" "github.com/garethgeorge/backrest/internal/api" "github.com/garethgeorge/backrest/internal/auth" @@ -94,7 +93,7 @@ func main() { mux := http.NewServeMux() - if box, err := rice.FindBox("webui/dist"); err == nil { + if box, err := WebUIBox(); err == nil { mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if strings.HasSuffix(r.URL.Path, "/") { r.URL.Path += "index.html" diff --git a/go.work b/go.work new file mode 100644 index 00000000..767c526b --- /dev/null +++ b/go.work @@ -0,0 +1,3 @@ +go 1.21.3 + +use . diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 00000000..d32061e1 --- /dev/null +++ b/go.work.sum @@ -0,0 +1,5 @@ +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/webui/.gitignore b/webui/.gitignore index f8b18656..75f5a6de 100644 --- a/webui/.gitignore +++ b/webui/.gitignore @@ -1,3 +1,4 @@ .parcel-cache node_modules dist +dist-windows diff --git a/webui/package.json b/webui/package.json index 2f6cedb8..a6f4ebf9 100644 --- a/webui/package.json +++ b/webui/package.json @@ -5,7 +5,7 @@ "scripts": { "start": "parcel serve src/index.html", "build": "BACKREST_BUILD_VERSION=$(git describe --tags --abbrev=0) UI_OS=unix parcel build src/index.html", - "build-windows": "set UI_OS=windows & parcel build src/index.html", + "build-windows": "BACKREST_BUILD_VERSION=$(git describe --tags --abbrev=0) UI_OS=windows parcel build src/index.html --dist-dir dist-windows", "test": "echo \"Error: no test specified\" && exit 1", "check": "tsc --noEmit" }, diff --git a/webuinix.go b/webuinix.go new file mode 100644 index 00000000..7df9578c --- /dev/null +++ b/webuinix.go @@ -0,0 +1,12 @@ +//go:build linux || darwin +// +build linux darwin + +//go:generate sh -c "rm -rf ./webui/dist && UI_OS=unix npm --prefix webui run build && gzip ./webui/dist/*" + +package main + +import rice "github.com/GeertJohan/go.rice" + +func WebUIBox() (*rice.Box, error) { + return rice.FindBox("webui/dist") +} diff --git a/webuiwin.go b/webuiwin.go new file mode 100644 index 00000000..076829c5 --- /dev/null +++ b/webuiwin.go @@ -0,0 +1,12 @@ +//go:build windows +// +build windows + +//go:generate sh -c "rm -rf ./webui/dist-windows && npm --prefix webui run build-windows && gzip ./webui/dist-windows/*" + +package main + +import rice "github.com/GeertJohan/go.rice" + +func WebUIBox() (*rice.Box, error) { + return rice.FindBox("webui/dist-windows") +}