-
Notifications
You must be signed in to change notification settings - Fork 1
318 lines (281 loc) · 11 KB
/
build.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: Build Docker images
run-name: Build Docker images for ${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: 'RavenDB Version'
required: true
type: string
docker_user:
description: 'DockerHub username'
required: false
type: string
default: ravendb
github_repository:
description: 'Github repository'
required: false
type: string
default: ravendb/ravendb
dry_run:
description: 'Dry run'
required: false
type: string
default: ''
env:
IS_STABLE: ${{ ! contains(inputs.version, '-') }}
IS_NIGHTLY: ${{ contains(inputs.version, 'nightly') }}
DOCKER_USER: ${{ inputs.docker_user }}
DOCKER_REPO: '${{ inputs.docker_user }}/ravendb'
DRY_RUN: ${{ inputs.dry_run }}
jobs:
debPackage:
name: Build DEB package
strategy:
matrix:
arch: [ x64, arm32v7, arm64v8 ]
ubuntuName: [bionic, focal, jammy]
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Get ravendb majorminor version, build type & set repo
run: |
v=$(echo ${{ inputs.version }} | cut -d. -f1,2)
echo "RAVEN_MAJOR_MINOR=$v" >> $GITHUB_ENV
[[ ${{ env.IS_NIGHTLY }} == true ]] && DOCKER_REPO="$DOCKER_REPO-nightly"
echo "DOCKER_REPO=$DOCKER_REPO" >> $GITHUB_ENV
buildType=$(echo ${{ inputs.version }} | cut -d- -f2)
echo "TRIGGERING_BUILD_TYPE=$buildType" >> $GITHUB_ENV
echo "Docker repository: $DOCKER_REPO; TRIGGERING_BUILD_TYPE: $buildType"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v3
with:
path: current
- uses: actions/checkout@v3
with:
repository: '${{ inputs.github_repository }}'
ref: "v${{ env.RAVEN_MAJOR_MINOR }}"
path: ravendb
- name: Download tar package
run: |
case "${{ matrix.arch }}" in
"arm32v7")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-raspberry-pi.tar.bz2"
;;
"arm64v8")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-linux-arm64.tar.bz2"
;;
"x64")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-linux-x64.tar.bz2"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
wget -P "temp" "$downloadURL"
working-directory: ravendb/scripts/linux/pkg/deb
- name: Extract build number
run: |
case "${{ matrix.arch }}" in
"arm32v7")
tarName="RavenDB-${{ inputs.version }}-raspberry-pi.tar.bz2"
;;
"arm64v8")
tarName="RavenDB-${{ inputs.version }}-linux-arm64.tar.bz2"
;;
"x64")
tarName="RavenDB-${{ inputs.version }}-linux-x64.tar.bz2"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
filePath="RavenDB/Server/Raven.Server.dll"
tar -xvf $tarName $filePath
sudo apt install -y libimage-exiftool-perl
number=$(exiftool $filePath | grep 'File Version Number' | cut -d. -f 4)
echo "BUILD_NUMBER=$number" >> $GITHUB_ENV
working-directory: ravendb/scripts/linux/pkg/deb/temp
- name: Build deb package
run: |
chmod a+x *.sh
case "${{ matrix.arch }}" in
"arm32v7")
arch="armhf"
;;
"arm64v8")
arch="arm64"
;;
"x64")
arch="amd64"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
source ./set-ubuntu-${{ matrix.ubuntuName }}.sh
source ./set-raven-platform-${arch}.sh
./build-deb.sh
echo "DEB_ARCH=$arch" >> $GITHUB_ENV
echo "UBUNTU_VERSION=$DISTRO_VERSION" >> $GITHUB_ENV
working-directory: ravendb/scripts/linux/pkg/deb
env:
RAVENDB_VERSION: ${{ inputs.version }}
- name: Upload deb package to artifacts
uses: actions/upload-artifact@v3
with:
name: package-${{ matrix.ubuntuName }}-${{ matrix.arch }}
path: ravendb/scripts/linux/pkg/deb/dist/${{ env.UBUNTU_VERSION }}/ravendb*.deb
- name: Upload deb package to s3
run: |
set -e
set -x
PACKAGES_DIST_DIR=ravendb/scripts/linux/pkg/deb/dist
if [ "${{ env.IS_NIGHTLY }}" == "true" ]; then
NIGHTLY_VERSION_DATE_PART=$(echo ${{ inputs.version }} | cut -d- -f3,4)
export BUILD_VERSION="$NIGHTLY_VERSION_DATE_PART-Nightly"
elif [ "${{ env.IS_STABLE }}" == "true" ]; then
export BUILD_VERSION="${{ env.BUILD_NUMBER }}"
else
export BUILD_VERSION="${{ env.BUILD_NUMBER }}-${{ env.TRIGGERING_BUILD_TYPE }}"
fi
export COMMENT="RavenDB_${RAVENDB_VERSION}_DEB"
export S3UPLOADER="./current/s3uploader.sh"
"$S3UPLOADER" \
--category "RavenDB for Ubuntu ${{ env.UBUNTU_VERSION }} ${{ matrix.arch }} DEB" \
--filename "${PACKAGES_DIST_DIR}/${{ env.UBUNTU_VERSION }}/ravendb_${RAVENDB_VERSION}-0_ubuntu.${{ env.UBUNTU_VERSION }}_${{ env.DEB_ARCH }}.deb"
env:
RAVENDB_VERSION: ${{ inputs.version }}
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
SECRET_PASS: ${{ secrets.SECRET_PASS }}
linux:
name: Build Linux Docker image
strategy:
matrix:
arch: [ x64, arm32v7, arm64v8 ]
fail-fast: false
runs-on: ubuntu-latest
needs: debPackage
if: always()
steps:
- name: Get ravendb majorminor version & set repo
run: |
v=$(echo ${{ inputs.version }} | cut -d. -f1,2)
echo "RAVEN_MAJOR_MINOR=$v" >> $GITHUB_ENV
[[ ${{ env.IS_NIGHTLY }} == true ]] && DOCKER_REPO="$DOCKER_REPO-nightly"
echo "DOCKER_REPO=$DOCKER_REPO" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
repository: '${{ inputs.github_repository }}'
ref: "v${{ env.RAVEN_MAJOR_MINOR }}"
- name: Get docker system
run: |
dockerSystem=$(grep -o -P "(?<=FROM\smcr\.microsoft\.com\/dotnet\/runtime-deps:\d\.\d-)([a-zA-Z]+)(?=.*)" Dockerfile.${{ matrix.arch }})
echo "DOCKER_SYSTEM=$dockerSystem" >> $GITHUB_ENV
working-directory: docker/ravendb-ubuntu
- uses: actions/download-artifact@v3
with:
name: package-${{ env.DOCKER_SYSTEM }}-${{ matrix.arch }}
path: downloads
- name: Move deb to correct folder
run: |
chmod -v a+rw ravendb*.deb
mv -v ravendb*.deb ../docker/ravendb-ubuntu/
working-directory: downloads
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Build
uses: docker/setup-buildx-action@v2
- name: Login to docker
run: |
docker login -u ${{ env.DOCKER_USER }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build image
run: |
case "${{ matrix.arch }}" in
"arm32v7")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-raspberry-pi.tar.bz2"
;;
"arm64v8")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-linux-arm64.tar.bz2"
;;
"x64")
downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-linux-x64.tar.bz2"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
wget -P "../artifacts" "$downloadURL"
pwsh build-ubuntu.ps1 -Repo $DOCKER_REPO -Arch ${{ matrix.arch }}
working-directory: docker
- name: Publish package
run: |
pwsh publish-ubuntu.ps1 -Repo $DOCKER_REPO -Arch ${{ matrix.arch }}
docker logout
working-directory: docker
windowsDockerImageBuilder:
name: Matrix Creator for Windows
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.create.outputs.matrix }}
steps:
- name: Create Matrix
id: create
run: |
v=$(echo ${{ inputs.version }} | cut -d. -f1,2)
if [[ "$v" < "5.4" ]]; then
echo "matrix=[ { \"os\": \"2019\", \"winVer\": \"1809\"} ]" >> "$GITHUB_OUTPUT"
else
echo "matrix=[ { \"os\": \"2019\", \"winVer\": \"1809\"}, { \"os\": \"2022\", \"winVer\": \"ltsc2022\"} ]" >> "$GITHUB_OUTPUT"
fi
windows:
needs: windowsDockerImageBuilder
name: Build Windows Docker images
strategy:
matrix:
data: ${{ fromJson(needs.windowsDockerImageBuilder.outputs.matrix) }}
fail-fast: false
runs-on: windows-${{ matrix.data.os }}
steps:
- name: Get ravendb majorminor version & set repo
shell: bash
run: |
v=$(echo ${{ inputs.version }} | cut -d. -f1,2)
echo "RAVEN_MAJOR_MINOR=$v" >> $GITHUB_ENV
[[ ${{ env.IS_NIGHTLY }} == true ]] && DOCKER_REPO="$DOCKER_REPO-nightly"
echo "DOCKER_REPO=$DOCKER_REPO" >> $GITHUB_ENV
- name: Login to docker
shell: pwsh
run: |
docker login -u ${{ env.DOCKER_USER }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
- uses: actions/checkout@v3
with:
repository: '${{ inputs.github_repository }}'
ref: "v${{ env.RAVEN_MAJOR_MINOR }}"
- name: Download package
shell: pwsh
run: |
$downloadURL="https://daily-builds.s3.amazonaws.com/RavenDB-${{ inputs.version }}-windows-x64.zip"
mkdir artifacts
Invoke-WebRequest -Uri "$downloadURL" -OutFile "artifacts\RavenDB-${{ inputs.version }}-windows-x64.zip"
- name: Build image
shell: pwsh
run: |
& .\build-nanoserver.ps1 -Repo ${{ env.DOCKER_REPO }} -WinVer ${{ matrix.data.winVer }}
working-directory: docker
- name: Publish package
shell: pwsh
run: |
& .\publish-nanoserver.ps1 -Repo ${{ env.DOCKER_REPO }} -WinVer ${{ matrix.data.winVer }}
docker logout
working-directory: docker