-
Notifications
You must be signed in to change notification settings - Fork 20
/
azure-pipelines.yml
122 lines (101 loc) · 3.31 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# 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:
# Do not build branches
branches:
exclude:
- "*"
# Run build on tagged versions
tags:
include:
- "v*"
# Run builds for PRs against `master`
pr:
- master
- release/*
pool:
vmImage: 'ubuntu-latest'
steps:
- bash: |
GIT_VERSION="$(git describe --always --long --dirty)"
echo "##vso[task.setvariable variable=VERSION]${GIT_VERSION}"
# Install GO
- task: GoTool@0
inputs:
version: "1.13.4"
displayName: "Set up the Go workspace"
# Install tools needed for CI environment
- script: |
./scripts/install_ci.sh
displayName: "Set up Golang CI Tools"
- script: |
set -x
go version
go get -v -t -d ./...
displayName: 'Get dependencies'
# Install tools needed for CI environment
- script: |
./scripts/install_ci.sh
displayName: "Set up Golang CI Tools"
- script: |
set -ex
# etcd depdendency bug workaround. See commends in go.mod for more details.
go build -ldflags "-X github.com/Optum/dce-cli/cmd.version=$(VERSION)" -v .
sudo rm /home/vsts/go/pkg/mod/github.com/coreos/etcd@v3.3.10+incompatible/client/keys.generated.go || true
which go-junit-report
make test
displayName: 'Run tests'
# Publish junit test results (for unit and functional tests)
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: $(System.DefaultWorkingDirectory)/junit-report/*.xml
testRunTitle: Unit Tests
condition: always()
# Publish code coverage results
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/coverage.xml
condition: always()
- script: |
set -x
mkdir dist && cd dist
# zip for windows and calculate sha256 hash
WINFILE=dce_windows_amd64.zip
env GOOS=windows GOARCH=amd64 go build -ldflags "-X github.com/Optum/dce-cli/cmd.version=$(VERSION)" -v -o ./dce ..
zip -m $WINFILE ./dce
WINSHA=$(IFS=' '; read -ra ADDR <<< $(sha256sum $WINFILE); echo "${ADDR[0]}")
# zip for linux and calculate sha256 hash
LINFILE=dce_linux_amd64.zip
env GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/Optum/dce-cli/cmd.version=$(VERSION)" -v -o ./dce ..
zip -m $LINFILE ./dce
LINSHA=$(IFS=' '; read -ra ADDR <<< $(sha256sum $LINFILE); echo "${ADDR[0]}")
# zip for mac and calculate sha256 hash
MACFILE=dce_darwin_amd64.zip
env GOOS=darwin GOARCH=amd64 go build -ldflags "-X github.com/Optum/dce-cli/cmd.version=$(VERSION)" -v -o ./dce ..
zip -m $MACFILE ./dce
MACSHA=$(IFS=' '; read -ra ADDR <<< $(sha256sum $MACFILE); echo "${ADDR[0]}")
cat> ../release.md <<- EOF
| File | SHA256 |
|---|---|
| $MACFILE | $MACSHA |
| $LINFILE | $LINSHA |
| $WINFILE | $WINSHA |
EOF
displayName: 'Build and zip'
# Publish a Github Release for tagged commits
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/github-release?view=azure-devops
- task: GithubRelease@0
displayName: 'Create GitHub Release'
inputs:
action: create
tagSource: 'auto'
gitHubConnection: Github
repositoryName: Optum/dce-cli
releaseNotesFile: |
./release.md
assets: |
./dist/*