-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tcp-server deps error
- Loading branch information
Showing
4 changed files
with
220 additions
and
134 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
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,162 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# | ||
|
||
#set -e | ||
|
||
# import common functions | ||
source "$(dirname $0)/common-func.sh" | ||
|
||
function show_help() { | ||
binName="bash $(basename $0)" | ||
|
||
cat <<EOF | ||
Release all sub-repo to new tag version and push to remote repo | ||
Usage: | ||
${binName} [-t VERSION] [NAME ...] | ||
Options: | ||
-a Release all components | ||
-t <version> Specifies the version number to be published, | ||
without specifying the automatic calculation of the next version. | ||
eg: v2.0.4 | ||
-y No confirmation required | ||
-h, --help Display the help information | ||
Example: | ||
${binName} -a Release all components, will auto calc next version | ||
${binName} -t v2.0.4 -a Release all components, use user input version | ||
${binName} -t v2.0.4 event Release one component | ||
${binName} -t v2.0.4 event stdlib Release multi components | ||
EOF | ||
exit 0 | ||
} | ||
|
||
# 显示帮助 | ||
[[ "$1" = "" || "$1" = "-h" || "$1" = "--help" ]] && show_help | ||
|
||
RELEASE_TAG=AUTO | ||
NEED_CONFIRM=Y | ||
|
||
# parse input options | ||
# ref https://www.cnblogs.com/yxzfscg/p/5338775.html | ||
while getopts "t:ahy" arg; do #选项后面的冒号表示该选项需要参数 | ||
case ${arg} in | ||
a) | ||
COMPONENTS=$(ls src/) ;; | ||
h) | ||
show_help ;; | ||
y) | ||
NEED_CONFIRM=N ;; | ||
t) | ||
RELEASE_TAG=$OPTARG ;; | ||
?) #当有不认识的选项的时候arg为? | ||
echo "Missing argument" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
shift $(($OPTIND - 1)) | ||
|
||
TARGET_BRANCH=master | ||
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` | ||
#CURRENT_BRANCH=master | ||
|
||
[[ -n "$@" ]] && COMPONENTS=$@ | ||
|
||
if [[ -z "${COMPONENTS}" ]]; then | ||
colored_text "Please input want released component names or use option: -a" red | ||
exit 1 | ||
fi | ||
|
||
echo "Will released version: ${RELEASE_TAG}" | ||
echo "Will released projects:" | ||
echo " " ${COMPONENTS} | ||
#colored_text "${COMPONENTS}" | ||
|
||
if [[ "$NEED_CONFIRM" = "Y" ]]; then | ||
if ! user_confirm "Continue"; then | ||
colored_text "Good Bye" | ||
exit 0 | ||
fi | ||
fi | ||
|
||
TMP_DIR="/tmp/release-components-git" | ||
|
||
yellow_text "> rm -rf ${TMP_DIR} && mkdir ${TMP_DIR}" | ||
rm -rf ${TMP_DIR} && mkdir ${TMP_DIR}; | ||
#pwd | ||
yellow_text "> cp -R $(pwd)/. ${TMP_DIR}" | ||
cp -R $(pwd)/. ${TMP_DIR} | ||
#cd ${TMP_DIR} && git checkout . && pwd; | ||
cd ${TMP_DIR} && git checkout . && pwd; | ||
|
||
for LIB_NAME in ${COMPONENTS} ; do | ||
colored_text "\n====== Releasing the component:【${LIB_NAME}】" cyan | ||
|
||
# REMOTE_URL=`git remote get-url ${LIB_NAME}` | ||
# REMOTE_URL="[email protected]:swoft-cloud/swoft-${LIB_NAME}.git" | ||
|
||
colored_text "Check sub-component remote" | ||
yellow_text "> git remote -v | grep ${LIB_NAME}" | ||
REMOTE_INFO=`git remote -v | grep ${LIB_NAME}` | ||
|
||
if [[ -z "$REMOTE_INFO" ]]; then | ||
red_text "Not found remote for the component: ${LIB_NAME}" | ||
continue | ||
fi | ||
|
||
yellow_text "> git pull ${LIB_NAME}" | ||
git pull ${LIB_NAME}; | ||
|
||
NEW_BRANCH=${LIB_NAME}-master | ||
|
||
yellow_text "> git checkout -b ${NEW_BRANCH} ${LIB_NAME}/master" | ||
git checkout -b ${NEW_BRANCH} ${LIB_NAME}/master; | ||
|
||
yellow_text "> git pull ${LIB_NAME} ${TARGET_BRANCH}" | ||
git pull ${LIB_NAME} ${TARGET_BRANCH}; | ||
|
||
# like: v2.0.0 | ||
LAST_RELEASE=$(git describe --tags $(git rev-list --tags --max-count=1)) | ||
|
||
# this is first release | ||
if [[ -z "$LAST_RELEASE" ]]; then | ||
if [[ "$RELEASE_TAG" = "AUTO" ]]; then | ||
read -p "Please input release tag version: " RELEASE_TAG | ||
fi | ||
|
||
colored_text "There has not been any releases. Releasing $RELEASE_TAG"; | ||
else | ||
# auto find next version tag | ||
if [[ "$RELEASE_TAG" = "AUTO" ]]; then | ||
RELEASE_TAG=$(php dtool.php git:tag --only-tag --next-tag ${LAST_RELEASE}) | ||
fi | ||
|
||
echo "Last release $LAST_RELEASE"; | ||
|
||
CHANGES_SINCE_LAST_RELEASE=$(git log --oneline --decorate "$LAST_RELEASE"...master) | ||
|
||
if [[ ! -z "$CHANGES_SINCE_LAST_RELEASE" ]]; then | ||
colored_text "There are changes since last release. Releasing $RELEASE_TAG"; | ||
else | ||
blue_text "No any change since last release. Skip release"; | ||
continue | ||
fi | ||
fi | ||
|
||
# git tag $1 -s -m "Release $RELEASE_TAG" | ||
yellow_text "> git tag -a $1 -m \"Release $RELEASE_TAG\"" | ||
git tag -a ${RELEASE_TAG} -m "Release $RELEASE_TAG"; | ||
|
||
yellow_text "> git push $LIB_NAME origin $RELEASE_TAG" | ||
git push ${LIB_NAME} ${RELEASE_TAG}; | ||
done | ||
|
||
yellow_text "> git checkout ${CURRENT_BRANCH}" | ||
git checkout ${CURRENT_BRANCH} | ||
|
||
colored_text "\nRelease Completed!" |
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 |
---|---|---|
@@ -1,162 +1,80 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# | ||
|
||
#set -e | ||
|
||
# import common functions | ||
source "$(dirname $0)/common-func.sh" | ||
|
||
function show_help() { | ||
binName="bash $(basename $0)" | ||
|
||
cat <<EOF | ||
Release all sub-repo to new tag version and push to remote repo | ||
Usage: | ||
${binName} [-t VERSION] [NAME ...] | ||
# TODO with release message | ||
|
||
Options: | ||
-a Release all components | ||
-t <version> Specifies the version number to be published, | ||
without specifying the automatic calculation of the next version. | ||
eg: v2.0.4 | ||
-y No confirmation required | ||
-h, --help Display the help information | ||
set -e | ||
|
||
Example: | ||
${binName} -a Release all components, will auto calc next version | ||
${binName} -t v2.0.4 -a Release all components, use user input version | ||
${binName} -t v2.0.4 event Release one component | ||
${binName} -t v2.0.4 event stdlib Release multi components | ||
binName="bash $(basename $0)" | ||
|
||
EOF | ||
if [[ -z "$1" ]] | ||
then | ||
echo "Release all sub-repo to new tag version and push to remote repo" | ||
echo -e "Usage:\n $binName VERSION" | ||
echo "Example:" | ||
echo " $binName v1.0.0 Tag for all sub-repos and push to remote repo" | ||
echo " $binName v1.0.0 http-server Tag for one sub-repo and push to remote repo" | ||
exit 0 | ||
} | ||
|
||
# 显示帮助 | ||
[[ "$1" = "" || "$1" = "-h" || "$1" = "--help" ]] && show_help | ||
|
||
RELEASE_TAG=AUTO | ||
NEED_CONFIRM=Y | ||
|
||
# parse input options | ||
# ref https://www.cnblogs.com/yxzfscg/p/5338775.html | ||
while getopts "t:ahy" arg; do #选项后面的冒号表示该选项需要参数 | ||
case ${arg} in | ||
a) | ||
COMPONENTS=$(ls src/) ;; | ||
h) | ||
show_help ;; | ||
y) | ||
NEED_CONFIRM=N ;; | ||
t) | ||
RELEASE_TAG=$OPTARG ;; | ||
?) #当有不认识的选项的时候arg为? | ||
echo "Missing argument" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
shift $(($OPTIND - 1)) | ||
fi | ||
|
||
RELEASE_TAG=$1 | ||
TARGET_BRANCH=master | ||
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` | ||
#CURRENT_BRANCH=master | ||
|
||
[[ -n "$@" ]] && COMPONENTS=$@ | ||
SUB_REPOS=$2 | ||
|
||
if [[ -z "${COMPONENTS}" ]]; then | ||
colored_text "Please input want released component names or use option: -a" red | ||
exit 1 | ||
if [[ -z "$2" ]]; then | ||
SUB_REPOS=$(ls src/) | ||
fi | ||
|
||
echo "Will released version: ${RELEASE_TAG}" | ||
echo "Will released projects:" | ||
echo " " ${COMPONENTS} | ||
#colored_text "${COMPONENTS}" | ||
|
||
if [[ "$NEED_CONFIRM" = "Y" ]]; then | ||
if ! user_confirm "Continue"; then | ||
colored_text "Good Bye" | ||
exit 0 | ||
fi | ||
fi | ||
|
||
TMP_DIR="/tmp/release-components-git" | ||
echo ${SUB_REPOS} | ||
|
||
yellow_text "> rm -rf ${TMP_DIR} && mkdir ${TMP_DIR}" | ||
rm -rf ${TMP_DIR} && mkdir ${TMP_DIR}; | ||
#pwd | ||
yellow_text "> cp -R $(pwd)/. ${TMP_DIR}" | ||
cp -R $(pwd)/. ${TMP_DIR} | ||
#cd ${TMP_DIR} && git checkout . && pwd; | ||
cd ${TMP_DIR} && git checkout . && pwd; | ||
TMP_DIR="/tmp/swoft-repos" | ||
|
||
for LIB_NAME in ${COMPONENTS} ; do | ||
colored_text "\n====== Releasing the component:【${LIB_NAME}】" cyan | ||
for LIB_NAME in ${SUB_REPOS} ; do | ||
echo "" | ||
echo "====== Releasing the component:【${LIB_NAME}】" | ||
|
||
# REMOTE_URL=`git remote get-url ${LIB_NAME}` | ||
# REMOTE_URL="[email protected]:swoft-cloud/swoft-${LIB_NAME}.git" | ||
REMOTE_URL="[email protected]:swoft-cloud/swoft-${LIB_NAME}.git" | ||
|
||
colored_text "Check sub-component remote" | ||
yellow_text "> git remote -v | grep ${LIB_NAME}" | ||
REMOTE_INFO=`git remote -v | grep ${LIB_NAME}` | ||
echo "> rm -rf ${TMP_DIR} && mkdir ${TMP_DIR}"; | ||
rm -rf ${TMP_DIR} && mkdir ${TMP_DIR}; | ||
|
||
if [[ -z "$REMOTE_INFO" ]]; then | ||
red_text "Not found remote for the component: ${LIB_NAME}" | ||
continue | ||
fi | ||
( | ||
cd ${TMP_DIR}; | ||
echo "Begin clone ${REMOTE_URL} to ${TMP_DIR}" | ||
git clone ${REMOTE_URL} . --depth=200 | ||
git checkout ${CURRENT_BRANCH}; | ||
|
||
yellow_text "> git pull ${LIB_NAME}" | ||
git pull ${LIB_NAME}; | ||
# like: v2.0.0 | ||
LAST_RELEASE=$(git describe --tags $(git rev-list --tags --max-count=1)) | ||
|
||
NEW_BRANCH=${LIB_NAME}-master | ||
if [[ -z "$LAST_RELEASE" ]]; then | ||
echo "There has not been any releases. Releasing $1"; | ||
|
||
yellow_text "> git checkout -b ${NEW_BRANCH} ${LIB_NAME}/master" | ||
git checkout -b ${NEW_BRANCH} ${LIB_NAME}/master; | ||
|
||
yellow_text "> git pull ${LIB_NAME} ${TARGET_BRANCH}" | ||
git pull ${LIB_NAME} ${TARGET_BRANCH}; | ||
|
||
# like: v2.0.0 | ||
LAST_RELEASE=$(git describe --tags $(git rev-list --tags --max-count=1)) | ||
|
||
# this is first release | ||
if [[ -z "$LAST_RELEASE" ]]; then | ||
if [[ "$RELEASE_TAG" = "AUTO" ]]; then | ||
read -p "Please input release tag version: " RELEASE_TAG | ||
fi | ||
|
||
colored_text "There has not been any releases. Releasing $RELEASE_TAG"; | ||
else | ||
# auto find next version tag | ||
if [[ "$RELEASE_TAG" = "AUTO" ]]; then | ||
RELEASE_TAG=$(php dtool.php git:tag --only-tag --next-tag ${LAST_RELEASE}) | ||
fi | ||
# git tag $1 -s -m "Release $1" | ||
git tag -a $1 -m "Release $1" | ||
git push origin --tags | ||
else | ||
echo "Last release $LAST_RELEASE"; | ||
|
||
echo "Last release $LAST_RELEASE"; | ||
CHANGES_SINCE_LAST_RELEASE=$(git log --oneline --decorate "$LAST_RELEASE"...master) | ||
|
||
CHANGES_SINCE_LAST_RELEASE=$(git log --oneline --decorate "$LAST_RELEASE"...master) | ||
if [[ ! -z "$CHANGES_SINCE_LAST_RELEASE" ]]; then | ||
echo "There are changes since last release. Releasing $1"; | ||
|
||
if [[ ! -z "$CHANGES_SINCE_LAST_RELEASE" ]]; then | ||
colored_text "There are changes since last release. Releasing $RELEASE_TAG"; | ||
else | ||
blue_text "No any change since last release. Skip release"; | ||
continue | ||
# git tag $1 -s -m "Release $1" | ||
git tag -a $1 -m "Release $1" | ||
git push origin --tags | ||
else | ||
echo "No change since last release."; | ||
fi | ||
fi | ||
fi | ||
|
||
# git tag $1 -s -m "Release $RELEASE_TAG" | ||
yellow_text "> git tag -a $1 -m \"Release $RELEASE_TAG\"" | ||
git tag -a ${RELEASE_TAG} -m "Release $RELEASE_TAG"; | ||
|
||
yellow_text "> git push $LIB_NAME origin $RELEASE_TAG" | ||
git push ${LIB_NAME} ${RELEASE_TAG}; | ||
) | ||
done | ||
|
||
yellow_text "> git checkout ${CURRENT_BRANCH}" | ||
git checkout ${CURRENT_BRANCH} | ||
|
||
colored_text "\nRelease Completed!" | ||
echo "" | ||
echo "Completed!" | ||
exit |
Oops, something went wrong.