From d08f8fab8c978805e26437abd21c5b7ac5c3ed5b Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 15 Aug 2021 11:48:25 +0800 Subject: [PATCH] Refine Dockerfile --- .github/workflows/release.yml | 88 ++++++++++++++++++++++++++++ CHANGELOG.md | 1 + README.md | 1 + trunk/Dockerfile | 35 +++++++++++ trunk/Dockerfile.test | 13 ++++ trunk/src/core/srs_core_version4.hpp | 2 +- 6 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 trunk/Dockerfile create mode 100644 trunk/Dockerfile.test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..b7535ccc7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,88 @@ +name: "Release" + +on: + push: + tags: + - v4* + +jobs: + k8s: + name: release-k8s + runs-on: ubuntu-20.04 + + steps: + ################################################################ + # Git checkout + - name: Checkout repository + uses: actions/checkout@v2 + + ################################################################ + # Tests + - name: Build test image + run: docker build --tag srs:test -f trunk/Dockerfile.test trunk + # For utest + - name: Run SRS utest + run: docker run --rm srs:test bash -c 'make && ./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 + # The github.ref is, for example, refs/tags/v4.0.145 or refs/tags/v4.0-r8 + # Generate variables like: + # SRS_TAG=v4.0.145 + # SRS_TAG=v4.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_MAJOR=$(echo $SRS_TAG| cut -c 2) + echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV + # Build SRS image + - name: Build SRS docker image + run: | + echo "Release ossrs/srs:$SRS_TAG" + docker build --tag ossrs/srs:$SRS_TAG trunk + + ################################################################ + # 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_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 diff --git a/CHANGELOG.md b/CHANGELOG.md index e9b24cace..16dc3c755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2021-08-14, Support Github Actions to publish SRS. 4.0.155 * v4.0, 2021-08-14, RTC: Merge [#2533](https://github.com/ossrs/srs/pull/2533), fix SDP comparison bug. 4.0.154 * v4.0, 2021-08-13, RTC: Merge [#2526](https://github.com/ossrs/srs/pull/2526), fix codec issue for G.711 or H.263. 4.0.152 * v4.0, 2021-08-10, RTC: Merge [#2509](https://github.com/ossrs/srs/pull/2514), support http hooks n_play/stop/publish/unpublish. 4.0.151 diff --git a/README.md b/README.md index bbb308e26..f94f779a0 100755 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ![](http://ossrs.net/gif/v1/sls.gif?site=github.com&path=/srs/develop) [![](https://github.com/ossrs/srs/actions/workflows/codeql-analysis.yml/badge.svg?branch=develop)](https://github.com/ossrs/srs/actions?query=workflow%3ACodeQL+branch%3Adevelop) +[![](https://github.com/ossrs/srs/actions/workflows/release.yml/badge.svg)](https://github.com/ossrs/srs/actions/workflows/release.yml?query=workflow%3ARelease) [![](https://circleci.com/gh/ossrs/srs/tree/develop.svg?style=svg&circle-token=1ef1d5b5b0cde6c8c282ed856a18199f9e8f85a9)](https://circleci.com/gh/ossrs/srs/tree/develop) [![](https://codecov.io/gh/ossrs/srs/branch/develop/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/develop) [![](https://gitee.com/winlinvip/srs-wiki/raw/master/images/wechat-badge.png)](../../wikis/Contact#wechat) diff --git a/trunk/Dockerfile b/trunk/Dockerfile new file mode 100644 index 000000000..393dca737 --- /dev/null +++ b/trunk/Dockerfile @@ -0,0 +1,35 @@ +FROM ossrs/srs:dev AS build + +# Install depends tools. +RUN yum install -y gcc make gcc-c++ patch unzip perl git + +# Build and install SRS. +COPY . /trunk +WORKDIR /trunk +RUN ./configure --srt=on --jobs=2 && make -j2 && make install + +# All config files for SRS. +RUN cp -R conf /usr/local/srs/conf && \ + cp research/api-server/static-dir/index.html /usr/local/srs/objs/nginx/html/ && \ + cp research/api-server/static-dir/favicon.ico /usr/local/srs/objs/nginx/html/ && \ + cp research/players/crossdomain.xml /usr/local/srs/objs/nginx/html/ && \ + cp -R research/console /usr/local/srs/objs/nginx/html/ && \ + cp -R research/players /usr/local/srs/objs/nginx/html/ && \ + cp -R 3rdparty/signaling/www/demos /usr/local/srs/objs/nginx/html/ + +############################################################ +# dist +############################################################ +FROM centos:7 AS dist + +# Expose ports for streaming @see https://github.com/ossrs/srs#ports +EXPOSE 1935 1985 8080 8000/udp 10080/udp + +# FFMPEG 4.1 +COPY --from=build /usr/local/bin/ffmpeg /usr/local/srs/objs/ffmpeg/bin/ffmpeg +# SRS binary, config files and srs-console. +COPY --from=build /usr/local/srs /usr/local/srs + +# Default workdir and command. +WORKDIR /usr/local/srs +CMD ["./objs/srs", "-c", "conf/srs.conf"] diff --git a/trunk/Dockerfile.test b/trunk/Dockerfile.test new file mode 100644 index 000000000..1bf98f85c --- /dev/null +++ b/trunk/Dockerfile.test @@ -0,0 +1,13 @@ +FROM ossrs/srs:dev + +# Install depends tools. +RUN yum install -y gcc make gcc-c++ patch unzip perl git + +# Build and install SRS. +COPY . /trunk +WORKDIR /trunk +RUN ./configure --srt=on --utest=on --jobs=2 && make -j2 +RUN cd 3rdparty/srs-bench && make + +# Run utest +RUN ./objs/srs_utest diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 04e93422f..82bfac181 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 154 +#define VERSION_REVISION 156 #endif