diff --git a/.github/workflows/scripts/update_version.sh b/.github/workflows/scripts/update_version.sh new file mode 100644 index 000000000..ed868e1f9 --- /dev/null +++ b/.github/workflows/scripts/update_version.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Check if the number of parameters is 2 +if [ $# -ne 2 ]; then + echo "Invalid parameters, please execute in format: version.sh [directory] [version]" + echo "Example: version.sh ./contrib v1.0.0" + exit 1 +fi + +# Check if the first parameter is a directory and exists +if [ ! -d "$1" ]; then + echo "Error: Directory does not exist" + exit 1 +fi + +# Check if the second parameter starts with 'v' +if [[ "$2" != v* ]]; then + echo "Error: Version number does not start with 'v'" + exit 1 +fi + +workdir=$1 +newVersion=$2 +echo "Preparing to replace version numbers in all go.mod files under ${workdir} directory to ${newVersion}" + + +# Check if file exists +if [ -f "go.work" ]; then + # File exists, rename it + mv go.work go.work.${newVersion} + echo "Backup 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 + 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.${newVersion}" ]; then + # File exists, rename it back + mv go.work.${newVersion} go.work + echo "Restore go.work file" +fi \ No newline at end of file diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index a368fc7cc..857d458b4 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -4,13 +4,12 @@ on: push: # Sequence of patterns matched against refs/tags tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 env: TZ: Asia/Shanghai GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - jobs: build: name: Auto Creating Tags @@ -18,22 +17,43 @@ jobs: steps: - name: Checkout Github Code uses: actions/checkout@v5 - - name: Auto Creating Tags For Contrib Packages run: | git config --global user.email "tagrobot@goframe.org" git config --global user.name "TagRobot" - # auto create tags for contrib packages. for file in `find contrib -name go.mod`; do - tag=$(dirname $file)/$GITHUB_REF_NAME + tag=$(dirname $file)/${{ github.ref_name }} git tag $tag git push origin $tag done - + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + with: + commit-message: 'update gf cli to ${{ github.ref_name }}' + title: 'fix: update gf cli to ${{ github.ref_name }}' + base: master + branch: fix/${{ github.ref_name }} + delete-branch: true + - name: Commit & Push changes + uses: actions-js/push@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: fix/${{ github.ref_name }} + author_name: TagRobot + author_email: tagrobot@goframe.org + message: 'fix: update gf cli to ${{ github.ref_name }}' + - name: update dependencies + run: | + go env -w GOPRIVATE=github.com/gogf/gf + .github/workflows/scripts/update_version.sh ./cmd/gfly ${{ github.ref_name }} + - name: Auto Creating Tags For cli tool + run: | + git config --global user.email "tagrobot@goframe.org" + git config --global user.name "TagRobot" # auto create tag for cli tool for file in `find cmd -name go.mod`; do - tag=$(dirname $file)/$GITHUB_REF_NAME + tag=$(dirname $file)/${{ github.ref_name }} git tag $tag git push origin $tag done diff --git a/.make_version.sh b/.make_version.sh index 95f9de8fe..14e314d0e 100755 --- a/.make_version.sh +++ b/.make_version.sh @@ -1,4 +1,19 @@ #!/usr/bin/env bash + +# Function to detect OS and set sed parameters +setup_sed() { + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + SED_INPLACE="sed -i ''" + else + # Linux/Windows Git Bash + SED_INPLACE="sed -i" + fi +} + +# Initialize sed command +setup_sed + if [ $# -ne 2 ]; then echo "Parameter exception, please execute in the format of $0 [directory] [version number]" echo "PS:$0 ./ v2.4.0" @@ -28,10 +43,10 @@ fi if [[ true ]]; then # Use sed to replace the version number in version.go - sed -i '' 's/VERSION = ".*"/VERSION = "'${newVersion}'"/' version.go + $SED_INPLACE 's/VERSION = ".*"/VERSION = "'${newVersion}'"/' version.go # Use sed to replace the version number in README.MD - sed -i '' 's/version=[^"]*/version='${newVersion}'/' README.MD + $SED_INPLACE 's/version=[^"]*/version='${newVersion}'/' README.MD fi if [ -f "go.work" ]; then @@ -67,7 +82,7 @@ for file in `find ${workdir} -name go.mod`; do fi go mod tidy # Remove toolchain line if exists - sed -i '' '/^toolchain/d' go.mod + $SED_INPLACE '/^toolchain/d' go.mod # Upgrading only GoFrame related libraries, sometimes even if a version number is specified, # it may not be possible to successfully upgrade. Please confirm before submitting the code @@ -75,7 +90,7 @@ for file in `find ${workdir} -name go.mod`; do 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 # Remove toolchain line if exists - sed -i '' '/^toolchain/d' go.mod + $SED_INPLACE '/^toolchain/d' go.mod if [ $goModPath = "./cmd/gf" ]; then go mod edit -dropreplace github.com/gogf/gf/v2 go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/clickhouse/v2 diff --git a/README.MD b/README.MD index 740065fca..11b3d636d 100644 --- a/README.MD +++ b/README.MD @@ -38,7 +38,7 @@ A powerful framework for faster, easier, and more efficient project development. 💖 [Thanks to all the contributors who made GoFrame possible](https://github.com/gogf/gf/graphs/contributors) 💖 -goframe contributors +goframe contributors # License diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index 93685b543..b252cddfe 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/nacos/v2 go 1.23.0 require ( - github.com/gogf/gf/v2 v2.9.0 + github.com/gogf/gf/v2 v2.9.2 github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 )