-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve command
make version
(gogf#2676)
- Loading branch information
Showing
2 changed files
with
55 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ $# -ne 2 ]; then | ||
echo "Parameter exception, please execute in the format of $0 [directory] [version number]" | ||
echo "PS:$0 ./ v2.4.0" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "$1" ]; then | ||
echo "Error: Directory does not exist" | ||
exit 1 | ||
fi | ||
|
||
if [[ "$2" != v* ]]; then | ||
echo "Error: Version number must start with v" | ||
exit 1 | ||
fi | ||
|
||
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 [[ true ]]; 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 "Back up the go.work file to avoid affecting the upgrade" | ||
fi | ||
|
||
for file in `find ${workdir} -name go.mod`; do | ||
goModPath=$(dirname $file) | ||
echo "" | ||
echo "processing dir: $goModPath" | ||
cd $goModPath | ||
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 | ||
go mod tidy | ||
cd - | ||
done | ||
|
||
if [ -f "go.work.version.bak" ]; then | ||
mv go.work.version.bak go.work | ||
echo "Restore the go.work file" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters