# Go # Build your Go project. # Add steps that test, save build artifacts, deploy, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/go trigger: tags: include: - v* pool: vmImage: 'ubuntu-latest' variables: GOBIN: '$(GOPATH)/bin' # Go binaries path GOROOT: '/usr/local/go1.13' # Go installation path GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code steps: - script: | mkdir -p '$(GOBIN)' mkdir -p '$(GOPATH)/pkg' mkdir -p '$(modulePath)' shopt -s extglob shopt -s dotglob mv !(gopath) '$(modulePath)' echo '##vso[task.prependpath]$(GOBIN)' echo '##vso[task.prependpath]$(GOROOT)/bin' displayName: 'Set up the Go workspace' - script: | go get github.com/mitchellh/gox mkdir -p release read -rp "Cleaning $PWD/release directory. Proceed? [y/n]" res if [ ! "$res" == "y" ]; then echo "Abort" exit 1 fi rm -rf ./release/* v = "$(git describe --tags)" output="{{.Dir}}-{{.OS}}-{{.Arch}}-$v" osarch="!darwin/arm !darwin/arm64 !darwin/386" echo "Compiling:" os="windows linux darwin" arch="amd64 386 arm arm64 mips mips64 mipsle mips64le" pushd cmd/ck-client || exit 1 gox -ldflags "-X main.version=${v}" -os="$os" -arch="$arch" -osarch="$osarch" -output="$output" GOOS="linux" GOARCH="mips" GOMIPS="softfloat" go build -ldflags "-X main.version=${v}" -o ck-client-linux-mips_softfloat-"${v}" GOOS="linux" GOARCH="mipsle" GOMIPS="softfloat" go build -ldflags "-X main.version=${v}" -o ck-client-linux-mipsle_softfloat-"${v}" mv ck-client-* ../../release os="linux" arch="amd64 386 arm arm64" pushd ../ck-server || exit 1 gox -ldflags "-X main.version=${v}" -os="$os" -arch="$arch" -osarch="$osarch" -output="$output" mv ck-server-* ../../release workingDirectory: '$(modulePath)' displayName: 'Get dependencies, then build'