From 70ff7360835001e3163a5a3c1606a4cb4a9d00cc Mon Sep 17 00:00:00 2001 From: Anim Mouse Date: Fri, 1 Mar 2024 23:59:44 +0800 Subject: [PATCH] Use cron for schedule, use automated version checking, and refactor workflow --- .github/workflows/build-ffmpeg.yaml | 141 ++++++++++++++++++ .github/workflows/build-on-pull-request.yaml | 131 ----------------- .github/workflows/build-on-push.yaml | 143 ------------------- dependencies.sh | 5 - 4 files changed, 141 insertions(+), 279 deletions(-) create mode 100644 .github/workflows/build-ffmpeg.yaml delete mode 100644 .github/workflows/build-on-pull-request.yaml delete mode 100644 .github/workflows/build-on-push.yaml delete mode 100755 dependencies.sh diff --git a/.github/workflows/build-ffmpeg.yaml b/.github/workflows/build-ffmpeg.yaml new file mode 100644 index 0000000..021fc36 --- /dev/null +++ b/.github/workflows/build-ffmpeg.yaml @@ -0,0 +1,141 @@ +name: Build FFmpeg stable +on: + schedule: + - cron: '7 11 * * 0' + workflow_dispatch: + watch: + types: [started] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Get FFmpeg latest version + id: ffmpeg-info + run: | + version=$(curl -s https://endoflife.date/api/ffmpeg.json | jq -r .[0].latest) + echo version=$version >> $GITHUB_OUTPUT + + - name: Get ffmpeg-windows-build-helpers latest commit + id: ffmpeg-helper-info + run: | + git_sha=$(gh api repos/rdp/ffmpeg-windows-build-helpers/commits/master -q .sha) + echo git-sha=$git_sha >> $GITHUB_OUTPUT + echo git-sha-short=${git_sha::7} >> $GITHUB_OUTPUT + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Get ffmpeg-stable-autobuild latest build + id: ffmpeg-autobuild-info + run: | + tag_name=$(gh api repos/$GITHUB_REPOSITORY/releases/latest -q .tag_name) + echo version=${tag_name:25} >> $GITHUB_OUTPUT + echo helper-git-sha=${tag_name:17:7} >> $GITHUB_OUTPUT + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Check if there is newer version or commit + run: > + [[ ${{ steps.ffmpeg-info.outputs.version }} != ${{ steps.ffmpeg-autobuild-info.outputs.version }} ]] || + [[ ${{ steps.ffmpeg-helper-info.outputs.git-sha-short }} != ${{ steps.ffmpeg-autobuild-info.outputs.helper-git-sha }} ]] + + outputs: + version: ${{ steps.ffmpeg-info.outputs.version }} + helper-git-sha: ${{ steps.ffmpeg-helper-info.outputs.git-sha }} + helper-git-sha-short: ${{ steps.ffmpeg-helper-info.outputs.git-sha-short }} + + build: + needs: check + runs-on: ubuntu-latest + strategy: + matrix: + os: [win64, win32] + + steps: + - name: Checkout ffmpeg-windows-build-helpers + uses: actions/checkout@v4 + with: + repository: rdp/ffmpeg-windows-build-helpers + ref: ${{ needs.check.outputs.helper-git-sha }} + persist-credentials: false + + - name: Install dependencies + run: | + sudo apt-get -qq update + sudo apt-get -qq install ragel cvs yasm pax nasm gperf autogen autoconf-archive + sudo -H pip3 -qq install meson ninja + + - name: Get current date & time before build + id: date-time-before + run: echo date-time=$(date +'%Y-%m-%d %H:%M') >> $GITHUB_OUTPUT + + - name: Compile FFmpeg using ffmpeg-windows-build-helpers + run: ./cross_compile_ffmpeg.sh --ffmpeg-git-checkout-version=n${{ needs.check.outputs.version }} --gcc-cpu-count=$(nproc) --disable-nonfree=n --sandbox-ok=y --compiler-flavors=${{ matrix.os }} + + - name: Get current date & time after build + id: date-time-after + run: | + echo date-time=$(date +'%Y-%m-%d %H:%M') >> $GITHUB_OUTPUT + echo date-time-tag=$(date +'%Y-%m-%d-%H-%M') >> $GITHUB_OUTPUT + + - name: Upload FFmpeg binaries + uses: actions/upload-artifact@v4 + with: + name: ffmpeg-${{ matrix.os }} + path: | + sandbox/${{ matrix.os }}/ffmpeg_git_with_fdk_aac_n${{ needs.check.outputs.version }}/ffmpeg.exe + sandbox/${{ matrix.os }}/ffmpeg_git_with_fdk_aac_n${{ needs.check.outputs.version }}/ffprobe.exe + sandbox/${{ matrix.os }}/ffmpeg_git_with_fdk_aac_n${{ needs.check.outputs.version }}/ffplay.exe + if-no-files-found: error + retention-days: 1 + + outputs: + date-time-before: ${{ steps.date-time-before.outputs.date-time }} + date-time-after: ${{ steps.date-time-after.outputs.date-time }} + date-time-after-tag: ${{ steps.date-time-after.outputs.date-time-tag }} + + archive: + needs: [check, build] + runs-on: ubuntu-latest + strategy: + matrix: + os: [win64, win32] + + steps: + - name: Download FFmpeg binaries + uses: actions/download-artifact@v4 + with: + name: ffmpeg-${{ matrix.os }} + + - name: 7-Zip FFmpeg binaries + run: 7z a -mx9 ffmpeg-${{ needs.check.outputs.version }}-${{ needs.check.outputs.helper-git-sha-short }}-${{ matrix.os }}-nonfree.7z ffmpeg.exe ffprobe.exe ffplay.exe + + - name: Upload FFmpeg archive + uses: actions/upload-artifact@v4 + with: + name: ffmpeg-archive-${{ matrix.os }} + path: ffmpeg-${{ needs.check.outputs.version }}-${{ needs.check.outputs.helper-git-sha-short }}-${{ matrix.os }}-nonfree.7z + retention-days: 1 + compression-level: 0 + + release: + needs: [check, build, archive] + runs-on: ubuntu-latest + steps: + - name: Download FFmpeg archives + uses: actions/download-artifact@v4 + with: + pattern: ffmpeg-archive-* + merge-multiple: true + + - name: Release FFmpeg archives + run: | + gh release create "${{ needs.build.outputs.date-time-after-tag }}-${{ needs.check.outputs.helper-git-sha-short }}-${{ needs.check.outputs.version }}" \ + "ffmpeg-${{ needs.check.outputs.version }}-${{ needs.check.outputs.helper-git-sha-short }}-win64-nonfree.7z" \ + "ffmpeg-${{ needs.check.outputs.version }}-${{ needs.check.outputs.helper-git-sha-short }}-win32-nonfree.7z" \ + -n "FFmpeg nonfree ${{ needs.check.outputs.version }} built on ${{ needs.build.outputs.date-time-after }} started at ${{ needs.build.outputs.date-time-before }} + Using ffmpeg-windows-build-helpers git-${{ needs.check.outputs.helper-git-sha }}" \ + -t "${{ needs.check.outputs.version }} ${{ needs.build.outputs.date-time-after }} ${{ needs.build.outputs.helper-git-sha }}" + env: + GITHUB_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} \ No newline at end of file diff --git a/.github/workflows/build-on-pull-request.yaml b/.github/workflows/build-on-pull-request.yaml deleted file mode 100644 index 3d93fbb..0000000 --- a/.github/workflows/build-on-pull-request.yaml +++ /dev/null @@ -1,131 +0,0 @@ -name: Build FFmpeg on pull request -on: - pull_request_target: - paths: - - ffmpeg-windows-build-helpers - - dependencies.sh - - .github/workflows/build-on-push.yaml - - .github/workflows/build-on-pull-request.yaml - -jobs: - build: - runs-on: ubuntu-latest - if: github.actor == 'dependabot[bot]' || github.actor == 'AnimMouse' - strategy: - matrix: - os: [win64, win32] - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: true - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - persist-credentials: false - - - name: Install dependencies - run: ./dependencies.sh - - - name: Get current ffmpeg-windows-build-helpers git commit SHA - id: helper-git-sha - working-directory: ffmpeg-windows-build-helpers - run: echo git-sha=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT - - - name: Move ffmpeg-windows-build-helpers - run: mv -v ./ffmpeg-windows-build-helpers/* ./ - - - name: Get current date & time before build - id: date-time-before - run: echo date-time=$(date +'%Y-%m-%d %H:%M') >> $GITHUB_OUTPUT - - - name: Compile FFmpeg using ffmpeg-windows-build-helpers - run: ./cross_compile_ffmpeg.sh --ffmpeg-git-checkout-version=${{ vars.FFMPEG_VERSION }} --gcc-cpu-count=$(nproc) --disable-nonfree=n --sandbox-ok=y --compiler-flavors=${{ matrix.os }} - - - name: Get current date & time after build - id: date-time-after - run: | - echo date-time=$(date +'%Y-%m-%d %H:%M') >> $GITHUB_OUTPUT - echo date-time-tag=$(date +'%Y-%m-%d-%H-%M') >> $GITHUB_OUTPUT - - - name: Upload FFmpeg ${{ matrix.os }} nonfree - uses: actions/upload-artifact@v4 - with: - name: ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ steps.helper-git-sha.outputs.git-sha }}-${{ matrix.os }}-nonfree - path: sandbox/${{ matrix.os }}/ffmpeg_git_with_fdk_aac_${{ vars.FFMPEG_VERSION }}/ffmpeg.exe - - - name: Upload FFprobe ${{ matrix.os }} nonfree - uses: actions/upload-artifact@v4 - with: - name: ffprobe-${{ vars.FFMPEG_VERSION }}-${{ steps.helper-git-sha.outputs.git-sha }}-${{ matrix.os }}-nonfree - path: sandbox/${{ matrix.os }}/ffmpeg_git_with_fdk_aac_${{ vars.FFMPEG_VERSION }}/ffprobe.exe - - - name: Upload FFplay ${{ matrix.os }} nonfree - uses: actions/upload-artifact@v4 - with: - name: ffplay-${{ vars.FFMPEG_VERSION }}-${{ steps.helper-git-sha.outputs.git-sha }}-${{ matrix.os }}-nonfree - path: sandbox/${{ matrix.os }}/ffmpeg_git_with_fdk_aac_${{ vars.FFMPEG_VERSION }}/ffplay.exe - - outputs: - date-time-before: ${{ steps.date-time-before.outputs.date-time }} - date-time-after: ${{ steps.date-time-after.outputs.date-time }} - date-time-after-tag: ${{ steps.date-time-after.outputs.date-time-tag }} - helper-git-sha: ${{ steps.helper-git-sha.outputs.git-sha }} - - archive: - needs: build - runs-on: ubuntu-latest - strategy: - matrix: - os: [win64, win32] - - steps: - - name: Download FFmpeg ${{ matrix.os }} nonfree - uses: actions/download-artifact@v4 - with: - name: ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree - - - name: Download FFprobe ${{ matrix.os }} nonfree - uses: actions/download-artifact@v4 - with: - name: ffprobe-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree - - - name: Download FFplay ${{ matrix.os }} nonfree - uses: actions/download-artifact@v4 - with: - name: ffplay-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree - - - name: 7-Zip FFmpeg ${{ matrix.os }} nonfree - run: 7z a ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree.7z ffmpeg.exe ffprobe.exe ffplay.exe -mx9 - - - name: Upload FFmpeg archive ${{ matrix.os }} nonfree - uses: actions/upload-artifact@v4 - with: - name: ffmpeg-archive-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree - path: ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree.7z - - release: - needs: [build, archive] - runs-on: ubuntu-latest - steps: - - name: Download FFmpeg archive win64 - uses: actions/download-artifact@v4 - with: - name: ffmpeg-archive-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-win64-nonfree - - - name: Download FFmpeg archive win32 - uses: actions/download-artifact@v4 - with: - name: ffmpeg-archive-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-win32-nonfree - - - name: Release - run: | - gh release create "a-${{ needs.build.outputs.date-time-after-tag }}" \ - "ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-win64-nonfree.7z" \ - "ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-win32-nonfree.7z" \ - -n "FFmpeg nonfree ${{ vars.FFMPEG_VERSION }} built on ${{ needs.build.outputs.date-time-after }} started at ${{ needs.build.outputs.date-time-before }} - Using ffmpeg-windows-build-helpers git-${{ needs.build.outputs.helper-git-sha }}" \ - -p -t "Auto ${{ vars.FFMPEG_VERSION }} ${{ needs.build.outputs.date-time-after }} ${{ needs.build.outputs.helper-git-sha }}" - env: - GITHUB_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} \ No newline at end of file diff --git a/.github/workflows/build-on-push.yaml b/.github/workflows/build-on-push.yaml deleted file mode 100644 index 85a3a00..0000000 --- a/.github/workflows/build-on-push.yaml +++ /dev/null @@ -1,143 +0,0 @@ -name: Build FFmpeg on push -on: - push: - paths: - - ffmpeg-windows-build-helpers - - dependencies.sh - - .github/workflows/build-on-push.yaml - branches-ignore: - - dependabot/** - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - os: [win64, win32] - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: true - persist-credentials: false - - - name: Install dependencies - run: ./dependencies.sh - - - name: Get current ffmpeg-windows-build-helpers git commit SHA - id: helper-git-sha - working-directory: ffmpeg-windows-build-helpers - run: echo git-sha=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT - - - name: Move ffmpeg-windows-build-helpers - run: mv -v ./ffmpeg-windows-build-helpers/* ./ - - - name: Get current date & time before build - id: date-time-before - run: echo date-time=$(date +'%Y-%m-%d %H:%M') >> $GITHUB_OUTPUT - - - name: Compile FFmpeg using ffmpeg-windows-build-helpers - run: ./cross_compile_ffmpeg.sh --ffmpeg-git-checkout-version=${{ vars.FFMPEG_VERSION }} --gcc-cpu-count=$(nproc) --disable-nonfree=n --sandbox-ok=y --compiler-flavors=${{ matrix.os }} - - - name: Get current date & time after build - id: date-time-after - run: | - echo date-time=$(date +'%Y-%m-%d %H:%M') >> $GITHUB_OUTPUT - echo date-time-tag=$(date +'%Y-%m-%d-%H-%M') >> $GITHUB_OUTPUT - - - name: Upload FFmpeg ${{ matrix.os }} nonfree - uses: actions/upload-artifact@v4 - with: - name: ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ steps.helper-git-sha.outputs.git-sha }}-${{ matrix.os }}-nonfree - path: sandbox/${{ matrix.os }}/ffmpeg_git_with_fdk_aac_${{ vars.FFMPEG_VERSION }}/ffmpeg.exe - - - name: Upload FFprobe ${{ matrix.os }} nonfree - uses: actions/upload-artifact@v4 - with: - name: ffprobe-${{ vars.FFMPEG_VERSION }}-${{ steps.helper-git-sha.outputs.git-sha }}-${{ matrix.os }}-nonfree - path: sandbox/${{ matrix.os }}/ffmpeg_git_with_fdk_aac_${{ vars.FFMPEG_VERSION }}/ffprobe.exe - - - name: Upload FFplay ${{ matrix.os }} nonfree - uses: actions/upload-artifact@v4 - with: - name: ffplay-${{ vars.FFMPEG_VERSION }}-${{ steps.helper-git-sha.outputs.git-sha }}-${{ matrix.os }}-nonfree - path: sandbox/${{ matrix.os }}/ffmpeg_git_with_fdk_aac_${{ vars.FFMPEG_VERSION }}/ffplay.exe - - outputs: - date-time-before: ${{ steps.date-time-before.outputs.date-time }} - date-time-after: ${{ steps.date-time-after.outputs.date-time }} - date-time-after-tag: ${{ steps.date-time-after.outputs.date-time-tag }} - helper-git-sha: ${{ steps.helper-git-sha.outputs.git-sha }} - - archive: - needs: build - runs-on: ubuntu-latest - strategy: - matrix: - os: [win64, win32] - - steps: - - name: Download FFmpeg ${{ matrix.os }} nonfree - uses: actions/download-artifact@v4 - with: - name: ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree - - - name: Download FFprobe ${{ matrix.os }} nonfree - uses: actions/download-artifact@v4 - with: - name: ffprobe-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree - - - name: Download FFplay ${{ matrix.os }} nonfree - uses: actions/download-artifact@v4 - with: - name: ffplay-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree - - - name: 7-Zip FFmpeg ${{ matrix.os }} nonfree - run: 7z a ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree.7z ffmpeg.exe ffprobe.exe ffplay.exe -mx9 - - - name: Upload FFmpeg archive ${{ matrix.os }} nonfree - uses: actions/upload-artifact@v4 - with: - name: ffmpeg-archive-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree - path: ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-${{ matrix.os }}-nonfree.7z - - release: - needs: [build, archive] - runs-on: ubuntu-latest - steps: - - name: Download FFmpeg archive win64 - uses: actions/download-artifact@v4 - with: - name: ffmpeg-archive-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-win64-nonfree - - - name: Download FFmpeg archive win32 - uses: actions/download-artifact@v4 - with: - name: ffmpeg-archive-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-win32-nonfree - - - name: Release - run: | - gh release create "m-${{ needs.build.outputs.date-time-after-tag }}" \ - "ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-win64-nonfree.7z" \ - "ffmpeg-${{ vars.FFMPEG_VERSION }}-${{ needs.build.outputs.helper-git-sha }}-win32-nonfree.7z" \ - -n "FFmpeg nonfree ${{ vars.FFMPEG_VERSION }} built on ${{ needs.build.outputs.date-time-after }} started at ${{ needs.build.outputs.date-time-before }} - Using ffmpeg-windows-build-helpers git-${{ needs.build.outputs.helper-git-sha }}" \ - -t "${{ vars.FFMPEG_VERSION }} ${{ needs.build.outputs.date-time-after }} ${{ needs.build.outputs.helper-git-sha }}" - env: - GITHUB_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - - delete_old: - name: Delete older pre-releases - runs-on: ubuntu-latest - steps: - - name: Delete older pre-releases - uses: dev-drprasad/delete-older-releases@v0.3.2 - with: - keep_latest: 1 - delete_tags: true - delete_tag_pattern: a - env: - GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/dependencies.sh b/dependencies.sh deleted file mode 100755 index 5570ecf..0000000 --- a/dependencies.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -sudo apt-get -qq update -sudo apt-get -qq upgrade -sudo apt-get -qq install ragel cvs yasm pax nasm gperf autogen autoconf-archive -sudo -H pip3 -qq install meson ninja \ No newline at end of file