From c2b133bd07cbb70302d9b130d40be64b4cb5c175 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 14 Aug 2021 20:46:52 +0800 Subject: [PATCH] Support Github Actions --- .github/workflows/release.yml | 75 +++++++++++++++++++++++++++++++++++ trunk/Dockerfile | 36 +++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 trunk/Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..00418403a4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,75 @@ +name: "Release" + +on: + push: + tags: + - v3* + +jobs: + k8s: + name: release-k8s + runs-on: ubuntu-20.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # The github.ref is, for example, refs/tags/v3.0.145 or refs/tags/v3.0-r8 + # Generate variables like: + # SRS_TAG=v3.0.145 + # SRS_TAG=v3.0-r8 + # SRS_MAJOR=3 + # @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + - name: Generate varaiables + shell: bash + 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 + + - name: Build SRS + shell: bash + run: | + echo "Release ossrs/srs:$SRS_TAG" + docker build --tag ossrs/srs:$SRS_TAG trunk + + - name: Login docker hub + uses: docker/login-action@v1 + with: + username: "${{ secrets.DOCKER_USERNAME }}" + password: "${{ secrets.DOCKER_PASSWORD }}" + - name: Push to docker hub + shell: bash + run: | + docker push ossrs/srs:$SRS_TAG + docker tag ossrs/srs:$SRS_TAG ossrs/srs:$SRS_MAJOR + docker push ossrs/srs:$SRS_MAJOR + + - 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 + shell: bash + 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 + + - name: Setup KUBCONFIG for Aliyun ACK + shell: bash + run: |- + KUBECONFIG=$RUNNER_TEMP/kubeconfig_$(date +%s) + echo "${{ secrets.KUBCONFIG }}" > $KUBECONFIG + echo "KUBECONFIG=$KUBECONFIG" >> $GITHUB_ENV + + - name: Release SRS 3.0 to Aliyun ACK + shell: bash + if: ${{ startsWith(github.ref, 'refs/tags/v3') }} + run: |- + kubectl set image deploy/srs3-deploy srs=registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG + kubectl describe deploy/srs3-deploy \ No newline at end of file diff --git a/trunk/Dockerfile b/trunk/Dockerfile new file mode 100644 index 0000000000..a48b22e798 --- /dev/null +++ b/trunk/Dockerfile @@ -0,0 +1,36 @@ +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 --jobs=2 && make -j2 && make install + +# All config files for SRS. +RUN cp -R conf /usr/local/srs/conf +# The default index.html and srs-console. +RUN cp research/api-server/static-dir/index.html /usr/local/srs/objs/nginx/html/ +RUN cp research/api-server/static-dir/favicon.ico /usr/local/srs/objs/nginx/html/ +RUN cp research/players/crossdomain.xml /usr/local/srs/objs/nginx/html/ +RUN cp -R research/console /usr/local/srs/objs/nginx/html/ +RUN cp -R research/players /usr/local/srs/objs/nginx/html/ +#RUN 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"]