diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f7aced..17ece11 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,10 +22,6 @@ jobs: with: go-version: stable - - uses: pnpm/action-setup@v3 - with: - version: 8 - - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: diff --git a/.gitignore b/.gitignore index 7facc49..32b0b6c 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,6 @@ sslcerts *.env.staging *.db logs -bin \ No newline at end of file +bin +ui/dist +teldrive-ui.zip \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c7eba1e..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "ui/teldrive-ui"] - path = ui/teldrive-ui - url = https://github.com/divyam234/teldrive-ui diff --git a/Makefile b/Makefile index b6b46d1..fb2d58f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -FRONTEND_DIR := ui/teldrive-ui -BUILD_DIR := bin APP_NAME := teldrive - +BUILD_DIR := bin +FRONTEND_DIR := ui/dist +FRONTEND_ASSET := https://github.com/divyam234/teldrive-ui/releases/download/v1/teldrive-ui.zip GIT_TAG := $(shell git describe --tags --abbrev=0) GIT_COMMIT := $(shell git rev-parse --short HEAD) GIT_LINK := $(shell git remote get-url origin) @@ -23,17 +23,23 @@ SHELL := /bin/bash BINARY_EXTENSION:= endif -frontend: $(ENV_FILE) - @echo "Building frontend..." - cd $(FRONTEND_DIR) ; pnpm install ; pnpm build - -$(ENV_FILE): Makefile -ifdef ComSpec - @echo 'VITE_VERSION_INFO={"version": "$(GIT_TAG)", "commit": "$(GIT_COMMIT)", "link": "$(GIT_LINK)"}' | Out-File -encoding utf8 $(ENV_FILE) +frontend: + @echo "Extract UI" +ifeq ($(OS),Windows_NT) + powershell -Command "Remove-Item -Path $(FRONTEND_DIR) -Recurse -Force" + powershell -Command "Invoke-WebRequest -Uri $(FRONTEND_ASSET) -OutFile teldrive-ui.zip" + powershell -Command "if (!(Test-Path -Path $(subst /,\\,$(FRONTEND_DIR)))) { New-Item -ItemType Directory -Force -Path $(subst /,\\,$(FRONTEND_DIR)) }" + powershell -Command "Expand-Archive -Path teldrive-ui.zip -DestinationPath $(FRONTEND_DIR) -Force" + powershell -Command "Remove-Item -Path teldrive-ui.zip -Force" else - @echo 'VITE_VERSION_INFO={"version": "$(GIT_TAG)", "commit": "$(GIT_COMMIT)", "link": "$(GIT_LINK)"}' > $(ENV_FILE) + rm -rf $(FRONTEND_DIR) + curl -LO $(FRONTEND_ASSET) -o teldrive-ui.zip + mkdir -p $(FRONTEND_DIR) + unzip -d $(FRONTEND_DIR) teldrive-ui.zip + rm -rf teldrive-ui.zip endif + backend: @echo "Building backend for $(GOOS)/$(GOARCH)..." go build -trimpath -ldflags "-s -w -X $(MODULE_PATH)/internal/config.Version=$(GIT_TAG) -extldflags=-static" -o $(BUILD_DIR)/$(APP_NAME)$(BINARY_EXTENSION) @@ -54,12 +60,6 @@ deps: @echo "Installing Go dependencies..." go mod download - @echo "Installing frontend dependencies..." - cd $(FRONTEND_DIR) && pnpm install - -sync-ui: - git submodule update --init --recursive --remote - retag: @echo "Retagging..." git tag -d $(GIT_TAG) diff --git a/ui/teldrive-ui b/ui/teldrive-ui deleted file mode 160000 index cdd8c6a..0000000 --- a/ui/teldrive-ui +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cdd8c6a7cf04ac72164c5b212d7a13b75041b1c0 diff --git a/ui/ui.go b/ui/ui.go index 559a31c..e1e0474 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -11,7 +11,7 @@ import ( "github.com/gin-gonic/gin" ) -//go:embed all:teldrive-ui/dist +//go:embed all:dist var staticFS embed.FS func AddRoutes(router gin.IRouter) { @@ -28,7 +28,7 @@ type staticFileSystem struct { var _ static.ServeFileSystem = (*staticFileSystem)(nil) func newStaticFileSystem() *staticFileSystem { - sub, err := fs.Sub(staticFS, "teldrive-ui/dist") + sub, err := fs.Sub(staticFS, "dist") if err != nil { panic(err) @@ -40,7 +40,7 @@ func newStaticFileSystem() *staticFileSystem { } func (s *staticFileSystem) Exists(prefix string, path string) bool { - buildpath := fmt.Sprintf("teldrive-ui/dist%s", path) + buildpath := fmt.Sprintf("dist%s", path) if strings.HasSuffix(path, "/") { _, err := staticFS.ReadDir(strings.TrimSuffix(buildpath, "/"))