背景
项目托管在JAVA后台,每次发布比较麻烦,所以写了个脚本,并且集成到了npm run publish
中,实现非常简单的one-click发布。
脚本代码
js_home=`pwd`
java_project_location="${js_home}/../../java-project"
java_resources_location="${java_project_location}/src/main/resources/META-INF/resources"
java_branch_names="dev prod"
date=`date`
echo $java_resources_location
git pull \
&& npm run build \
&& echo 'Run build finished!!!' \
&& cd ${java_project_location} \
&& for java_branch_name in ${java_branch_names};
do
echo "Starting publish branch ${java_branch_name}:" \
&& git checkout ${java_branch_name} \
&& git pull \
&& rm -rf ${java_resources_location}/* \
&& cp -r ${js_home}/build/* ${java_resources_location} \
&& git status \
&& git add . \
&& git commit -m "Update fe build version automatically!! Date: ${date}" \
&& git push \
&& echo "Publish branch ${java_branch_name} success!!!";
done