-
Notifications
You must be signed in to change notification settings - Fork 1.5k
255 lines (252 loc) · 12 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
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: Get Go Version
run: |
#!/bin/bash
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- 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:
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: |
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
- 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: |
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
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD_TOKEN }}
- name: Push Images to DockerHub
run: |
if [ "${{ inputs.custom-build }}" == "true" ]; then
docker push dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-amd64
else
docker push dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-amd64
docker push dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-amd64
fi
dgraph-build-arm64:
runs-on: warp-ubuntu-latest-arm64-16x
steps:
- uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.releasetag }}'
- name: Get Go Version
run: |
#!/bin/bash
GOVERSION=$({ [ -f .go-version ] && cat .go-version; })
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVERSION }}
- 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:
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: |
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
- 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: |
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
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD_TOKEN }}
- name: Push Images to DockerHub
run: |
if [ "${{ inputs.custom-build }}" == "true" ]; then
docker push dgraph/dgraph-custom:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
else
docker push dgraph/standalone:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker push dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
fi
dgraph-docker-manifest:
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 }}
- name: Docker Manifest
run: |
if [ "${{ github.event.inputs.custom-build }}" == "true" ]; then
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
# standalone
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 }}
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 push dgraph/standalone:latest
fi
# dgraph
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/dgraph:latest --amend dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-amd64 --amend dgraph/dgraph:${{ env.DGRAPH_RELEASE_VERSION }}-arm64
docker manifest push dgraph/dgraph:latest
fi
fi