Skip to content

Commit

Permalink
使用脚本更新版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
intomylife committed Jun 5, 2020
1 parent 70f6c81 commit e4c31de
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ logs/
**/mvnw.cmd
**/.mvn

**/target
**/target

### bak ###
*.versionsBackup
44 changes: 44 additions & 0 deletions growth-version.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@echo off

REM ## 开始
echo [INFO] ----------------------------- start --------------------------------------

REM ## 获取入参,版本号
set new_versiont=%1%
REM ## 输出看一眼
echo new_versiont: %new_versiont%

REM ## 获取入参,是否需要备份(true | false)
set is_bak=%2%
REM ## 输出看一眼
echo is_bak: %is_bak%

REM ## 非空判断
if defined new_versiont (
REM ## 1. 更新 commons 工程版本号
cd osc-commons/
REM ## 获取当前工程的版本号
REM for /f "delims=" %%i in ('..\old-version.bat') do set old_version=%%i
REM ## 输出看一眼
REM echo old_version: %old_version%
REM ## 升级
mvn versions:set -DoldVersion=* -DnewVersion=%new_versiont% -DgenerateBackupPoms=%is_bak% && mvn clean install

REM ## 2. 更新 service 工程中的 commons 工程版本号
cd ../osc-service/
REM ## 获取当前工程的版本号
REM for /f "delims=" %%i in ('..\old-version.bat') do set old_version=%%i
REM ## 输出看一眼
REM echo old_version: %old_version%
REM ## 更新
mvn versions:update-properties -DincludeProperties={osc.commons.version} -Dproperties=[%new_versiont%] -DgenerateBackupPoms=%is_bak%

REM ## 3. 更新 service 工程版本号
mvn versions:set -DoldVersion=* -DnewVersion=%new_versiont% -DgenerateBackupPoms=%is_bak%

REM ## 结束
echo [INFO] ----------------------------- end --------------------------------------
) else (
REM ## 结束
echo [INFO] -------------------------- 缺少参数 -------------------------------------
)
50 changes: 50 additions & 0 deletions growth-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
## $() - 方法,${} - 变量

## 开始
echo [INFO] ----------------------------- start --------------------------------------

## 获取入参,版本号
new_versiont=$1
## 输出看一眼
echo new_versiont: ${new_versiont}

## 获取入参,是否需要备份(true | false)
is_bak=$2
## 输出看一眼
echo is_bak: ${is_bak}

## 非空判断
if [ $new_versiont ];
then

## 1. 更新 commons 工程版本号
cd osc-commons/
## 获取当前工程的版本号
## old_version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
## 输出看一眼
## echo old_version: ${old_version}
## 升级
mvn versions:set -DoldVersion=* -DnewVersion=${new_versiont} -DgenerateBackupPoms=${is_bak} && mvn clean install

## 2. 更新 service 工程中的 commons 工程版本号
cd ../osc-service/
## 获取当前工程的版本号
## old_version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
## 输出看一眼
## echo old_version: ${old_version}
## 更新
mvn versions:update-properties -DincludeProperties={osc.commons.version} -Dproperties=[${new_versiont}] -DgenerateBackupPoms=${is_bak}

## 3. 更新 service 工程版本号
mvn versions:set -DoldVersion=* -DnewVersion=${new_versiont} -DgenerateBackupPoms=${is_bak}

## 结束
echo [INFO] ----------------------------- end --------------------------------------

else

## 结束
echo [INFO] -------------------------- 缺少参数 -------------------------------------

fi
3 changes: 3 additions & 0 deletions old-version.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout
4 changes: 3 additions & 1 deletion osc-service/osc-base-service/osc-base-service-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<properties>
<!-- docker 镜像名称 -->
<docker.image.name>osc-base</docker.image.name>
<!-- 公用工程版本号 -->
<osc.commons.version>1.4.3</osc.commons.version>
</properties>

<!-- 加入依赖 -->
Expand All @@ -34,7 +36,7 @@
<dependency>
<groupId>com.zwc</groupId>
<artifactId>osc-commons</artifactId>
<version>1.4.3</version>
<version>${osc.commons.version}</version>
</dependency>
<!-- api 工程依赖 -->
<dependency>
Expand Down
4 changes: 3 additions & 1 deletion osc-service/osc-log-service/osc-log-service-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<properties>
<!-- docker 镜像名称 -->
<docker.image.name>osc-log</docker.image.name>
<!-- 公用工程版本号 -->
<osc.commons.version>1.4.3</osc.commons.version>
</properties>

<!-- 加入依赖 -->
Expand All @@ -34,7 +36,7 @@
<dependency>
<groupId>com.zwc</groupId>
<artifactId>osc-commons</artifactId>
<version>1.4.3</version>
<version>${osc.commons.version}</version>
</dependency>
<!-- api 工程依赖 -->
<dependency>
Expand Down

0 comments on commit e4c31de

Please sign in to comment.