From 6ab35f456dcc6d03f667b1adad0c7cb49c8bf71b Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Sun, 13 Sep 2020 11:13:02 +0100 Subject: [PATCH] Add azure release pipeline --- azure-pipelines.yml | 84 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..7d9f284 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,84 @@ +# 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: + - refs/tags/v* + branches: + exclude: + - master + +pool: + vmImage: 'ubuntu-latest' + +variables: + GOBIN: '$(GOPATH)/bin' # Go binaries path + GOROOT: '$(Agent.BuildDirectory)/go' # Go installation path + GOPATH: '$(Agent.BuildDirectory)/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' + wget "https://golang.org/dl/go1.15.2.linux-amd64.tar.gz" --output-document "$(Agent.BuildDirectory)/go1.15.2.tar.gz" + tar -C '$(Agent.BuildDirectory)' -xzf "$(Agent.BuildDirectory)/go1.15.2.tar.gz" + displayName: 'Set up the Go workspace' + +- script: | + go get github.com/mitchellh/gox + + 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-* $(Build.ArtifactStagingDirectory)/ + + 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-* $(Build.ArtifactStagingDirectory)/ + workingDirectory: '$(modulePath)' + displayName: 'Get dependencies, then build' + +# GitHub Release +# Create, edit, or delete a GitHub release +- task: GitHubRelease@0 + inputs: + gitHubConnection: cbeuw + repositoryName: '$(Build.Repository.Name)' + action: 'create' # Options: create, edit, delete + target: '$(Build.SourceVersion)' # Required when action == Create || Action == Edit + tagSource: 'auto' # Required when action == Create# Options: auto, manual + #tagPattern: # Optional + #tag: "$(git describe --tags)" # Required when action == Edit || Action == Delete || TagSource == Manual + #title: # Optional + #releaseNotesSource: 'file' # Optional. Options: file, input + #releaseNotesFile: # Optional + #releaseNotes: # Optional + #assets: '$(Build.ArtifactStagingDirectory)/*' # Optional + #assetUploadMode: 'delete' # Optional. Options: delete, replace + #isDraft: false # Optional + #isPreRelease: false # Optional + addChangeLog: false # Optional + #compareWith: 'lastFullRelease' # Required when addChangeLog == True. Options: lastFullRelease, lastRelease, lastReleaseByTag + #releaseTag: # Required when compareWith == LastReleaseByTag \ No newline at end of file