$beginPWD = $PWD $module = "video_course" try { Write-Output "set location to script path: $PSScriptRoot" Set-Location $PSScriptRoot git checkout master git checkout . git pull # git submodule foreach git checkout master # git submodule foreach git pull # .\scrips\gen_proto.ps1 $cmd = "git describe --tags" $version = Invoke-Expression $cmd Write-Output "version: $version" $stableVersionParttern = ".*-stable$" $isStable = $version -match $stableVersionParttern if ($isStable) { Write-Output "is stable version" } # # Write-Output "use origin golang compiler" # Set-Location ($PSScriptRoot + "/assembly/$module/main") $cmd = "go build -o $module -ldflags ""-X main._VERSION_='$version'""" Write-Output $cmd Invoke-Expression $cmd Write-Output "compile finish" Remove-Item "$PSScriptRoot/docker/$module/$module" Move-Item "$module" "$PSScriptRoot/docker/$module/$module" $dockerImage = "docker.beswell.com:5050/loallout/$module" $dockerImageWithVersion = "${dockerImage}:$version" $dockerImageLatest = "${dockerImage}:latest" $cmd = "docker build -t $dockerImageWithVersion $PSScriptRoot/docker/$module" Invoke-Expression $cmd $cmd = "docker tag $dockerImageWithVersion $dockerImageLatest" Invoke-Expression $cmd $cmd = "docker push $dockerImageWithVersion" Invoke-Expression $cmd $cmd = "docker push $dockerImageLatest" Invoke-Expression $cmd } catch { $err = $Error[0] Write-Error $err } Set-Location $beginPWD