40.Station-publish.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. set -e
  2. #---------------------------------------------------------------------
  3. # args
  4. args_="
  5. export basePath=/root/temp/svn
  6. export NUGET_PATH=$basePath/Publish/release/.nuget
  7. # "
  8. if [ ! $NUGET_PATH ]; then NUGET_PATH=$basePath/Publish/release/.nuget; fi
  9. #----------------------------------------------
  10. echo "#40.Station-publish.sh -> find projects and build"
  11. export devOpsPath="$PWD/.."
  12. docker run -i --rm \
  13. --env LANG=C.UTF-8 \
  14. -v $NUGET_PATH:/root/.nuget \
  15. -v "$basePath":/root/code \
  16. -v "$basePath":"$basePath" \
  17. serset/dotnet:sdk-6.0 \
  18. bash -c "
  19. set -e
  20. if grep '<publish>' -r --include *.csproj /root/code; then
  21. echo '#40.Station-publish.sh -> got projects need to be built'
  22. else
  23. echo '#40.Station-publish.sh -> skip for no project needs to be built'
  24. exit 0
  25. fi
  26. echo '#1 get netVersion'
  27. export netVersion=\$(grep '<TargetFramework>' \$(grep '<publish>' -rl --include *.csproj /root/code | head -n 1) | grep -oP '>(.*)<' | tr -d '<>')
  28. echo netVersion: \$netVersion
  29. export basePath=/root/code
  30. export publishPath=\$basePath/Publish/release/release/Station\(\$netVersion\)
  31. mkdir -p \$publishPath
  32. echo '#2 publish station'
  33. cd \$basePath
  34. for file in \$(grep -a '<publish>' . -rl --include *.csproj)
  35. do
  36. cd \$basePath
  37. #get publishName
  38. publishName=\`grep '<publish>' \$file -r | grep -oP '>(.*)<' | tr -d '<>'\`
  39. echo publish \$publishName
  40. #publish
  41. cd \$(dirname \"\$file\")
  42. dotnet build --configuration Release
  43. dotnet publish --configuration Release --output \"\$publishPath/\$publishName\"
  44. #copy xml
  45. for filePath in bin/Release/\$netVersion/*.xml ; do \\cp -rf \$filePath \"\$publishPath/\$publishName\";done
  46. done
  47. #3 copy station release files
  48. if [ -d \"\$basePath/Publish/ReleaseFile/Station\" ]; then
  49. echo '#3 copy station release files'
  50. \cp -rf \$basePath/Publish/ReleaseFile/Station/. \"\$publishPath\"
  51. fi
  52. #4 copy extra release files
  53. bashFile=\"$devOpsPath/environment/build-bash__40.Station-publish__#4_copyExtraReleaseFiles.sh\"
  54. if [ -f \"\$bashFile\" ]; then
  55. echo '#4 copy extra release files'
  56. sh \"\$bashFile\"
  57. fi
  58. "
  59. echo '#40.Station-publish.sh -> success!'