-
Notifications
You must be signed in to change notification settings - Fork 5
/
azure-pipelines.yml
62 lines (51 loc) · 2.04 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Go
# Build your Go project.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go
pool:
vmImage: 'ubuntu-latest'
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.13' # Go installation path
GOPATH: '/gopath' # Go workspace path
GOARCH: amd64
GO111MODULE: on
steps:
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
shopt -s extglob
shopt -s dotglob
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'
- task: Cache@2
inputs:
key: 'go | "$(Agent.OS)" | go.sum | go.mod'
restoreKeys: |
go | "$(Agent.OS)" | go.sum
path: $(GOPATH)/pkg/mod
displayName: Cache Go Mod
- script: go test -v ./...
displayName: 'Run tests and get deps'
- script: |
set -e -x
APP_VERSION=$(git describe --tags | tr - ' ' | awk '// {print $2}' || echo $(Build.BuildId))
export GOOS=darwin
go build -ldflags "-X main.version=${APP_VERSION}" -o $(Build.ArtifactStagingDirectory)/azure-tag-manager-${GOOS}-${GOARCH} cmd/cli/main.go
export GOOS=linux
go build -ldflags "-X main.version=${APP_VERSION}" -o $(Build.ArtifactStagingDirectory)/azure-tag-manager-${GOOS}-${GOARCH} cmd/cli/main.go
export GOOS=windows
go build -ldflags "-X main.version=${APP_VERSION}" -o $(Build.ArtifactStagingDirectory)/azure-tag-manager-${GOOS}-${GOARCH} cmd/cli/main.go
ls -la $(Build.ArtifactStagingDirectory)
displayName: 'Build'
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/release'), not(eq(variables['Build.Reason'], 'PullRequest')))
- task: GitHubRelease@0
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/release'), not(eq(variables['Build.Reason'], 'PullRequest')))
displayName: ‘Create GitHub Release’
inputs:
action: 'create'
githubConnection: tdi
repositoryName: nordcloud/azure-tag-manager
tagSource: 'auto'
addChangeLog: true