Skip to content

Commit

Permalink
fix(action): fix action
Browse files Browse the repository at this point in the history
fix action

Signed-off-by: ysicing <[email protected]>
  • Loading branch information
ysicing committed Aug 29, 2023
1 parent 0745cd9 commit 592ff27
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ jobs:
- name: test qcadmin
run: |
./_output/qcadmin_linux_amd64 version
sudo ./_output/qcadmin_linux_amd64 cluster init --debug
sudo ./_output/qcadmin_linux_amd64 quickon init --domain local.demo --version test-2.6 --debug
sudo ./_output/qcadmin_linux_amd64 init --domain github.local --debug
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:

before:
hooks:
- make generate
- task generate
- ./hack/scripts/gencompletions.sh
- ./hack/scripts/genmanpages.sh

Expand Down
117 changes: 117 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
###########################################
.EXPORT_ALL_VARIABLES:
VERSION_PKG := github.com/easysoft/qcadmin/common
ROOT_DIR := $(CURDIR)
BUILD_DIR := $(ROOT_DIR)/_output
BIN_DIR := $(BUILD_DIR)/bin
LOCAL_OS := $(shell go version | awk '{print \$NF}')

GO111MODULE = on
GOPROXY = https://goproxy.cn,direct
GOSUMDB = sum.golang.google.cn

BUILD_RELEASE ?= v$(shell cat VERSION || echo "0.0.1")
BUILD_DATE := $(shell date "+%Y%m%d")
GIT_BRANCH := $(shell git branch -r --contains | head -1 | sed -E -e "s%(HEAD ->|origin|upstream)/?%%g" | xargs)
GIT_COMMIT := $(shell git rev-parse --short HEAD || echo "abcdefgh")
APP_VERSION := ${BUILD_RELEASE}-${BUILD_DATE}-${GIT_COMMIT}

LDFLAGS := "-w -s \
-X '$(VERSION_PKG).Version=$(BUILD_RELEASE)' \
-X '$(VERSION_PKG).BuildDate=$(BUILD_DATE)' \
-X '$(VERSION_PKG).GitCommitHash=$(GIT_COMMIT)' \
-X 'k8s.io/client-go/pkg/version.gitVersion=${BUILD_RELEASE}' \
-X 'k8s.io/client-go/pkg/version.gitCommit=${GIT_COMMIT}' \
-X 'k8s.io/client-go/pkg/version.gitTreeState=dirty' \
-X 'k8s.io/client-go/pkg/version.buildDate=${BUILD_DATE}' \
-X 'k8s.io/client-go/pkg/version.gitMajor=1' \
-X 'k8s.io/client-go/pkg/version.gitMinor=24' \
-X 'k8s.io/component-base/version.gitVersion=${BUILD_RELEASE}' \
-X 'k8s.io/component-base/version.gitCommit=${GIT_COMMIT}' \
-X 'k8s.io/component-base/version.gitTreeState=dirty' \
-X 'k8s.io/component-base/version.gitMajor=1' \
-X 'k8s.io/component-base/version.gitMinor=24' \
-X 'k8s.io/component-base/version.buildDate=${BUILD_DATE}'"

##########################################################################

help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

gencopyright: ## add copyright
@bash hack/scripts/gencopyright.sh

doc: ## gen docs
rm -rf ./docs/*.md
go run ./docs/docs.go
cp -a README.md docs/index.md

fmt: ## fmt code
gofmt -s -w .
goimports -w .
@echo gofmt -l
@OUTPUT=`gofmt -l . 2>&1`; \
if [ "$$OUTPUT" ]; then \
echo "gofmt must be run on the following files:"; \
echo "$$OUTPUT"; \
exit 1; \
fi

lint: ## lint code
@echo golangci-lint run -v ./...
@OUTPUT=`command -v golangci-lint >/dev/null 2>&1 && golangci-lint run -v ./... 2>&1`; \
if [ "$$OUTPUT" ]; then \
echo "go lint errors:"; \
echo "$$OUTPUT"; \
fi

default: gencopyright fmt lint ## fmt code

coverage: generate ## coverage
go test -race -failfast -coverprofile=coverage.out -covermode=atomic `go list ./... | grep -vE '(internal/static)'`

build: ## build binary
@echo "build bin ${GIT_VERSION} $(GIT_COMMIT) $(GIT_BRANCH) $(BUILD_DATE) $(GIT_TREE_STATE)"
@GO_ENABLED=1 gox -osarch="linux/amd64 linux/arm64" \
-output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" \
-ldflags ${LDFLAGS}

generate: ## generate
go generate ./...

dev: generate ## dev test
GO_ENABLED=1 gox -osarch="linux/amd64" \
-output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" \
-ldflags ${LDFLAGS}

local: ## dev test
GO_ENABLED=1 gox -osarch="darwin/arm64" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags ${LDFLAGS}

clean: ## clean
rm -rf dist

upx: ## upx
upx dist/*

fixme: ## fixme check
grep -rnw "FIXME" internal

todo: ## todo check
grep -rnw "TODO" internal

# Legacy code should be removed by the time of release
legacy: # legacy code check
grep -rnw "\(LEGACY\|Deprecated\)" internal

.PHONY : build prod-docker dev-push clean

snapshot: ## local test goreleaser
goreleaser release --snapshot --clean --skip-publish

fix-version:
@echo "fix version"
cat examples/sonar-project.properties.example | sed "s#2.0.0#${APP_VERSION}#g" > sonar-project.properties

fix-local-version:
@echo "fix version"
cat examples/sonar-project.properties.example | sed "s#2.0.0#${APP_VERSION}#g" | sed "s#quickon#pangu#g" > sonar-project.properties

0 comments on commit 592ff27

Please sign in to comment.