Skip to content

Commit

Permalink
Support Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 14, 2021
1 parent b8177ff commit c2b133b
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions trunk/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit c2b133b

Please sign in to comment.