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