From 68c0424808266371c4d8fb88daefd182e4a79d56 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 1 Jun 2024 18:24:02 +0800 Subject: [PATCH] feat: Automatically build package and upload binary files to the issue list --- .github/workflows/android.yml | 32 +++++++++++++++++ .github/workflows/linux.yml | 38 +++++++++++++++++--- .github/workflows/macos.yml | 65 ++++++++++++++++++++++++----------- .github/workflows/windows.yml | 46 ++++++++++++++++++++++--- README.md | 5 ++- README_en.md | 4 +++ dockerfile | 2 +- 7 files changed, 160 insertions(+), 32 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a4d36bcf..3296a056 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -23,3 +23,35 @@ jobs: - name: 编译 run: cd Android && ./gradlew build + + - name: 设置环境变量 + run: | + echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr -s "/\?%*:|\"<>" "_")" >> $GITHUB_ENV + echo "BRANCH2=$(echo ${GITHUB_REF#refs/heads/} )" >> $GITHUB_ENV + echo "DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV + + - name: 打包二进制 + id: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ github.workflow }}_${{ env.BRANCH }}_${{ env.DATE }} + path: Android/app/build/outputs/apk/debug/* + if-no-files-found: error + retention-days: 1 + + - name: issue评论 + if: github.event_name != 'pull_request' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: 483, + owner: context.repo.owner, + repo: context.repo.repo, + body: '- 下载地址: [${{ github.workflow }}_${{ env.BRANCH }}_${{ env.DATE }}](${{ steps.upload.outputs.artifact-url }})\n' + + '- 分支: ${{ env.BRANCH2 }}\n' + + '- git hash: ${{ github.sha }} \n' + + '- 编译日期: ${{ env.DATE }}\n' + + '- 打包ci名: ${{ github.workflow }}\n' + }) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 58580e60..96bbcadb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -25,12 +25,40 @@ jobs: path: 3rdpart/libsrtp - name: 编译 SRTP - run: cd 3rdpart/libsrtp && ./configure --enable-openssl && make -j4 && sudo make install + run: cd 3rdpart/libsrtp && ./configure --enable-openssl && make -j $(nproc) && sudo make install - name: 编译 - run: mkdir -p linux_build && cd linux_build && cmake .. -DENABLE_WEBRTC=true -DENABLE_FFMPEG=true && make -j $(nproc) + run: mkdir -p linux_build && cd linux_build && cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_FFMPEG=true && make -j $(nproc) - - name: 运行MediaServer - run: pwd && cd release/linux/Debug && sudo ./MediaServer -d & + - name: 设置环境变量 + run: | + echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr -s "/\?%*:|\"<>" "_")" >> $GITHUB_ENV + echo "BRANCH2=$(echo ${GITHUB_REF#refs/heads/} )" >> $GITHUB_ENV + echo "DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV - + - name: 打包二进制 + id: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ github.workflow }}_${{ env.BRANCH }}_${{ env.DATE }} + path: release/* + if-no-files-found: error + retention-days: 1 + + - name: issue评论 + if: github.event_name != 'pull_request' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: 483, + owner: context.repo.owner, + repo: context.repo.repo, + body: '- 下载地址: [${{ github.workflow }}_${{ env.BRANCH }}_${{ env.DATE }}](${{ steps.upload.outputs.artifact-url }})\n' + + '- 分支: ${{ env.BRANCH2 }}\n' + + '- git hash: ${{ github.sha }} \n' + + '- 编译日期: ${{ env.DATE }}\n' + + '- 打包ci名: ${{ github.workflow }}\n' + + '- 说明: 本二进制在ubuntu-20.04(x64)上编译,请确保您的机器系统不低于此版本,并提前`sudo apt-get install -y libssl-dev libsdl-dev libavcodec-dev libavutil-dev libswscale-dev libresample-dev libusrsctp-dev`安装依赖项\n' + }) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 84638370..adda4d8c 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -13,27 +13,52 @@ jobs: - name: 下载submodule源码 run: mv -f .gitmodules_github .gitmodules && git submodule sync && git submodule update --init -# - name: 安装brew -# run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -# -# - name: brew安装依赖库(非必选) -# run: brew update && brew install cmake openssl sdl2 ffmpeg - -# - name: 下载 SRTP -# uses: actions/checkout@v2 -# with: -# repository: cisco/libsrtp -# fetch-depth: 1 -# ref: v2.3.0 -# path: 3rdpart/libsrtp -# -# - name: 编译 SRTP -# run: cd 3rdpart/libsrtp && ./configure --enable-openssl && make -j4 && sudo make install + - name: 配置 vcpkg + uses: lukka/run-vcpkg@v7 + with: + vcpkgDirectory: '${{github.workspace}}/vcpkg' + vcpkgTriplet: arm64-osx + # 2024.06.01 + vcpkgGitCommitId: '47364fbc300756f64f7876b549d9422d5f3ec0d3' + vcpkgArguments: 'openssl libsrtp[openssl]' - name: 编译 - run: mkdir -p build && cd build && cmake .. && make -j $(nproc) + uses: lukka/run-cmake@v3 + with: + useVcpkgToolchainFile: true + buildDirectory: '${{github.workspace}}/build' + cmakeAppendedArgs: '' + cmakeBuildType: 'Release' - - name: 运行MediaServer - run: pwd && cd release/darwin/Debug && sudo ./MediaServer -d & + - name: 设置环境变量 + run: | + echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr -s "/\?%*:|\"<>" "_")" >> $GITHUB_ENV + echo "BRANCH2=$(echo ${GITHUB_REF#refs/heads/} )" >> $GITHUB_ENV + echo "DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV - + - name: 打包二进制 + id: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ github.workflow }}_${{ env.BRANCH }}_${{ env.DATE }} + path: release/* + if-no-files-found: error + retention-days: 1 + + - name: issue评论 + if: github.event_name != 'pull_request' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: 483, + owner: context.repo.owner, + repo: context.repo.repo, + body: '- 下载地址: [${{ github.workflow }}_${{ env.BRANCH }}_${{ env.DATE }}](${{ steps.upload.outputs.artifact-url }})\n' + + '- 分支: ${{ env.BRANCH2 }}\n' + + '- git hash: ${{ github.sha }} \n' + + '- 编译日期: ${{ env.DATE }}\n' + + '- 打包ci名: ${{ github.workflow }}\n' + + '- 说明: 此二进制为arm64版本\n' + }) \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ec366084..662d211c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -17,14 +17,50 @@ jobs: with: vcpkgDirectory: '${{github.workspace}}/vcpkg' vcpkgTriplet: x64-windows-static - # 2021.05.12 - vcpkgGitCommitId: '5568f110b509a9fd90711978a7cb76bae75bb092' - vcpkgArguments: 'openssl libsrtp' + # 2024.06.01 + vcpkgGitCommitId: '47364fbc300756f64f7876b549d9422d5f3ec0d3' + vcpkgArguments: 'openssl libsrtp[openssl]' - name: 编译 uses: lukka/run-cmake@v3 with: useVcpkgToolchainFile: true buildDirectory: '${{github.workspace}}/build' - cmakeAppendedArgs: '-DCMAKE_ENABLE_WEBRTC:BOOL=ON' - cmakeBuildType: 'RelWithDebInfo' + cmakeAppendedArgs: '' + cmakeBuildType: 'Release' + + - name: 设置环境变量 + run: | + $dateString = Get-Date -Format "yyyy-MM-dd" + $branch = $env:GITHUB_REF -replace "refs/heads/", "" -replace "[\\/\\\?\%\*:\|\x22<>]", "_" + $branch2 = $env:GITHUB_REF -replace "refs/heads/", "" + echo "BRANCH=$branch" >> $env:GITHUB_ENV + echo "BRANCH2=$branch2" >> $env:GITHUB_ENV + echo "DATE=$dateString" >> $env:GITHUB_ENV + + - name: 打包二进制 + id: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ github.workflow }}_${{ env.BRANCH }}_${{ env.DATE }} + path: release/* + if-no-files-found: error + retention-days: 1 + + - name: issue评论 + if: github.event_name != 'pull_request' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: 483, + owner: context.repo.owner, + repo: context.repo.repo, + body: '- 下载地址: [${{ github.workflow }}_${{ env.BRANCH }}_${{ env.DATE }}](${{ steps.upload.outputs.artifact-url }})\n' + + '- 分支: ${{ env.BRANCH2 }}\n' + + '- git hash: ${{ github.sha }} \n' + + '- 编译日期: ${{ env.DATE }}\n' + + '- 打包ci名: ${{ github.workflow }}\n' + + '- 说明: 此二进制为x64版本\n' + }) diff --git a/README.md b/README.md index 59fd30a4..60e8078b 100644 --- a/README.md +++ b/README.md @@ -159,12 +159,15 @@ - 2、作为独立的流媒体服务器使用,不想做c/c++开发的,可以参考 [restful api](https://github.com/ZLMediaKit/ZLMediaKit/wiki/MediaServer支持的HTTP-API) 和 [web hook](https://github.com/ZLMediaKit/ZLMediaKit/wiki/MediaServer支持的HTTP-HOOK-API ). - 3、如果想做c/c++开发,添加业务逻辑增加功能,可以参考这里的[测试程序](https://github.com/ZLMediaKit/ZLMediaKit/tree/master/tests). +## 二进制文件下载 +zlmediakit采用 github action 持续集成自动编译打包上传编译产出包,请在[issue列表](https://github.com/ZLMediaKit/ZLMediaKit/issues/483)下载最新sdk库文件以及可执行文件。 + ## Docker 镜像 你可以从Docker Hub下载已经编译好的镜像并启动它: ```bash -#此镜像为github持续集成自动编译推送,跟代码(master分支)保持最新状态 +#此镜像为github action 持续集成自动编译推送,跟代码(master分支)保持最新状态 docker run -id -p 1935:1935 -p 8080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:master ``` diff --git a/README_en.md b/README_en.md index b41eea20..865a2e7f 100644 --- a/README_en.md +++ b/README_en.md @@ -324,6 +324,10 @@ git submodule update --init }); ``` + +## Binary file download +zlmediakit uses github action to continuously integrate automatic compilation package and upload the compilation output package. Please download the latest sdk library file and executable file at [issue list] (https://github.com/ZLMediaKit/ZLMediaKit/issues/483). + ## Docker Image You can download the pre-compiled image from Docker Hub and start it: diff --git a/dockerfile b/dockerfile index f02a8fb7..cc45df3d 100644 --- a/dockerfile +++ b/dockerfile @@ -43,7 +43,7 @@ WORKDIR /opt/media/ZLMediaKit # 3rdpart init WORKDIR /opt/media/ZLMediaKit/3rdpart -RUN wget https://mirror.ghproxy.com/https://github.com/cisco/libsrtp/archive/v2.3.0.tar.gz -O libsrtp-2.3.0.tar.gz && \ +RUN wget https://github.com/cisco/libsrtp/archive/v2.3.0.tar.gz -O libsrtp-2.3.0.tar.gz && \ tar xfv libsrtp-2.3.0.tar.gz && \ mv libsrtp-2.3.0 libsrtp && \ cd libsrtp && ./configure --enable-openssl && make -j $(nproc) && make install