90.release-build.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. set -e
  2. #---------------------------------------------------------------------
  3. #(x.1)参数
  4. args_="
  5. export codePath=/root/docker/jenkins/workspace/sqler/svn
  6. export version=`grep '<Version>' ${codePath} -r --include *.csproj | grep -oP '>(.*)<' | tr -d '<>'`
  7. export name=sqler
  8. export export GIT_SSH_SECRET=xxxxxx
  9. # "
  10. #----------------------------------------------
  11. echo "(x.2.1)发布文件-创建文件夹及内容"
  12. mkdir -p $codePath/Publish/git
  13. mkdir -p $codePath/Publish/release
  14. cp -rf $codePath/Publish/04.服务站点 $codePath/Publish/release/04.服务站点
  15. cp -rf $codePath/Publish/06.Docker $codePath/Publish/release/06.Docker
  16. cp -rf $codePath/Publish/06.Docker/制作镜像/${name}/app $codePath/Publish/release/04.服务站点/${name}
  17. echo "(x.2.3)发布文件-压缩"
  18. docker run --rm -i \
  19. -v $codePath/Publish:/root/file \
  20. serset/filezip dotnet FileZip.dll zip -i /root/file/release -o /root/file/git/${name}-${version}.zip
  21. #----------------------------------------------
  22. echo "(x.3)github-提交release文件到release仓库"
  23. # releaseFile=$codePath/Publish/git/${name}-${version}.zip
  24. #复制ssh key
  25. echo "${GIT_SSH_SECRET}" > $codePath/Publish/git/serset
  26. chmod 600 $codePath/Publish/git/serset
  27. #推送到github
  28. docker run -i --rm -v $codePath/Publish/git:/root/git serset/git-client bash -c " \
  29. set -e
  30. ssh-agent bash -c \"
  31. ssh-add /root/git/serset
  32. ssh -T git@github.com -o StrictHostKeyChecking=no
  33. git config --global user.email 'serset@yeah.com'
  34. git config --global user.name 'lith'
  35. mkdir -p /root/code
  36. cd /root/code
  37. git clone git@github.com:serset/release.git /root/code
  38. mkdir -p /root/code/file/${name}
  39. cp /root/git/${name}-${version}.zip /root/code/file/${name}
  40. git add file/${name}/${name}-${version}.zip
  41. git commit -m 'auto commit ${version}'
  42. git push -u origin master \" "