mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
50
.github/workflows/scripts/update_version.sh
vendored
Normal file
50
.github/workflows/scripts/update_version.sh
vendored
Normal file
@ -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
|
||||
34
.github/workflows/tag.yml
vendored
34
.github/workflows/tag.yml
vendored
@ -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
|
||||
|
||||
Reference in New Issue
Block a user