From 3484914304d6c4fcbe8c5e50a0757878b4e2c359 Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Sat, 12 Sep 2020 22:40:13 +0100 Subject: [PATCH] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 66 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..92e718b --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,66 @@ +# 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.11' # 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'