This repository has been archived by the owner on Aug 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.azure-pipelines.yml
179 lines (150 loc) · 5.88 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
trigger:
branches:
include:
- '*'
jobs:
- job: "Build"
pool:
vmImage: 'ubuntu-18.04'
variables:
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
strategy:
matrix:
win64:
archName: 'win64'
GOOS: 'windows'
GOARCH: 'amd64'
win32:
archName: 'win32'
GOOS: 'windows'
GOARCH: '386'
macOS:
archName: 'macOS'
GOOS: 'darwin'
GOARCH: 'amd64'
linux:
archName: 'linux'
GOOS: 'linux'
GOARCH: 'amd64'
steps:
- task: GoTool@0
inputs:
version: '1.13'
displayName: 'Install Go'
- 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'
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'specific'
project: 'ed1875fa-87ea-4872-9756-9a91c67a8c6e'
definition: '1'
buildVersionToDownload: 'latestFromBranch'
branchName: '$(Build.SourceBranch)'
targetPath: '$(modulePath)'
displayName: 'Download bsnes-angelscript $(Build.SourceBranchName)'
- script: |
echo 'Package'
set -e
# expand the wildcard to find the folder name:
bsnes_nightly=( $(compgen -W "bsnes-angelscript-$(archName)-*") )
echo "Determined bsnes_nightly=${bsnes_nightly[0]}"
# extract the commit id from the folder name:
bsnes_commit=${bsnes_nightly[0]:(-40)}
echo "Determined bsnes_commit=${bsnes_commit}"
# determine our own commit:
alttpo_commit=$(Build.SourceVersion)
echo "Determined alttpo_commit=${alttpo_commit}"
# find our nightly folder name:
alttpo_nightly=alttpo-client-$(archName)-$(Build.SourceBranchName)-${alttpo_commit:0:7}-${bsnes_commit:0:7}
echo "Determined alttpo_nightly=${alttpo_nightly}"
# rename the bsnes folder:
mv ${bsnes_nightly} ${alttpo_nightly}
# package alttpo folder:
mkdir ${alttpo_nightly}/alttpo
cp -a alttpo/*.as ${alttpo_nightly}/alttpo/
cp -a README.md ${alttpo_nightly}/
cp -a static ${alttpo_nightly}/
# output variable for the nightly build path:
echo "##vso[task.setvariable variable=alttpo_nightly]${alttpo_nightly}"
workingDirectory: '$(modulePath)'
displayName: 'Package alttpo-nightly'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(modulePath)/$(alttpo_nightly)'
artifact: '$(alttpo_nightly)'
publishLocation: 'pipeline'
displayName: 'Publish alttpo-nightly'
- script: |
go version
go get -v -t -d ./...
GOOS='$(GOOS)' GOARCH='$(GOARCH)' go build -v .
workingDirectory: '$(modulePath)/alttp-server'
displayName: 'Build alttp-server'
- script: |
# determine our own commit:
alttpo_commit=$(Build.SourceVersion)
echo "Determined alttpo_commit=${alttpo_commit}"
# find our nightly folder name:
alttpo_server_nightly=alttpo-server-$(archName)-$(Build.SourceBranchName)-${alttpo_commit:0:7}
echo "Determined alttpo_server_nightly=${alttpo_server_nightly}"
# package up server binary:
mkdir ${alttpo_server_nightly}
mv alttp-server/alttp-server* ${alttpo_server_nightly}/
# output variable for the nightly build path:
echo "##vso[task.setvariable variable=alttpo_server_nightly]${alttpo_server_nightly}"
workingDirectory: '$(modulePath)/'
displayName: 'Package alttp-server'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(modulePath)/$(alttpo_server_nightly)'
artifact: '$(alttpo_server_nightly)'
publishLocation: 'pipeline'
displayName: 'Publish alttp-server'
- job: "Success"
dependsOn: "Build"
condition: succeeded()
pool: server
steps:
# Post a link to latest build artifacts on success to #stable channel in Discord:
- task: InvokeRESTAPI@1
inputs:
connectionType: 'connectedServiceName'
serviceConnection: 'stable-webhook'
method: 'POST'
body: |
{
"content": "A new stable build from the `$(Build.SourceBranchName)` branch is available! Download it here:\nhttps://dev.azure.com/ALttPO/alttpo/_build/results?buildId=$(Build.BuildId)&view=artifacts&type=publishedArtifacts\n\nBuild notes:\n$(Build.SourceVersionMessage)"
}
headers: |
{
"Content-Type": "application/json"
}
waitForCompletion: 'false'
condition: eq(variables['Build.SourceBranchName'], 'master')
displayName: "Discord: post link to #stable channel"
# Post a link to latest build artifacts on success to #stable channel in Discord:
- task: InvokeRESTAPI@1
inputs:
connectionType: 'connectedServiceName'
serviceConnection: 'unstable-webhook'
method: 'POST'
body: |
{
"content": "A new unstable build from the `$(Build.SourceBranchName)` branch is available! Download it here:\nhttps://dev.azure.com/ALttPO/alttpo/_build/results?buildId=$(Build.BuildId)&view=artifacts&type=publishedArtifacts\n\nBuild notes:\n$(Build.SourceVersionMessage)"
}
headers: |
{
"Content-Type": "application/json"
}
waitForCompletion: 'false'
condition: ne(variables['Build.SourceBranchName'], 'master')
displayName: "Discord: post link to #unstable channel"