From 7b2f96762677fc398bcf3c017e2b9632cb89b1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=88=9F?= Date: Thu, 1 Apr 2021 09:22:28 +0800 Subject: [PATCH] add tool scripts --- README.md | 1 + README_EN.md | 1 + tool/bump-to-next-release.sh | 23 ++++++++++++++++ tool/generate-snapshot-release.sh | 45 +++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100755 tool/bump-to-next-release.sh create mode 100755 tool/generate-snapshot-release.sh diff --git a/README.md b/README.md index 3147908..7822fc6 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ |-- testable-agent ➜ JavaAgent模块,提供Mock测试相关功能 |-- testable-core ➜ 基础功能模块,提供Mock相关注解和工具类 |-- testable-maven-plugin ➜ Maven插件模块,用于简化JavaAgent注入 +|-- tool ➜ 项目开发过程中的工具脚本 |-- demo | |-- java-demo ➜ Java语言的示例代码 | `-- kotlin-demo ➜ Kotlin语言的示例代码 diff --git a/README_EN.md b/README_EN.md index 94711dc..f3c55a8 100644 --- a/README_EN.md +++ b/README_EN.md @@ -24,6 +24,7 @@ Usage Document: https://alibaba.github.io/testable-mock/#/en-us/ |-- testable-agent ➜ JavaAgent module, provides test mocking related functions |-- testable-core ➜ Basic function module, provides mock related class and annotation |-- testable-maven-plugin ➜ Maven plugin module, for simplify JavaAgent injection +|-- tool ➜ Scripts for project maintain |-- demo | |-- java-demo ➜ Java code example | `-- kotlin-demo ➜ Kotlin code example diff --git a/tool/bump-to-next-release.sh b/tool/bump-to-next-release.sh new file mode 100755 index 0000000..89b44b5 --- /dev/null +++ b/tool/bump-to-next-release.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Release next version + +VERSION=$(cat testable-parent/pom.xml | grep '' | sed -e 's/^.*>\([^<]*\)<.*$/\1/g') +echo "Current version is: ${VERSION}" +read -p "Next version should be: " NEXT + +for pom in testable-all/pom.xml testable-maven-plugin/pom.xml testable-processor/pom.xml testable-agent/pom.xml testable-core/pom.xml testable-parent/pom.xml; do + sed -i '' "s/${VERSION}<\/version>/${NEXT}<\/version>/" $pom +done +for gradle in demo/java-demo/build.gradle demo/kotlin-demo/build.gradle.kts; do + sed -i '' "s/testable-\([a-z]*\):${VERSION}/testable-\1:${NEXT}/" $gradle +done +for pom in testable-parent/pom.xml demo/java-demo/pom.xml demo/kotlin-demo/pom.xml; do + sed -i '' "s/${VERSION}<\/testable.version>/${NEXT}<\/testable.version>/" $pom +done +for md in docs/zh-cn/doc/setup.md docs/en-us/doc/setup.md; do + sed -i '' "s/${VERSION}/${NEXT}/" $md +done + +echo "Done. Please setup maven configuration for sonatype, and manually run \"mvn clean deploy -Prelease\"" +echo "Then commit the new version with \"git add . && git commit -m 'release v${VERSION}' && git tag v${VERSION} && git push --tag\"" diff --git a/tool/generate-snapshot-release.sh b/tool/generate-snapshot-release.sh new file mode 100755 index 0000000..b2001a6 --- /dev/null +++ b/tool/generate-snapshot-release.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Release SNAPSHOT version + +if [ "${SNAPSHOT_MVN_REPO}" = "" ]; then + echo "\"SNAPSHOT_MVN_REPO\" environment variable should be setup before execution" + exit -1 +fi + +VERSION=$(cat testable-parent/pom.xml | grep '' | sed -e 's/^.*>\([^<]*\)<.*$/\1/g') +MAJOR_VERSION=$(echo $VERSION | sed 's/^\(.*\)\.[0-9]\{1,\}.*/\1/g') +declare -i MINOR_VERSION=$(echo $VERSION | sed 's/^.*\.\([0-9]\{1,\}\)/\1/g') +MINOR_VERSION=$MINOR_VERSION+1 +SNAPSHOT="${MAJOR_VERSION}.${MINOR_VERSION}-SNAPSHOT" + +echo "Current version: ${VERSION}" +echo "Next snapshot version: ${SNAPSHOT}" +read -p "Confirm (Y/N) ? " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 + + +sed -i '' '/<\/profiles>/,$d' testable-parent/pom.xml +cat << EOF >> testable-parent/pom.xml + + snapshot + + + releases + http://${SNAPSHOT_MVN_REPO}/mvn/releases + + + snapshots + http://${SNAPSHOT_MVN_REPO}/mvn/snapshots + + + + + +EOF + +for pom in testable-all/pom.xml testable-maven-plugin/pom.xml testable-processor/pom.xml testable-agent/pom.xml testable-core/pom.xml testable-parent/pom.xml; do + sed -i '' "s#${VERSION}#${SNAPSHOT}#g" $pom +done +sed -i '' "s#${VERSION}#${SNAPSHOT}#g" testable-parent/pom.xml + +echo "Done. Please setup maven configuration for snapshot repository and manually run \"mvn clean deploy -Psnapshot\""