add tool scripts

This commit is contained in:
金戟 2021-04-01 09:22:28 +08:00
parent e0a4a39d55
commit 7b2f967626
4 changed files with 70 additions and 0 deletions

View File

@ -32,6 +32,7 @@
|-- testable-agent ➜ JavaAgent模块提供Mock测试相关功能
|-- testable-core ➜ 基础功能模块提供Mock相关注解和工具类
|-- testable-maven-plugin ➜ Maven插件模块用于简化JavaAgent注入
|-- tool ➜ 项目开发过程中的工具脚本
|-- demo
| |-- java-demo ➜ Java语言的示例代码
| `-- kotlin-demo ➜ Kotlin语言的示例代码

View File

@ -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

23
tool/bump-to-next-release.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# Release next version
VERSION=$(cat testable-parent/pom.xml | grep '<testable.version>' | 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}<\/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/<testable.version>${VERSION}<\/testable.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\""

View File

@ -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 '<testable.version>' | 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
<profile>
<id>snapshot</id>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://${SNAPSHOT_MVN_REPO}/mvn/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://${SNAPSHOT_MVN_REPO}/mvn/snapshots</url>
</snapshotRepository>
</distributionManagement>
</profile>
</profiles>
</project>
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>${VERSION}</version>#<version>${SNAPSHOT}</version>#g" $pom
done
sed -i '' "s#<testable.version>${VERSION}</testable.version>#<testable.version>${SNAPSHOT}</testable.version>#g" testable-parent/pom.xml
echo "Done. Please setup maven configuration for snapshot repository and manually run \"mvn clean deploy -Psnapshot\""