-
Notifications
You must be signed in to change notification settings - Fork 0
489 lines (448 loc) · 21.8 KB
/
release.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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
name: "Release"
# @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags
on:
push:
tags:
- v5*
jobs:
test:
name: test
runs-on: ubuntu-20.04
steps:
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Git checkout
- name: Checkout repository
uses: actions/checkout@v2
# The github.ref is, for example, refs/tags/v5.0.145 or refs/tags/v5.0-r8
# Generate variables like:
# SRS_TAG=v5.0-r8
# SRS_TAG=v5.0.145
# SRS_VERSION=5.0.145
# SRS_VERSION=5.0-r8
# SRS_MAJOR=5
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Generate varaiables
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
SRS_VERSION=$(echo ${SRS_TAG}| sed 's/^v//g')
echo "SRS_VERSION=$SRS_VERSION" >> $GITHUB_ENV
SRS_MAJOR=$(echo $SRS_TAG| cut -c 2)
echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
# Tests
- name: Build test image
run: docker build --tag srs:test -f trunk/Dockerfile.test .
# For utest
- name: Run SRS utest
run: docker run --rm srs:test bash -c 'make utest && ./objs/srs_utest'
# For regression-test
- name: Run SRS regression-test
run: |
docker run --rm srs:test bash -c 'make && ./objs/srs -c conf/regression-test.conf && \
cd 3rdparty/srs-bench && make && ./objs/srs_test -test.v'
docker-srs:
name: docker-srs
runs-on: ubuntu-20.04
needs:
- test
steps:
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Git checkout
- name: Checkout repository
uses: actions/checkout@v2
# See https://github.com/crazy-max/ghaction-docker-buildx#moved-to-docker-organization
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# The github.ref is, for example, refs/tags/v5.0.145 or refs/tags/v5.0-r8
# Generate variables like:
# SRS_TAG=v5.0-r8
# SRS_TAG=v5.0.145
# SRS_VERSION=5.0.145
# SRS_VERSION=5.0-r8
# SRS_MAJOR=5
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Generate varaiables
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
SRS_VERSION=$(echo ${SRS_TAG}| sed 's/^v//g')
echo "SRS_VERSION=$SRS_VERSION" >> $GITHUB_ENV
SRS_MAJOR=$(echo $SRS_TAG| cut -c 2)
echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Create main images for Docker
- name: Login to docker hub
uses: docker/login-action@v1
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Build and push images to Docker hub
env:
PACKAGER: ${{ secrets.SRS_PACKAGER_DOCKER }}
run: |
echo "Release ossrs/srs:$SRS_TAG"
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
--output "type=image,push=true" \
-t ossrs/srs:$SRS_TAG --build-arg SRS_AUTO_PACKAGER=$PACKAGER -f trunk/Dockerfile .
# Docker alias images
# TODO: FIXME: If stable, please set the latest from 4.0 to 5.0
- name: Docker alias images for ossrs/srs
uses: akhilerm/tag-push-action@v2.0.0
with:
src: ossrs/srs:${{ env.SRS_TAG }}
dst: |
ossrs/srs:${{ env.SRS_VERSION }}
ossrs/srs:${{ env.SRS_MAJOR }}
ossrs/srs:v${{ env.SRS_MAJOR }}
# Aliyun ACR
# TODO: FIXME: If stable, please set the latest from 4.0 to 5.0
- name: Login aliyun hub
uses: docker/login-action@v1
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: "${{ secrets.ACR_USERNAME }}"
password: "${{ secrets.ACR_PASSWORD }}"
- name: Push to Aliyun registry for ossrs/srs
uses: akhilerm/tag-push-action@v2.0.0
with:
src: ossrs/srs:${{ env.SRS_TAG }}
dst: |
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:${{ env.SRS_TAG }}
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:${{ env.SRS_VERSION }}
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:${{ env.SRS_MAJOR }}
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:v${{ env.SRS_MAJOR }}
docker-droplet:
name: docker-droplet
runs-on: ubuntu-20.04
needs:
- test
steps:
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Git checkout
- name: Checkout repository
uses: actions/checkout@v2
# See https://github.com/crazy-max/ghaction-docker-buildx#moved-to-docker-organization
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# The github.ref is, for example, refs/tags/v5.0.145 or refs/tags/v5.0-r8
# Generate variables like:
# SRS_TAG=v5.0-r8
# SRS_TAG=v5.0.145
# SRS_VERSION=5.0.145
# SRS_VERSION=5.0-r8
# SRS_MAJOR=5
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Generate varaiables
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
SRS_VERSION=$(echo ${SRS_TAG}| sed 's/^v//g')
echo "SRS_VERSION=$SRS_VERSION" >> $GITHUB_ENV
SRS_MAJOR=$(echo $SRS_TAG| cut -c 2)
echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Create main images for Docker
- name: Login to docker hub
uses: docker/login-action@v1
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Build and push images to Docker hub
env:
PACKAGER_DROPLET: ${{ secrets.SRS_PACKAGER_DROPLET }}
run: |
echo "Release ossrs/droplet:$SRS_TAG"
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
--output "type=image,push=true" \
-t ossrs/droplet:$SRS_TAG --build-arg SRS_AUTO_PACKAGER=$PACKAGER_DROPLET -f trunk/Dockerfile .
# Docker alias images
# TODO: FIXME: If stable, please set the latest from 4.0 to 5.0
- name: Docker alias images for ossrs/droplet
uses: akhilerm/tag-push-action@v2.0.0
with:
src: ossrs/droplet:${{ env.SRS_TAG }}
dst: |
ossrs/droplet:${{ env.SRS_VERSION }}
ossrs/droplet:${{ env.SRS_MAJOR }}
ossrs/droplet:v${{ env.SRS_MAJOR }}
# Aliyun ACR
# TODO: FIXME: If stable, please set the latest from 4.0 to 5.0
- name: Login aliyun hub
uses: docker/login-action@v1
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: "${{ secrets.ACR_USERNAME }}"
password: "${{ secrets.ACR_PASSWORD }}"
- name: Push to Aliyun registry for ossrs/droplet
uses: akhilerm/tag-push-action@v2.0.0
with:
src: ossrs/droplet:${{ env.SRS_TAG }}
dst: |
registry.cn-hangzhou.aliyuncs.com/ossrs/droplet:${{ env.SRS_TAG }}
registry.cn-hangzhou.aliyuncs.com/ossrs/droplet:${{ env.SRS_VERSION }}
registry.cn-hangzhou.aliyuncs.com/ossrs/droplet:${{ env.SRS_MAJOR }}
registry.cn-hangzhou.aliyuncs.com/ossrs/droplet:v${{ env.SRS_MAJOR }}
docker-lighthouse:
name: docker-lighthouse
runs-on: ubuntu-20.04
needs:
- test
steps:
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Git checkout
- name: Checkout repository
uses: actions/checkout@v2
# See https://github.com/crazy-max/ghaction-docker-buildx#moved-to-docker-organization
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# The github.ref is, for example, refs/tags/v5.0.145 or refs/tags/v5.0-r8
# Generate variables like:
# SRS_TAG=v5.0-r8
# SRS_TAG=v5.0.145
# SRS_VERSION=5.0.145
# SRS_VERSION=5.0-r8
# SRS_MAJOR=5
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Generate varaiables
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
SRS_VERSION=$(echo ${SRS_TAG}| sed 's/^v//g')
echo "SRS_VERSION=$SRS_VERSION" >> $GITHUB_ENV
SRS_MAJOR=$(echo $SRS_TAG| cut -c 2)
echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Create main images for Docker
- name: Login to docker hub
uses: docker/login-action@v1
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Build and push images to Docker hub
env:
PACKAGER_LIGHTHOUSE: ${{ secrets.SRS_PACKAGER_LIGHTHOUSE }}
run: |
echo "Release ossrs/lighthouse:$SRS_TAG"
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
--output "type=image,push=true" \
-t ossrs/lighthouse:$SRS_TAG --build-arg SRS_AUTO_PACKAGER=$PACKAGER_LIGHTHOUSE -f trunk/Dockerfile .
# Docker alias images
# TODO: FIXME: If stable, please set the latest from 4.0 to 5.0
- name: Docker alias images for ossrs/lighthouse
uses: akhilerm/tag-push-action@v2.0.0
with:
src: ossrs/lighthouse:${{ env.SRS_TAG }}
dst: |
ossrs/lighthouse:${{ env.SRS_VERSION }}
ossrs/lighthouse:${{ env.SRS_MAJOR }}
ossrs/lighthouse:v${{ env.SRS_MAJOR }}
# Aliyun ACR
# TODO: FIXME: If stable, please set the latest from 4.0 to 5.0
- name: Login aliyun hub
uses: docker/login-action@v1
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: "${{ secrets.ACR_USERNAME }}"
password: "${{ secrets.ACR_PASSWORD }}"
- name: Push to Aliyun registry for ossrs/lighthouse
uses: akhilerm/tag-push-action@v2.0.0
with:
src: ossrs/lighthouse:${{ env.SRS_TAG }}
dst: |
registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse:${{ env.SRS_TAG }}
registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse:${{ env.SRS_VERSION }}
registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse:${{ env.SRS_MAJOR }}
registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse:v${{ env.SRS_MAJOR }}
update:
name: update
runs-on: ubuntu-20.04
needs:
- test
- docker-srs
- docker-lighthouse
- docker-droplet
steps:
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Git checkout
- name: Checkout repository
uses: actions/checkout@v2
# The github.ref is, for example, refs/tags/v5.0.145 or refs/tags/v5.0-r8
# Generate variables like:
# SRS_TAG=v5.0-r8
# SRS_TAG=v5.0.145
# SRS_VERSION=5.0.145
# SRS_VERSION=5.0-r8
# SRS_MAJOR=5
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Generate varaiables
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
SRS_VERSION=$(echo ${SRS_TAG}| sed 's/^v//g')
echo "SRS_VERSION=$SRS_VERSION" >> $GITHUB_ENV
SRS_MAJOR=$(echo $SRS_TAG| cut -c 2)
echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Generate variables like:
# SRS_DROPLET_EIP=1.2.3.4
- name: Build variables for lh.ossrs.net
run: |
SRS_DROPLET_EIP=$(dig +short lh.ossrs.net)
echo "SRS_DROPLET_EIP=$SRS_DROPLET_EIP" >> $GITHUB_ENV
- name: Release to lh.ossrs.net
uses: appleboy/ssh-action@master
with:
host: ${{ env.SRS_DROPLET_EIP }}
username: root
key: ${{ secrets.DIGITALOCEAN_SSHKEY }}
port: 22
envs: SRS_MAJOR
timeout: 60s
command_timeout: 30m
script: |
docker pull registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_MAJOR
docker rm -f srs-server
#
# Cleanup old docker images.
for image in $(docker images |grep '<none>' |awk '{print $3}'); do
docker rmi -f $image
echo "Remove image $image, r0=$?"
done
release:
name: release
runs-on: ubuntu-20.04
needs:
- update
steps:
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Git checkout
- name: Checkout repository
uses: actions/checkout@v2
# The github.ref is, for example, refs/tags/v5.0.145 or refs/tags/v5.0-r8
# Generate variables like:
# SRS_TAG=v5.0-r8
# SRS_TAG=v5.0.145
# SRS_VERSION=5.0.145
# SRS_VERSION=5.0-r8
# SRS_MAJOR=5
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Generate varaiables
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
SRS_VERSION=$(echo ${SRS_TAG}| sed 's/^v//g')
echo "SRS_VERSION=$SRS_VERSION" >> $GITHUB_ENV
SRS_MAJOR=$(echo $SRS_TAG| cut -c 2)
echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
##################################################################################################################
##################################################################################################################
##################################################################################################################
# Create source tar for release. Note that it's for OpenWRT package srs-server, so the filename MUST be
# srs-server-xxx.tar.gz, because the package is named srs-server.
# Generate variables like:
# SRS_SOURCE_TAR=srs-server-5.0.145.tar.gz
# SRS_SOURCE_MD5=83e38700a80a26e30b2df054e69956e5
- name: Create source tar.gz
run: |
DEST_DIR=srs-server-$SRS_VERSION && mkdir -p $DEST_DIR &&
cp README.md $DEST_DIR && cp LICENSE $DEST_DIR && cp -R trunk $DEST_DIR/trunk &&
(cd $DEST_DIR/trunk/3rdparty && rm -rf *.zip openssl-*.gz srs-bench) &&
tar zcf ${DEST_DIR}.tar.gz ${DEST_DIR} && du -sh ${DEST_DIR}* && rm -rf ${DEST_DIR} &&
echo "SRS_SOURCE_TAR=${DEST_DIR}.tar.gz" >> $GITHUB_ENV &&
echo "SRS_SOURCE_MD5=$(md5sum ${DEST_DIR}.tar.gz| awk '{print $1}')" >> $GITHUB_ENV
# Create package tar for release
# Generate variables like:
# SRS_PACKAGE_ZIP=SRS-CentOS7-x86_64-5.0.145.zip
# SRS_PACKAGE_MD5=3880a26e30b283edf05700a4e69956e5
- name: Create package zip
env:
PACKAGER: ${{ secrets.SRS_PACKAGER_BINARY }}
run: |
docker build --tag srs:pkg --build-arg version=$SRS_VERSION --build-arg SRS_AUTO_PACKAGER=$PACKAGER -f trunk/Dockerfile.pkg . &&
SRS_PACKAGE_ZIP=SRS-CentOS7-x86_64-$SRS_VERSION.zip &&
docker run --rm -v $(pwd):/output srs:pkg cp objs/$SRS_PACKAGE_ZIP /output/ &&
du -sh $SRS_PACKAGE_ZIP &&
echo "SRS_PACKAGE_ZIP=$SRS_PACKAGE_ZIP" >> $GITHUB_ENV &&
echo "SRS_PACKAGE_MD5=$(md5sum $SRS_PACKAGE_ZIP| awk '{print $1}')" >> $GITHUB_ENV
# Create release.
# TODO: FIXME: Refine the release when 5.0 released
# TODO: FIXME: Change prerelease to false when 5.0 released
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
[${{ github.event.head_commit.message }}](https://github.com/ossrs/srs/commit/${{ github.sha }})
## Resource
* Source: ${{ env.SRS_SOURCE_MD5 }} [${{ env.SRS_SOURCE_TAR }}](https://github.com/ossrs/srs/releases/download/${{ env.SRS_TAG }}/${{ env.SRS_SOURCE_TAR }})
* Binary: ${{ env.SRS_PACKAGE_MD5 }} [${{ env.SRS_PACKAGE_ZIP }}](https://github.com/ossrs/srs/releases/download/${{ env.SRS_TAG }}/${{ env.SRS_PACKAGE_ZIP }})
## Docker
* China: [docker pull registry.cn-hangzhou.aliyuncs.com/ossrs/srs:${{ env.SRS_MAJOR }}](https://github.com/ossrs/srs/wiki/v5_CN_Home#docker)
* China: [docker pull registry.cn-hangzhou.aliyuncs.com/ossrs/srs:${{ env.SRS_TAG }}](https://github.com/ossrs/srs/wiki/v5_CN_Home#docker)
* Global: [docker pull ossrs/srs:${{ env.SRS_MAJOR }}](https://github.com/ossrs/srs/wiki/v5_EN_Home#docker)
* Global: [docker pull ossrs/srs:${{ env.SRS_TAG }}](https://github.com/ossrs/srs/wiki/v5_EN_Home#docker)
## Doc
* [FAQ](https://github.com/ossrs/srs/issues/2716), [Features](https://github.com/ossrs/srs/blob/${{ github.sha }}/trunk/doc/Features.md#features) or [ChangeLogs](https://github.com/ossrs/srs/blob/${{ github.sha }}/trunk/doc/CHANGELOG.md#changelog)
draft: false
prerelease: true
# Upload release source files
- name: Upload Release Assets Source
id: upload-release-assets-source
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: ${{ env.SRS_SOURCE_TAR }}
# Upload release package files
- name: Upload Release Assets Package
id: upload-release-assets-package
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: ${{ env.SRS_PACKAGE_ZIP }}
done:
name: done
runs-on: ubuntu-20.04
needs:
- release
steps:
- run: echo 'All done'