Skip to content

Commit

Permalink
chore(Makefile): optimize make build
Browse files Browse the repository at this point in the history
Solve the problem of repository changing from clean state to dirty state after executing `make build` every time.
  • Loading branch information
windvalley committed Oct 24, 2023
1 parent 1683247 commit 02c418f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 32 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## v0.15.1

### Changed

- GoFrame 版本升级到 `v2.5.6`
- 优化 `make build` 的版本生成功能, 解决每次执行完 `make build` , 仓库从 `clean` 状态变为 `dirty` 状态的问题.

## v0.15.0

### Added
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://seisman.github.io/how-to-write-makefile/index.html

# Be same as gf version in go.mod.
GF_VERSION = v2.5.5
GF_VERSION = v2.5.6
GF_PATH = ${HOME}/.gf/${GF_VERSION}
GF_BIN = ${GF_PATH}/gf

Expand Down Expand Up @@ -134,13 +134,15 @@ build: ctrl service
@echo "******** gf build ${APISERVER_PATH} ********"
@${SED} -i '/^ version:/s/version:.*/version: ${VERSION}/' hack/config.yaml
@go mod tidy && ${GF_BIN} build ${APISERVER_PATH} ${GF_BUILD_ARGS}
@${SED} -i '/^ version:/s/version:.*/version:/' hack/config.yaml

## build.cli: Build gf2-demo-cli binary
.PHONY: build.cli
build.cli: ctrl service
@echo "******** gf build ${CLI_PATH} ********"
@${SED} -i '/^ version:/s/version:.*/version: ${VERSION}/' hack/config.yaml
@go mod tidy && ${GF_BIN} build ${CLI_PATH} ${GF_BUILD_ARGS}
@${SED} -i '/^ version:/s/version:.*/version:/' hack/config.yaml

# Build image, deploy image and yaml to current kubectl environment and make port forward to local machine
.PHONY: start
Expand Down
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -668,20 +668,28 @@ git push --tags
- gf 工具配置(`hack/config.yaml`)
```yaml
# doc: https://goframe.org/pages/viewpage.action?pageId=3673173
gfcli:
# doc: https://goframe.org/pages/viewpage.action?pageId=1115788
build:
path: "./bin" # 编译生成的二进制文件的存放目录. 生成的二进制名称默认与程序入口go文件同名
arch: "amd64"
system: "linux,darwin"
packSrc: "manifest/config" # 将项目需要的配置文件打包进二进制, 这样项目部署的时候就可以不用拷贝配置文件了
extra: ""
# 编译时的内置变量可以在运行时通过gbuild包获取, 比如: utility/version.go
varMap:
# NOTE:
# 1) `version` was generated by `make build`, Do Not Edit
# 2) you should manage versions by `git tag vX.X.X`
version: v0.3.0
# doc: https://goframe.org/pages/viewpage.action?pageId=1115788
build:
path: "./bin" # 编译生成的二进制文件的存放目录. 生成的二进制名称默认与程序入口go文件同名
arch: "amd64"
system: "linux,darwin"
# 将项目需要的配置文件打包进二进制, 这样项目部署的时候就可以不用拷贝配置文件了.
# NOTE: 1) 如果开启了打包功能, 但还是想再使用外部配置文件,
# 需要通过环境变量GF_GCFG_FILE或-c参数指定配置文件路径.
# 例如:
# GF_GCFG_FILE=./config.prod.yaml ./gf2-demo-api
# 或: ./gf2-demo-api -c ./config.prod.yaml
# 2) 使用外部配置文件的好处: 可以不用重新编译变更配置文件内容, 支持配置文件热更新.
# 3) 使用外部配置文件的缺点: 配置文件的变化没有经过版本管理, 出现问题不方便回溯历史.
packSrc: "manifest/config"
extra: ""
# 编译时的内置变量可以在运行时通过gbuild包获取, 比如: utility/version.go
varMap:
# NOTE: 1) `version` is used by `make build` to generate binary version. Do Not Edit.
# 2) You can manage the project versions by command `git tag vX.X.X`
version:
```
- 编译
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/windvalley/gf2-demo
go 1.18

require (
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.5
github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.5
github.com/gogf/gf/contrib/sdk/httpclient/v2 v2.5.5
github.com/gogf/gf/v2 v2.5.5
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.6
github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.6
github.com/gogf/gf/contrib/sdk/httpclient/v2 v2.5.6
github.com/gogf/gf/v2 v2.5.6
github.com/qiniu/qmgo v1.1.7
github.com/satori/go.uuid v1.2.0
github.com/segmentio/kafka-go v0.4.40
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7a
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.5 h1:P1dJmEhyEVVkSXbeP8ge2jxA2lZrch2cZCSOxgTT0X8=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.5/go.mod h1:R6tDeHWP3kpApZtOrVbj/tP7dtwcFHmhFFqnIlQh+yU=
github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.5 h1:c8cv5EQdGHFYAms+7DCHg5p1LLrP2au1eMmfPcuB79o=
github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.5/go.mod h1:2aENeWXI1LRl1cmGmByEn12FlfC2t5PchYvNUTHRIJs=
github.com/gogf/gf/contrib/sdk/httpclient/v2 v2.5.5 h1:xMUSUwWUhP5wkaNL4IC6RZHl4AsO6FZ5i5vB1WHjgpY=
github.com/gogf/gf/contrib/sdk/httpclient/v2 v2.5.5/go.mod h1:BmcK6w/DfdblesXFZmx8Att8THiO9wXo9agRW1DMkSc=
github.com/gogf/gf/v2 v2.5.5 h1:av3xMltrJiZWs4lW5KUTTDh45qg3wUV33W5OebE+pYo=
github.com/gogf/gf/v2 v2.5.5/go.mod h1:17K/gBYrp0bHGC3XYC7bSPoywmZ6MrZHrZakTfh4eIQ=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.6 h1:oR9F4LVoKa/fjf/o6Y/CQRNiYy35Bszo07WwvMWYMxo=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.6/go.mod h1:gvHSRqCpv2c+N0gDHsEldHgU/yM9tcCBdIEKZ32/TaE=
github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.6 h1:JPhmDok7Q85TB2TOJhhJUz3U3U/4GUES1SXhuSnwjSw=
github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.6/go.mod h1:gwY76zchpp+xhS+akLTORyMGkI3CXA1CoQFeS3PeF4w=
github.com/gogf/gf/contrib/sdk/httpclient/v2 v2.5.6 h1:AEyO5D1tLEPt2oHFxjpm7mwP6OqxvMoDdw0qPjQupS0=
github.com/gogf/gf/contrib/sdk/httpclient/v2 v2.5.6/go.mod h1:GwJNtgcXU9Aks6acjKJ2a1FBqHdxHqqfvkNU3OCOPzE=
github.com/gogf/gf/v2 v2.5.6 h1:a1UK1yUP3s+l+vPxmV91+8gTarAP9b1IEOw0W7LNl6E=
github.com/gogf/gf/v2 v2.5.6/go.mod h1:17K/gBYrp0bHGC3XYC7bSPoywmZ6MrZHrZakTfh4eIQ=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand Down
13 changes: 7 additions & 6 deletions hack/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ gfcli:
path: "./bin" # 编译生成的二进制文件的存放目录. 生成的二进制名称默认与程序入口go文件同名
arch: "amd64"
system: "linux,darwin"
# 将项目需要的配置文件打包进二进制, 这样项目部署的时候就可以不用拷贝配置文件了
# NOTE: 1) 如果开启了打包功能, 但要想再使用外部配置文件,
# 需要通过环境变量GF_GCFG_FILE或-c参数指定配置文件的绝对路径(不能是相对路径).
# 将项目需要的配置文件打包进二进制, 这样项目部署的时候就可以不用拷贝配置文件了.
# NOTE: 1) 如果开启了打包功能, 但还是想再使用外部配置文件,
# 需要通过环境变量GF_GCFG_FILE或-c参数指定配置文件路径.
# 例如
# GF_GCFG_FILE=./config.prod.yaml ./gf2-demo-api
# 或: ./gf2-demo-api -c ./config.prod.yaml
# 2) 使用外部配置文件的好处: 可以不用重新编译变更配置文件内容, 支持配置文件热更新.
# 3) 使用外部配置文件的缺点: 配置文件的变化没有经过版本管理, 出现问题不方便回溯历史.
packSrc: "manifest/config"
extra: ""
# 编译时的内置变量可以在运行时通过gbuild包获取, 比如: utility/version.go
varMap:
# NOTE: 1) `version` was generated by `make build`, Do Not Edit
# 2) You can manage versions by `git tag vX.X.X`
version: v0.14.0-6-gd4f8a93
# NOTE: 1) `version` is used by `make build` to generate binary version. Do Not Edit.
# 2) You can manage the project versions by command `git tag vX.X.X`
version:

gen:
# doc: https://goframe.org/pages/viewpage.action?pageId=3673173
Expand Down

0 comments on commit 02c418f

Please sign in to comment.