11#! /usr/bin/env bash
22
3- # Function to detect OS and set sed parameters
4- setup_sed () {
3+ # Function to run sed in-place with OS-specific options
4+ sed_inplace () {
55 if [[ " $OSTYPE " == " darwin" * ]]; then
6- # macOS
7- SED_INPLACE= " sed -i ''"
6+ # macOS - requires empty string after -i
7+ sed -i ' ' " $@ "
88 else
99 # Linux/Windows Git Bash
10- SED_INPLACE= " sed -i"
10+ sed -i " $@ "
1111 fi
1212}
1313
14- # Initialize sed command
15- setup_sed
16-
1714if [ $# -ne 2 ]; then
1815 echo " Parameter exception, please execute in the format of $0 [directory] [version number]"
1916 echo " PS:$0 ./ v2.4.0"
4340
4441if [[ true ]]; then
4542 # Use sed to replace the version number in version.go
46- $SED_INPLACE ' s/VERSION = ".*"/VERSION = "' ${newVersion} ' "/' version.go
43+ sed_inplace ' s/VERSION = ".*"/VERSION = "' ${newVersion} ' "/' version.go
4744
4845 # Use sed to replace the version number in README.MD
49- $SED_INPLACE ' s/version=[^"]*/version=' ${newVersion} ' /' README.MD
46+ sed_inplace ' s/version=[^"]*/version=' ${newVersion} ' /' README.MD
47+ sed_inplace ' s/version=[^"]*/version=' ${newVersion} ' /' README.zh_CN.MD
5048fi
5149
5250if [ -f " go.work" ]; then
@@ -70,6 +68,8 @@ for file in `find ${workdir} -name go.mod`; do
7068 fi
7169
7270 cd $goModPath
71+
72+ # Add replace directive for local development.
7373 if [ $goModPath = " ./cmd/gf" ]; then
7474 mv go.work go.work.version.bak
7575 go mod edit -replace github.com/gogf/gf/v2=../../
@@ -81,20 +81,20 @@ for file in `find ${workdir} -name go.mod`; do
8181 go mod edit -replace github.com/gogf/gf/contrib/drivers/sqlite/v2=../../contrib/drivers/sqlite
8282 fi
8383 # Remove indirect dependencies
84- sed -i ' /\/\/ indirect/d' go.mod
84+ sed_inplace ' /\/\/ indirect/d' go.mod
8585 go mod tidy
8686 # Remove toolchain line if exists
87- $SED_INPLACE ' /^toolchain/d' go.mod
87+ sed_inplace ' /^toolchain/d' go.mod
8888
89- # Upgrading only GoFrame related libraries, sometimes even if a version number is specified,
89+ # Upgrading only GoFrame related libraries, sometimes even if a version number is specified,
9090 # it may not be possible to successfully upgrade. Please confirm before submitting the code
9191 go list -f " {{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion} {{end}}" -m all | grep " ^github.com/gogf/gf"
92- go list -f " {{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion} {{end}}" -m all | grep " ^github.com/gogf/gf" | xargs -L1 go get -v
92+ go list -f " {{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion} {{end}}" -m all | grep " ^github.com/gogf/gf" | xargs -L1 go get -v
9393 # Remove indirect dependencies
94- sed -i ' /\/\/ indirect/d' go.mod
94+ sed_inplace ' /\/\/ indirect/d' go.mod
9595 go mod tidy
9696 # Remove toolchain line if exists
97- $SED_INPLACE ' /^toolchain/d' go.mod
97+ sed_inplace ' /^toolchain/d' go.mod
9898 if [ $goModPath = " ./cmd/gf" ]; then
9999 go mod edit -dropreplace github.com/gogf/gf/v2
100100 go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/clickhouse/v2
0 commit comments