-
Notifications
You must be signed in to change notification settings - Fork 1
159 lines (150 loc) · 7.01 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
name: "Release"
# @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags
on:
push:
tags:
- v5*
jobs:
k8s:
name: release-k8s
runs-on: ubuntu-20.04
steps:
################################################################
# Git checkout
- name: Checkout repository
uses: actions/checkout@v2
# The github.ref is, for example, refs/tags/v4.0.145 or refs/tags/v4.0-r8
# Generate variables like:
# SRS_TAG=v4.0-r8
# SRS_TAG=v4.0.145
# SRS_VERSION=4.0.145
# SRS_VERSION=4.0-r8
# SRS_MAJOR=4
# @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-4.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-4.0.145.zip
# SRS_PACKAGE_MD5=3880a26e30b283edf05700a4e69956e5
- name: Create package zip
run: |
docker build --tag srs:pkg --build-arg version=$SRS_VERSION -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
################################################################
# 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'
################################################################
# Build
# Build SRS image
- name: Build SRS docker image
run: |
echo "Release ossrs/srs:$SRS_TAG"
docker build --tag ossrs/srs:$SRS_TAG -f trunk/Dockerfile .
################################################################
# Docker
- name: Login docker hub
uses: docker/login-action@v1
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Push to docker hub
run: |
docker push ossrs/srs:$SRS_TAG
docker tag ossrs/srs:$SRS_TAG ossrs/srs:$SRS_MAJOR
docker push ossrs/srs:$SRS_MAJOR
# Aliyun ACR
- name: Login Aliyun docker hub
uses: aliyun/acr-login@v1
with:
login-server: https://registry.cn-hangzhou.aliyuncs.com
username: "${{ secrets.ACR_USERNAME }}"
password: "${{ secrets.ACR_PASSWORD }}"
- name: Push to Aliyun docker hub
run: |
docker tag ossrs/srs:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG
docker push registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG
docker tag ossrs/srs:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_VERSION
docker push registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_VERSION
docker tag ossrs/srs:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/srs:v$SRS_MAJOR
docker push registry.cn-hangzhou.aliyuncs.com/ossrs/srs:v$SRS_MAJOR
docker tag ossrs/srs:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_MAJOR
docker push registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_MAJOR
################################################################
# K8S
- name: Setup KUBCONFIG for Aliyun ACK
run: |-
KUBECONFIG=$RUNNER_TEMP/kubeconfig_$(date +%s)
echo "${{ secrets.KUBCONFIG }}" > $KUBECONFIG
echo "KUBECONFIG=$KUBECONFIG" >> $GITHUB_ENV
# K8S for SRS 4.0
- name: Release SRS 4.0 to Aliyun ACK
if: ${{ startsWith(github.ref, 'refs/tags/v4') }}
run: |-
kubectl set image deploy/srs4-deploy srs4=registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG
kubectl describe deploy/srs4-deploy
################################################################
# Create release.
- 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 }}
## 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 }})
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 }}