40.Station-publish.sh 2.0 KB

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