build_video_course.ps1 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. $beginPWD = $PWD
  2. $module = "video_course"
  3. try {
  4. Write-Output "set location to script path: $PSScriptRoot"
  5. Set-Location $PSScriptRoot
  6. git checkout master
  7. git checkout .
  8. git pull
  9. # git submodule foreach git checkout master
  10. # git submodule foreach git pull
  11. # .\scrips\gen_proto.ps1
  12. $cmd = "git describe --tags"
  13. $version = Invoke-Expression $cmd
  14. Write-Output "version: $version"
  15. $stableVersionParttern = ".*-stable$"
  16. $isStable = $version -match $stableVersionParttern
  17. if ($isStable) {
  18. Write-Output "is stable version"
  19. }
  20. #
  21. # Write-Output "use origin golang compiler"
  22. # Set-Location ($PSScriptRoot + "/assembly/$module/main")
  23. $cmd = "go build -o $module -ldflags ""-X main._VERSION_='$version'"""
  24. Write-Output $cmd
  25. Invoke-Expression $cmd
  26. Write-Output "compile finish"
  27. Remove-Item "$PSScriptRoot/docker/$module/$module"
  28. Move-Item "$module" "$PSScriptRoot/docker/$module/$module"
  29. $dockerImage = "docker.beswell.com:5050/loallout/$module"
  30. $dockerImageWithVersion = "${dockerImage}:$version"
  31. $dockerImageLatest = "${dockerImage}:latest"
  32. $cmd = "docker build -t $dockerImageWithVersion $PSScriptRoot/docker/$module"
  33. Invoke-Expression $cmd
  34. $cmd = "docker tag $dockerImageWithVersion $dockerImageLatest"
  35. Invoke-Expression $cmd
  36. $cmd = "docker push $dockerImageWithVersion"
  37. Invoke-Expression $cmd
  38. $cmd = "docker push $dockerImageLatest"
  39. Invoke-Expression $cmd
  40. }
  41. catch {
  42. $err = $Error[0]
  43. Write-Error $err
  44. }
  45. Set-Location $beginPWD