-
Notifications
You must be signed in to change notification settings - Fork 1.5k
320 lines (304 loc) · 14.6 KB
/
cd-dgraph.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
name: cd-dgraph
on:
workflow_dispatch:
inputs:
latest:
type: boolean
default: false
description: release latest tag docker-images on dockerhub
releasetag:
description: releasetag
required: true
type: string
custom-build:
type: boolean
default: false
description: if checked, images will be pushed to dgraph-custom repo in Dockerhub
jobs:
dgraph-build-amd64:
runs-on: warp-ubuntu-latest-x64-16x
steps:
- uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.releasetag }}'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install protobuf-compiler
run: sudo apt update && sudo apt install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
go mod tidy
make regenerate
git diff --exit-code -- .
- name: Set Badger Release Version
run: |
#!/bin/bash
BADGER_RELEASE_VERSION=$(cat go.mod | grep -i "github.com/dgraph-io/badger" | awk '{print $2}')
echo "setting badger version "$BADGER_RELEASE_VERSION
echo "BADGER_RELEASE_VERSION=$BADGER_RELEASE_VERSION" >> $GITHUB_ENV
- name: Download Badger Artifacts
run: |
#!/bin/bash
mkdir badger
cd badger
wget https://github.com/dgraph-io/badger/releases/download/${{ env.BADGER_RELEASE_VERSION }}/badger-checksum-linux-amd64.sha256
wget https://github.com/dgraph-io/badger/releases/download/${{ env.BADGER_RELEASE_VERSION }}/badger-linux-amd64.tar.gz
- name: Set Dgraph Release Version
run: |
#!/bin/bash
GIT_TAG_NAME='${{ github.event.inputs.releasetag }}'
if [[ "$GIT_TAG_NAME" == "v"* ]];
then
echo "this is a release branch"
else
echo "this is NOT a release branch"
exit 1
fi
DGRAPH_RELEASE_VERSION='${{ github.event.inputs.releasetag }}'
echo "making a new release for dgraph "$DGRAPH_RELEASE_VERSION
echo "DGRAPH_RELEASE_VERSION=$DGRAPH_RELEASE_VERSION" >> $GITHUB_ENV
- name: Make Dgraph Linux Build
run: make dgraph DGRAPH_VERSION=${{ env.DGRAPH_RELEASE_VERSION }}
- name: Generate SHA for Dgraph Linux Build
run: cd dgraph && sha256sum dgraph | cut -c-64 > dgraph-checksum-linux-amd64.sha256
- name: Tar Archive for Dgraph Linux Build
run: cd dgraph && tar -zcvf dgraph-linux-amd64.tar.gz dgraph
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dgraph-amd-release-artifacts
path: |
badger/badger-checksum-linux-amd64.sha256
badger/badger-linux-amd64.tar.gz
dgraph/dgraph-checksum-linux-amd64.sha256
dgraph/dgraph-linux-amd64.tar.gz
- name: Move Badger Binary into Linux Directory
run: |
tar -xzf badger/badger-linux-amd64.tar.gz --directory badger
[ -d "linux" ] || mkdir linux
# linux directory will be added to docker image in build step
cp badger/badger-linux-amd64 linux/badger
- name: Make Dgraph Docker Image
run: |
set -e
make docker-image DGRAPH_VERSION=${{ env.DGRAPH_RELEASE_VERSION }}-amd64
[[ "${{ inputs.latest }}" = true ]] && docker tag dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 dgraph/dgraph:latest-amd64 || true
[[ "${{ inputs.custom-build }}" = true ]] && docker tag dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 || true
#Save all tagged images into a single tar file
docker save -o dgraph-docker-amd64.tar \
dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 \
$( [[ "${{ inputs.latest }}" = true ]] && echo "dgraph/dgraph:latest-amd64" ) \
$( [[ "${{ inputs.custom-build }}" = true ]] && echo "dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-amd64" )
- name: Upload AMD64 Docker Image
uses: actions/upload-artifact@v4
with:
name: dgraph-docker-amd64
path: dgraph-docker-amd64.tar
- name: Make Dgraph Standalone Docker Image with Version
#No need to build and push Standalone Image when its a custom build
if: inputs.custom-build == false
run: |
set -e
make docker-image-standalone DGRAPH_VERSION=${{ env.DGRAPH_RELEASE_VERSION }}-amd64
[[ "${{ inputs.latest }}" = true ]] && docker tag dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 dgraph/standalone:latest-amd64 || true
docker save -o dgraph-standalone-amd64.tar \
dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 \
$( [[ "${{ inputs.latest }}" = true ]] && echo "dgraph/standalone:latest-amd64" )
- name: Upload AMD64 Standalone Image
if: inputs.custom-build == false
uses: actions/upload-artifact@v4
with:
name: dgraph-standalone-amd64
path: dgraph-standalone-amd64.tar
dgraph-build-arm64:
runs-on: warp-ubuntu-latest-arm64-16x
steps:
- uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.releasetag }}'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install protobuf-compiler
run: sudo apt update && sudo apt install -y protobuf-compiler
- name: Check protobuf
run: |
cd ./protos
go mod tidy
make regenerate
git diff --exit-code -- .
- name: Set Badger Release Version
run: |
#!/bin/bash
BADGER_RELEASE_VERSION=$(cat go.mod | grep -i "github.com/dgraph-io/badger" | awk '{print $2}')
echo "setting badger version "$BADGER_RELEASE_VERSION
echo "BADGER_RELEASE_VERSION=$BADGER_RELEASE_VERSION" >> $GITHUB_ENV
- name: Download Badger Artifacts
run: |
#!/bin/bash
mkdir badger
cd badger
wget https://github.com/dgraph-io/badger/releases/download/${{ env.BADGER_RELEASE_VERSION }}/badger-checksum-linux-arm64.sha256
wget https://github.com/dgraph-io/badger/releases/download/${{ env.BADGER_RELEASE_VERSION }}/badger-linux-arm64.tar.gz
- name: Set Dgraph Release Version
run: |
#!/bin/bash
GIT_TAG_NAME='${{ github.event.inputs.releasetag }}'
if [[ "$GIT_TAG_NAME" == "v"* ]];
then
echo "this is a release branch"
else
echo "this is NOT a release branch"
exit 1
fi
DGRAPH_RELEASE_VERSION='${{ github.event.inputs.releasetag }}'
echo "making a new release for dgraph "$DGRAPH_RELEASE_VERSION
echo "DGRAPH_RELEASE_VERSION=$DGRAPH_RELEASE_VERSION" >> $GITHUB_ENV
- name: Make Dgraph Linux Build
run: make dgraph DGRAPH_VERSION=${{ env.DGRAPH_RELEASE_VERSION }}
- name: Generate SHA for Dgraph Linux Build
run: cd dgraph && sha256sum dgraph | cut -c-64 > dgraph-checksum-linux-arm64.sha256
- name: Tar Archive for Dgraph Linux Build
run: cd dgraph && tar -zcvf dgraph-linux-arm64.tar.gz dgraph
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dgraph-arm-release-artifacts
path: |
badger/badger-checksum-linux-arm64.sha256
badger/badger-linux-arm64.tar.gz
dgraph/dgraph-checksum-linux-arm64.sha256
dgraph/dgraph-linux-arm64.tar.gz
- name: Move Badger Binary into Linux Directory
run: |
tar -xzf badger/badger-linux-arm64.tar.gz --directory badger
[ -d "linux" ] || mkdir linux
# linux directory will be added to docker image in build step
cp badger/badger-linux-arm64 linux/badger
- name: Make Dgraph Docker Image
run: |
set -e
make docker-image DGRAPH_VERSION=${{ env.DGRAPH_RELEASE_VERSION }}-arm64
[[ "${{ inputs.latest }}" = true ]] && docker tag dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-arm64 dgraph/dgraph:latest-arm64 || true
[[ "${{ inputs.custom-build }}" = true ]] && docker tag dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-arm64 dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-arm64 || true
docker save -o dgraph-docker-arm64.tar \
dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-arm64 \
$( [[ "${{ inputs.latest }}" = true ]] && echo "dgraph/dgraph:latest-arm64" ) \
$( [[ "${{ inputs.custom-build }}" = true ]] && echo "dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-arm64" )
- name: Upload ARM64 Docker Image
uses: actions/upload-artifact@v4
with:
name: dgraph-docker-arm64
path: dgraph-docker-arm64.tar
- name: Make Dgraph Standalone Docker Image with Version
#No need to build and push Standalone Image when its a custom build
if: inputs.custom-build == false
run: |
set -e
make docker-image-standalone DGRAPH_VERSION=${{ env.DGRAPH_RELEASE_VERSION }}-arm64
[[ "${{ inputs.latest }}" = true ]] && docker tag dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-arm64 dgraph/standalone:latest-arm64 || true
docker save -o dgraph-standalone-arm64.tar \
dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-arm64 \
$( [[ "${{ inputs.latest }}" = true ]] && echo "dgraph/standalone:latest-arm64" )
- name: Upload ARM64 Standalone Image
if: inputs.custom-build == false
uses: actions/upload-artifact@v4
with:
name: dgraph-standalone-arm64
path: dgraph-standalone-arm64.tar
dgraph-docker-image-and-manifests-push:
needs: [dgraph-build-amd64, dgraph-build-arm64]
runs-on: warp-ubuntu-latest-x64-16x
steps:
- uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.releasetag }}'
- name: Set Dgraph Release Version
run: |
#!/bin/bash
GIT_TAG_NAME='${{ github.event.inputs.releasetag }}'
if [[ "$GIT_TAG_NAME" == "v"* ]];
then
echo "this is a release branch"
else
echo "this is NOT a release branch"
exit 1
fi
DGRAPH_RELEASE_VERSION='${{ github.event.inputs.releasetag }}'
echo "making a new release for dgraph "$DGRAPH_RELEASE_VERSION
echo "DGRAPH_RELEASE_VERSION=$DGRAPH_RELEASE_VERSION" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD_TOKEN }}
# Download AMD64 Tar File
- name: Download Dgraph AMD64 Tar
uses: actions/download-artifact@v4
with:
name: dgraph-docker-amd64
# Download Dgraph ARM64 Tar File
- name: Download ARM64 Tar
uses: actions/download-artifact@v4
with:
name: dgraph-docker-arm64
# Load Dgraph AMD64 Image
- name: Load AMD64 Docker Image
run: |
docker load -i dgraph-docker-amd64.tar
# Load Dgraph ARM64 Image
- name: Load ARM64 Docker Image
run: |
docker load -i dgraph-docker-arm64.tar
# Download Standalone AMD64 Tar File
- name: Download Standalone AMD64 Tar
if: inputs.custom-build == false
uses: actions/download-artifact@v4
with:
name: dgraph-standalone-amd64
# Load Standalone AMD64 Image
- name: Load Standalone AMD64 Docker Image
if: inputs.custom-build == false
run: |
docker load -i dgraph-standalone-amd64.tar
# Download Standalone ARM64 Tar File
- name: Download Standalone ARM64 Tar
if: inputs.custom-build == false
uses: actions/download-artifact@v4
with:
name: dgraph-standalone-arm64
# Load Standalone ARM64 Image
- name: Load Standalone ARM64 Docker Image
if: inputs.custom-build == false
run: |
docker load -i dgraph-standalone-arm64.tar
- name: Docker Manifest
run: |
if [ "${{ github.event.inputs.custom-build }}" == "true" ]; then
#Push AMD and ARM images to dgraph-custom repo
docker push dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-amd64
docker push dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker manifest create dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }} --amend dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 --amend dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker manifest push dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}
else
# Push standalone Images and manifest
docker push dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-amd64
docker push dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker manifest create dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }} --amend dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 --amend dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker manifest push dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}
# Push Dgraph Images and Manifest
docker push dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-amd64
docker push dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker manifest create dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }} --amend dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 --amend dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker manifest push dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}
if [ "${{ github.event.inputs.latest }}" == "true" ]; then
docker manifest create dgraph/standalone:latest --amend dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 --amend dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker manifest create dgraph/dgraph:latest --amend dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 --amend dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker manifest push dgraph/standalone:latest
docker manifest push dgraph/dgraph:latest
fi
fi