From 78f517c2cb5a94935a50cd5f8940147c243c3b79 Mon Sep 17 00:00:00 2001 From: Rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Tue, 22 Aug 2023 09:46:42 +0800 Subject: [PATCH] fix: goreleaser build without embed UI (#176) --- .github/workflows/release.yaml | 2 -- .goreleaser.yaml | 1 + Makefile | 8 ++++++-- go.sum | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 35e3532a..ed685c53 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,8 +30,6 @@ jobs: node-version: 18.x cache: 'npm' cache-dependency-path: console/atest-ui/package-lock.json - - name: Build - run: make build-embed-ui - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2.9.1 with: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 14df9e01..0be3056a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -4,6 +4,7 @@ before: hooks: # You may remove this if you don't use go modules. - go mod tidy + - make embed-ui builds: - env: - CGO_ENABLED=0 diff --git a/Makefile b/Makefile index 9d3b2d42..652da27d 100644 --- a/Makefile +++ b/Makefile @@ -5,19 +5,23 @@ build: mkdir -p bin rm -rf bin/atest go build -o bin/atest main.go -build-embed-ui: +embed-ui: cd console/atest-ui && npm i && npm run build-only cp console/atest-ui/dist/index.html cmd/data/index.html cp console/atest-ui/dist/assets/*.js cmd/data/index.js cp console/atest-ui/dist/assets/*.css cmd/data/index.css - GOOS=${OS} go build -ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=$(shell git rev-parse --short HEAD)" -o bin/${BINARY} main.go +clean-embed-ui: echo -n '' > cmd/data/index.html echo -n '' > cmd/data/index.js echo -n '' > cmd/data/index.css +build-embed-ui: embed-ui + GOOS=${OS} go build -ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=$(shell git rev-parse --short HEAD)" -o bin/${BINARY} main.go + make clean-embed-ui build-win-embed-ui: BINARY=atest.exe OS=windows make build-embed-ui goreleaser: goreleaser build --rm-dist --snapshot + make clean-embed-ui build-image: ${IMG_TOOL} build -t ghcr.io/linuxsuren/api-testing:master . \ --build-arg GOPROXY=https://goproxy.cn,direct \ diff --git a/go.sum b/go.sum index 5823918e..d937e798 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/antonmedv/expr v1.12.1 h1:GTGrGN1kxxb+le0uQKaFRK8By4cvq1sleUCGE/U6hHg= -github.com/antonmedv/expr v1.12.1/go.mod h1:FPC8iWArxls7axbVLsW+kpg1mz29A1b2M6jt+hZfDkU= +github.com/antonmedv/expr v1.14.0 h1:C4BHw+0cVyKy/ndU3uqYo6TV5rCtq/SY2Wdlwanvo/Q= +github.com/antonmedv/expr v1.14.0/go.mod h1:FPC8iWArxls7axbVLsW+kpg1mz29A1b2M6jt+hZfDkU= github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=