From f6893af6bc3a109b8ba19a44d880bb7309e14442 Mon Sep 17 00:00:00 2001 From: HaiLaz <739476267@qq.com> Date: Wed, 31 May 2023 07:24:48 +0000 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E8=BF=81=E7=A7=BBmake=20version?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E5=88=B0=E8=84=9A=E6=9C=AC=E5=B9=B6=E5=81=9A?= =?UTF-8?q?=E4=BA=86=E4=B8=80=E4=BA=9B=E5=88=A4=E6=96=AD=E5=92=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/set_version.sh | 59 ++++++++++++++++++++++++++++++++ Makefile | 28 ++------------- 2 files changed, 61 insertions(+), 26 deletions(-) create mode 100755 .github/workflows/set_version.sh diff --git a/.github/workflows/set_version.sh b/.github/workflows/set_version.sh new file mode 100755 index 00000000000..17ca65538a6 --- /dev/null +++ b/.github/workflows/set_version.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# 判断参数个数是否为2 +if [ $# -ne 2 ]; then + echo "参数异常,请以$0 [目录] [版本号]的格式执行" + echo "例如:$0 ./contrib v1.0.0" + exit 1 +fi + +# 判断第一个参数是否为目录并存在 +if [ ! -d "$1" ]; then + echo "错误:目录不存在" + exit 1 +fi + +# 判断第二个参数是否以v开头 +if [[ "$2" != v* ]]; then + echo "错误:版本号不是以v开头" + exit 1 +fi + +workdir=$1 +newVersion=$2 +echo "准备将${workdir}目录下的所有go.mod文件中的gf库版本号替换为${newVersion}" + +if [[ ${workdir} == ./contrib ]]; then + echo "package gf" > version.go + echo "" >> version.go + echo "const (" >> version.go + echo -e "\t// VERSION is the current GoFrame version." >> version.go + echo -e "\tVERSION = \"${newVersion}\"" >> version.go + echo ")" >> version.go +fi + +# 判断文件是否存在 +if [ -f "go.work" ]; then + # 文件存在,重命名 + mv go.work go.work.version.bak + echo "备份go.work文件,以免影响升级" +fi + +for file in `find ${workdir} -name go.mod`; do + goModPath=$(dirname $file) + echo "" + echo "processing dir: $goModPath" + cd $goModPath + go mod tidy + # 只升级gf相关库,有时候就算指定版本号,也不一定能升级成功,提交代码前一定要确认一下 + go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" + go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" | xargs -L1 go get -v + go mod tidy + cd - +done + +if [ -f "go.work.version.bak" ]; then + # 文件存在,重命名 + mv go.work.version.bak go.work + echo "恢复go.work文件" +fi \ No newline at end of file diff --git a/Makefile b/Makefile index b8c6f6f6f09..022e9a95ac7 100644 --- a/Makefile +++ b/Makefile @@ -18,33 +18,9 @@ lint: # make version to=v2.4.0 .PHONY: version version: - $(eval files=$(shell find . -name go.mod)) @set -e; \ newVersion=$(to); \ - echo "The version will be set to $$newVersion"; \ - if [[ $$newVersion =~ "v" ]]; then \ - latestVersion=$$newVersion; \ - echo "package gf" > version.go; \ - echo "" >> version.go; \ - echo "const (" >> version.go; \ - echo -e "\t// VERSION is the current GoFrame version." >> version.go; \ - echo -e "\tVERSION = \"$$latestVersion\"" >> version.go; \ - echo ")" >> version.go; \ - else \ - latestVersion=latest; \ - fi; \ - for file in ${files}; do \ - goModPath=$$(dirname $$file); \ - if [[ $$goModPath =~ "./contrib" || $$goModPath =~ "./cmd/gf" || $$goModPath =~ "./example" ]]; then \ - echo "" ; \ - echo "processing dir: $$goModPath"; \ - cd $$goModPath; \ - go mod tidy; \ - go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@$$latestVersion{{end}}" -m all | grep "^github.com/gogf/gf/contrib" | xargs -L1 go get -v; \ - go get -v github.com/gogf/gf/v2@$$latestVersion; \ - go mod tidy; \ - cd -; \ - fi \ - done + .github/workflows/set_version.sh ./ $$newVersion; \ + echo "make version to=$(to) done" From fa172fa0444186957d1deb276ecf6d77d110a4d4 Mon Sep 17 00:00:00 2001 From: HaiLaz <739476267@qq.com> Date: Fri, 2 Jun 2023 06:54:59 +0000 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E8=BF=81=E7=A7=BBset=5Fversion.sh?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E5=88=B0=E6=A0=B9=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../set_version.sh => .set_version.sh | 22 +++++++------------ Makefile | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) rename .github/workflows/set_version.sh => .set_version.sh (59%) diff --git a/.github/workflows/set_version.sh b/.set_version.sh similarity index 59% rename from .github/workflows/set_version.sh rename to .set_version.sh index 17ca65538a6..2f3f63076ff 100755 --- a/.github/workflows/set_version.sh +++ b/.set_version.sh @@ -1,27 +1,24 @@ #!/usr/bin/env bash -# 判断参数个数是否为2 if [ $# -ne 2 ]; then - echo "参数异常,请以$0 [目录] [版本号]的格式执行" - echo "例如:$0 ./contrib v1.0.0" + echo "Parameter exception, please execute in the format of $0 [directory] [version number]" + echo "PS:$0 ./contrib v1.0.0" exit 1 fi -# 判断第一个参数是否为目录并存在 if [ ! -d "$1" ]; then - echo "错误:目录不存在" + echo "Error: Directory does not exist" exit 1 fi -# 判断第二个参数是否以v开头 if [[ "$2" != v* ]]; then - echo "错误:版本号不是以v开头" + echo "Error: Version number must start with v" exit 1 fi workdir=$1 newVersion=$2 -echo "准备将${workdir}目录下的所有go.mod文件中的gf库版本号替换为${newVersion}" +echo "Prepare to replace the GF library version numbers in all go.mod files in the ${workdir} directory with ${newVersion}" if [[ ${workdir} == ./contrib ]]; then echo "package gf" > version.go @@ -32,11 +29,9 @@ if [[ ${workdir} == ./contrib ]]; then echo ")" >> version.go fi -# 判断文件是否存在 if [ -f "go.work" ]; then - # 文件存在,重命名 mv go.work go.work.version.bak - echo "备份go.work文件,以免影响升级" + echo "Back up the go.work file to avoid affecting the upgrade" fi for file in `find ${workdir} -name go.mod`; do @@ -45,7 +40,7 @@ for file in `find ${workdir} -name go.mod`; do echo "processing dir: $goModPath" cd $goModPath go mod tidy - # 只升级gf相关库,有时候就算指定版本号,也不一定能升级成功,提交代码前一定要确认一下 + # Upgrading only GF related libraries, sometimes even if a version number is specified, it may not be possible to successfully upgrade. Please confirm before submitting the code go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" | xargs -L1 go get -v go mod tidy @@ -53,7 +48,6 @@ for file in `find ${workdir} -name go.mod`; do done if [ -f "go.work.version.bak" ]; then - # 文件存在,重命名 mv go.work.version.bak go.work - echo "恢复go.work文件" + echo "Restore the go.work file" fi \ No newline at end of file diff --git a/Makefile b/Makefile index 022e9a95ac7..2210ebcd91c 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ lint: version: @set -e; \ newVersion=$(to); \ - .github/workflows/set_version.sh ./ $$newVersion; \ + ./.set_version.sh ./ $$newVersion; \ echo "make version to=$(to) done" From 70304f41e024c8e037a0c17e12c80ca7f038f3c5 Mon Sep 17 00:00:00 2001 From: HaiLaz <739476267@qq.com> Date: Fri, 2 Jun 2023 07:27:27 +0000 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E9=BB=98=E8=AE=A4=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .set_version.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.set_version.sh b/.set_version.sh index 2f3f63076ff..adee5165ece 100755 --- a/.set_version.sh +++ b/.set_version.sh @@ -2,7 +2,7 @@ if [ $# -ne 2 ]; then echo "Parameter exception, please execute in the format of $0 [directory] [version number]" - echo "PS:$0 ./contrib v1.0.0" + echo "PS:$0 ./ v2.4.0" exit 1 fi @@ -20,7 +20,7 @@ workdir=$1 newVersion=$2 echo "Prepare to replace the GF library version numbers in all go.mod files in the ${workdir} directory with ${newVersion}" -if [[ ${workdir} == ./contrib ]]; then +if [[ true ]]; then echo "package gf" > version.go echo "" >> version.go echo "const (" >> version.go @@ -39,7 +39,7 @@ for file in `find ${workdir} -name go.mod`; do echo "" echo "processing dir: $goModPath" cd $goModPath - go mod tidy + # go mod tidy # Upgrading only GF related libraries, sometimes even if a version number is specified, it may not be possible to successfully upgrade. Please confirm before submitting the code go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" | xargs -L1 go get -v From 3b3cd33b59902d6290d90d0abd2f10b580f89805 Mon Sep 17 00:00:00 2001 From: HaiLaz <739476267@qq.com> Date: Fri, 2 Jun 2023 09:26:11 +0000 Subject: [PATCH 4/4] fix: 1 --- .set_version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.set_version.sh b/.set_version.sh index adee5165ece..33fc5dba8e5 100755 --- a/.set_version.sh +++ b/.set_version.sh @@ -39,7 +39,7 @@ for file in `find ${workdir} -name go.mod`; do echo "" echo "processing dir: $goModPath" cd $goModPath - # go mod tidy + go mod tidy # Upgrading only GF related libraries, sometimes even if a version number is specified, it may not be possible to successfully upgrade. Please confirm before submitting the code go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" | xargs -L1 go get -v