Codex: Modernize GitHub Actions workflows. #186
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Release" | ||
| # @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags | ||
| on: | ||
| push: | ||
| tags: | ||
| - v7* | ||
| # For draft, need write permission. | ||
| permissions: | ||
| contents: write | ||
| jobs: | ||
| envs: | ||
| name: envs | ||
| steps: | ||
| ################################################################################################################## | ||
| # Git checkout | ||
| - name: Checkout repository | ||
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | ||
| # The github.ref is, for example, refs/tags/v6.0.145 or refs/tags/v6.0-r8 | ||
| # Generate variables like: | ||
| # SRS_TAG=v6.0-r8 | ||
| # SRS_TAG=v6.0.145 | ||
| # SRS_VERSION=6.0.145 | ||
| # SRS_VERSION=6.0-r8 | ||
| # SRS_MAJOR=6 | ||
| # SRS_XYZ=6.0.145 | ||
| # @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 | ||
| VFILE="trunk/src/core/srs_core_version6.hpp" | ||
| SRS_X=$(cat $VFILE |grep VERSION_MAJOR |awk '{print $3}') | ||
| SRS_Y=$(cat $VFILE |grep VERSION_MINOR |awk '{print $3}') | ||
| SRS_Z=$(cat $VFILE |grep VERSION_REVISION |awk '{print $3}') | ||
| SRS_XYZ=$SRS_X.$SRS_Y.$SRS_Z | ||
| echo "SRS_XYZ=$SRS_XYZ" >> $GITHUB_ENV | ||
| # Map a step output to a job output, see https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs | ||
| outputs: | ||
| SRS_TAG: ${{ env.SRS_TAG }} | ||
| SRS_VERSION: ${{ env.SRS_VERSION }} | ||
| SRS_MAJOR: ${{ env.SRS_MAJOR }} | ||
| SRS_XYZ: ${{ env.SRS_XYZ }} | ||
| runs-on: ubuntu-22.04 | ||
| test: | ||
| name: test | ||
| needs: | ||
| - envs | ||
| steps: | ||
| ################################################################################################################## | ||
| - name: Covert output to env | ||
| run: | | ||
| echo "SRS_TAG=${{ needs.envs.outputs.SRS_TAG }}" >> $GITHUB_ENV | ||
| echo "SRS_VERSION=${{ needs.envs.outputs.SRS_VERSION }}" >> $GITHUB_ENV | ||
| echo "SRS_MAJOR=${{ needs.envs.outputs.SRS_MAJOR }}" >> $GITHUB_ENV | ||
| ################################################################################################################## | ||
| # Git checkout | ||
| - name: Checkout repository | ||
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | ||
| ################################################################################################################## | ||
| # 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 && sleep 10 && \ | ||
| cd 3rdparty/srs-bench && make && ./objs/srs_test -test.v' | ||
| runs-on: ubuntu-22.04 | ||
| draft: | ||
| name: draft | ||
| needs: | ||
| - envs | ||
| steps: | ||
| - name: Create release draft | ||
| uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| allowUpdates: true | ||
| tag: ${{ github.ref }} | ||
| draft: true | ||
| prerelease: true | ||
| runs-on: ubuntu-22.04 | ||
| linux: | ||
| name: linux | ||
| needs: | ||
| - envs | ||
| - draft | ||
| steps: | ||
| ################################################################################################################## | ||
| - name: Covert output to env | ||
| run: | | ||
| echo "SRS_TAG=${{ needs.envs.outputs.SRS_TAG }}" >> $GITHUB_ENV | ||
| echo "SRS_VERSION=${{ needs.envs.outputs.SRS_VERSION }}" >> $GITHUB_ENV | ||
| echo "SRS_MAJOR=${{ needs.envs.outputs.SRS_MAJOR }}" >> $GITHUB_ENV | ||
| ################################################################################################################## | ||
| # Git checkout | ||
| - name: Checkout repository | ||
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | ||
| ################################################################################################################## | ||
| # 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-6.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-6.0.145.zip | ||
| # SRS_PACKAGE_MD5=3880a26e30b283edf05700a4e69956e5 | ||
| - name: Create package zip | ||
| env: | ||
| PACKAGER: ${{ secrets.SRS_PACKAGER_BINARY }} | ||
| run: | | ||
| docker build --tag srs:pkg --build-arg version=$SRS_VERSION --build-arg SRS_AUTO_PACKAGER=$PACKAGER -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 | ||
| ################################################################################################################## | ||
| - name: Upload release assets | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh release upload "$GITHUB_REF" \ | ||
| "$SRS_PACKAGE_ZIP" "$SRS_SOURCE_TAR" \ | ||
| --clobber --repo "$GITHUB_REPOSITORY" | ||
| # Map a step output to a job output, see https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs | ||
| outputs: | ||
| SRS_PACKAGE_ZIP: ${{ env.SRS_PACKAGE_ZIP }} | ||
| SRS_PACKAGE_MD5: ${{ env.SRS_PACKAGE_MD5 }} | ||
| SRS_SOURCE_TAR: ${{ env.SRS_SOURCE_TAR }} | ||
| SRS_SOURCE_MD5: ${{ env.SRS_SOURCE_MD5 }} | ||
| runs-on: ubuntu-22.04 | ||
| docker-srs: | ||
| name: docker-srs | ||
| needs: | ||
| - envs | ||
| steps: | ||
| ################################################################################################################## | ||
| - name: Covert output to env | ||
| run: | | ||
| echo "SRS_TAG=${{ needs.envs.outputs.SRS_TAG }}" >> $GITHUB_ENV | ||
| echo "SRS_VERSION=${{ needs.envs.outputs.SRS_VERSION }}" >> $GITHUB_ENV | ||
| echo "SRS_MAJOR=${{ needs.envs.outputs.SRS_MAJOR }}" >> $GITHUB_ENV | ||
| echo "SRS_XYZ=${{ needs.envs.outputs.SRS_XYZ }}" >> $GITHUB_ENV | ||
| ################################################################################################################## | ||
| # Git checkout | ||
| - name: Checkout repository | ||
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | ||
| # See https://github.com/crazy-max/ghaction-docker-buildx#moved-to-docker-organization | ||
| # https://github.com/docker/setup-qemu-action | ||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 | ||
| # https://github.com/docker/setup-buildx-action | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 | ||
| ################################################################################################################## | ||
| # Create main images for Docker | ||
| - name: Login to docker hub | ||
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | ||
| with: | ||
| username: "${{ secrets.DOCKER_USERNAME }}" | ||
| password: "${{ secrets.DOCKER_PASSWORD }}" | ||
| - name: Build and push images to Docker hub | ||
| env: | ||
| PACKAGER: ${{ secrets.SRS_PACKAGER_DOCKER }} | ||
| run: | | ||
| echo "Release ossrs/srs:$SRS_TAG" | ||
| docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \ | ||
| --output "type=image,push=true,oci-artifact=false" \ | ||
| -t ossrs/srs:$SRS_TAG \ | ||
| --build-arg SRS_AUTO_PACKAGER=$PACKAGER \ | ||
| --build-arg IMAGE=ossrs/srs:ubuntu20 \ | ||
| --build-arg CONFARGS='--sanitizer=off --gb28181=on --rtsp=on' \ | ||
| -f Dockerfile . | ||
| # Docker alias images | ||
| # TODO: FIXME: If stable, please set the latest from 5.0 to 6.0 | ||
| - name: Docker alias images for ossrs/srs | ||
| uses: akhilerm/tag-push-action@eadeefebd39db8a47e146115649adae1fce576a6 # v2.3.0 | ||
| with: | ||
| src: ossrs/srs:${{ env.SRS_TAG }} | ||
| dst: | | ||
| ossrs/srs:${{ env.SRS_VERSION }} | ||
| ossrs/srs:${{ env.SRS_MAJOR }} | ||
| ossrs/srs:v${{ env.SRS_MAJOR }} | ||
| ossrs/srs:${{ env.SRS_XYZ }} | ||
| ossrs/srs:v${{ env.SRS_XYZ }} | ||
| runs-on: ubuntu-22.04 | ||
| release: | ||
| name: release | ||
| needs: | ||
| - docker-srs | ||
| - envs | ||
| - draft | ||
| - linux | ||
| - test | ||
| steps: | ||
| ################################################################################################################## | ||
| - name: Covert output to env | ||
| run: | | ||
| echo "SRS_TAG=${{ needs.envs.outputs.SRS_TAG }}" >> $GITHUB_ENV | ||
| echo "SRS_VERSION=${{ needs.envs.outputs.SRS_VERSION }}" >> $GITHUB_ENV | ||
| echo "SRS_MAJOR=${{ needs.envs.outputs.SRS_MAJOR }}" >> $GITHUB_ENV | ||
| echo "SRS_XYZ=${{ needs.envs.outputs.SRS_XYZ }}" >> $GITHUB_ENV | ||
| echo "SRS_PACKAGE_ZIP=${{ needs.linux.outputs.SRS_PACKAGE_ZIP }}" >> $GITHUB_ENV | ||
| echo "SRS_PACKAGE_MD5=${{ needs.linux.outputs.SRS_PACKAGE_MD5 }}" >> $GITHUB_ENV | ||
| echo "SRS_SOURCE_TAR=${{ needs.linux.outputs.SRS_SOURCE_TAR }}" >> $GITHUB_ENV | ||
| echo "SRS_SOURCE_MD5=${{ needs.linux.outputs.SRS_SOURCE_MD5 }}" >> $GITHUB_ENV | ||
| ################################################################################################################## | ||
| # Git checkout | ||
| - name: Checkout repository | ||
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | ||
| # Create release. | ||
| # TODO: FIXME: Refine the release when 6.0 released | ||
| # TODO: FIXME: Change prerelease to false and makeLatest to true when 6.0 released | ||
| - name: Update release | ||
| id: update_release | ||
| uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| allowUpdates: true | ||
| tag: ${{ github.ref }} | ||
| name: Release ${{ env.SRS_TAG }} | ||
| body: | | ||
| If you would like to support SRS, please consider contributing to our [OpenCollective](https://opencollective.com/srs-server). | ||
| [${{ github.sha }}](https://github.com/ossrs/srs/commit/${{ github.sha }}) | ||
| ${{ 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 }}) | ||
| ## Resource Mirror: gitee.com | ||
| * Source: ${{ env.SRS_SOURCE_MD5 }} [${{ env.SRS_SOURCE_TAR }}](https://gitee.com/ossrs/srs/releases/download/${{ env.SRS_TAG }}/${{ env.SRS_SOURCE_TAR }}) | ||
| * Binary: ${{ env.SRS_PACKAGE_MD5 }} [${{ env.SRS_PACKAGE_ZIP }}](https://gitee.com/ossrs/srs/releases/download/${{ env.SRS_TAG }}/${{ env.SRS_PACKAGE_ZIP }}) | ||
| ## Docker | ||
| * [docker pull ossrs/srs:${{ env.SRS_MAJOR }}](https://ossrs.io/lts/en-us/docs/v7/doc/getting-started) | ||
| * [docker pull ossrs/srs:${{ env.SRS_TAG }}](https://ossrs.io/lts/en-us/docs/v7/doc/getting-started) | ||
| * [docker pull ossrs/srs:${{ env.SRS_XYZ }}](https://ossrs.io/lts/en-us/docs/v7/doc/getting-started) | ||
| ## Usage | ||
| * [AI Guide](https://github.com/ossrs/srs#ai-agent) | ||
| draft: false | ||
| prerelease: true | ||
| makeLatest: false | ||
| runs-on: ubuntu-22.04 | ||
| release-done: | ||
| runs-on: ubuntu-22.04 | ||
| needs: | ||
| - update | ||
| - release | ||
| steps: | ||
| - run: echo 'All done' | ||