-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure-pipelines.yaml
148 lines (133 loc) · 4.43 KB
/
azure-pipelines.yaml
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
trigger:
tags:
include:
- v*
branches:
include:
- master
paths:
exclude:
- README.md
- CHANGELOG.md
variables:
jobuuid: $(Build.BuildId)$(Agent.Id)
build: $(Build.BuildId)
ref: $(Build.SourceBranch)
commit: $(Build.SourceVersion)
branch: $(Build.SourceBranchName)
isTaggedCommit: 'no'
version:
GOROOT: '/usr/local/go1.16'
GOPATH: '/tmp/go'
GOBIN: '$(GOPATH)/bin'
dp.cli.version: "3.0.0"
stages:
- stage: Publish
jobs:
- job: Publish
pool:
vmImage: 'Ubuntu-18.04'
steps:
- script: |
set -e
VERS=$(echo $(commit) | cut -c1-20)
if [[ $(ref) == refs/tags* ]]; then
VERS=$(echo $(ref) | sed "s|refs/tags/v||g")
echo "##vso[task.setvariable variable=isTaggedCommit]yes"
fi
echo "##vso[task.setvariable variable=version]$VERS"
echo "Version: $VERS"
displayName: 'Set git/version variables'
- script: |
set -e
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'
- task: GoTool@0
inputs:
version: '1.16'
goPath: $(GOPATH)
goBin: $(GOBIN)
displayName: 'Install Golang'
- script: |
set -e
AGENT_VERSION="$(version)" script/build.bash
dist/agent/$(version)/linux/amd64/deviceplane-agent --help
displayName: 'Build binaries'
- task: AzureCLI@2
displayName: Upload versioned binaries to Azure
inputs:
azureSubscription: AzureSubscription
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
set -e
az storage blob upload-batch -d downloads/agent -s ./dist/agent/ --account-name deviceplanedownloads --account-key $(az.storage_account_key)
- task: AzureCLI@2
condition: eq(variables.isTaggedCommit, 'yes')
displayName: Upload latest binaries to Azure
inputs:
azureSubscription: AzureSubscription
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
set -e
az storage blob upload-batch -d downloads/agent/latest -s ./dist/agent/$(version)/ --account-name deviceplanedownloads --account-key $(az.storage_account_key)
- task: AzureCLI@2
condition: eq(variables.isTaggedCommit, 'yes')
displayName: Upload install.sh
inputs:
azureSubscription: AzureSubscription
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
set -e
az storage blob upload --account-name deviceplanedownloads --account-key $(az.storage_account_key) --container-name downloads --file script/install.sh --name install.sh
- stage: Test
jobs:
- job: Test
pool:
vmImage: 'Ubuntu-18.04'
steps:
- checkout: self
submodules: true
- script: |
set -e
VERS=$(echo $(commit) | cut -c1-20)
if [[ $(ref) == refs/tags* ]]; then
VERS=$(echo $(ref) | sed "s|refs/tags/v||g")
fi
echo "##vso[task.setvariable variable=version]$VERS"
echo "Version: $VERS"
displayName: 'Set git/version variables'
- bash: |
set -e
./bootstrap.bash
displayName: 'Bootstrap'
workingDirectory: $(System.DefaultWorkingDirectory)/tests
- bash: |
set -e
cp ./env.sh ./conf/env.sh
sed -i "s|TT_CLI_VERSION=.*|TT_CLI_VERSION=\"$(dp.cli.version)\"|g" ./conf/env.sh
./run.bash install_cli
displayName: 'Test: install cli'
workingDirectory: $(System.DefaultWorkingDirectory)/tests
- bash: |
set -e
cp ./env.sh ./conf/env.sh
sed -i "s|TT_AGENT_VERSION=.*|TT_AGENT_VERSION=\"$(version)\"|g" ./conf/env.sh
sed -i "s|TT_REGISTRATION_TOKEN=.*|TT_REGISTRATION_TOKEN=\"$(agent.registration_token)\"|g" ./conf/env.sh
sed -i "s|TT_PROJECT=.*|TT_PROJECT=\"$(project)\"|g" ./conf/env.sh
./run.bash install_agent
displayName: 'Test: install agent'
workingDirectory: $(System.DefaultWorkingDirectory)/tests
- bash: |
set -e
cp ./env.sh ./conf/env.sh
sed -i "s|TT_PROJECT=.*|TT_PROJECT=\"$(project)\"|g" ./conf/env.sh
sed -i "s|TT_ACCESS_KEY=.*|TT_ACCESS_KEY=\"$(cli.access_key)\"|g" ./conf/env.sh
./run.bash ssh
displayName: 'Test: ssh'
workingDirectory: $(System.DefaultWorkingDirectory)/tests