|
| 1 | +--- |
| 2 | +# Update a repository's build-deps submodule to the latest tag and refresh related prebuilt dependencies. |
| 3 | + |
| 4 | +name: Update build-deps |
| 5 | +permissions: {} |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + repo: |
| 11 | + description: 'Repository to update.' |
| 12 | + required: true |
| 13 | + type: choice |
| 14 | + options: |
| 15 | + - Sunshine |
| 16 | + |
| 17 | +jobs: |
| 18 | + update-build-deps: |
| 19 | + name: Update build-deps - ${{ inputs.repo }} |
| 20 | + permissions: {} |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 25 | + with: |
| 26 | + repository: ${{ github.repository_owner }}/${{ inputs.repo }} |
| 27 | + token: ${{ secrets.GH_BOT_TOKEN }} |
| 28 | + fetch-depth: 0 |
| 29 | + path: repo |
| 30 | + |
| 31 | + - name: Update build-deps |
| 32 | + id: update-build-deps |
| 33 | + working-directory: repo |
| 34 | + run: | |
| 35 | + git submodule update --init third-party/build-deps |
| 36 | + git -C third-party/build-deps fetch --force --tags origin |
| 37 | +
|
| 38 | + current_commit=$(git -C third-party/build-deps rev-parse HEAD) |
| 39 | + latest_tag=$(git -C third-party/build-deps tag --sort=-version:refname | sed -n '1p') |
| 40 | +
|
| 41 | + if [ -z "${latest_tag}" ]; then |
| 42 | + echo "No build-deps tags were found." |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | +
|
| 46 | + latest_commit=$(git -C third-party/build-deps rev-list -n 1 "${latest_tag}") |
| 47 | + echo "version=${latest_tag}" >> "${GITHUB_OUTPUT}" |
| 48 | +
|
| 49 | + if [ "${current_commit}" = "${latest_commit}" ]; then |
| 50 | + echo "build-deps is already at ${latest_tag}." |
| 51 | + echo "updated=false" >> "${GITHUB_OUTPUT}" |
| 52 | + exit 0 |
| 53 | + fi |
| 54 | +
|
| 55 | + git -C third-party/build-deps checkout --detach "${latest_tag}" |
| 56 | + echo "updated=true" >> "${GITHUB_OUTPUT}" |
| 57 | +
|
| 58 | + - name: Get build-deps release |
| 59 | + id: get-release |
| 60 | + if: steps.update-build-deps.outputs.updated == 'true' |
| 61 | + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 |
| 62 | + env: |
| 63 | + BUILD_DEPS_VERSION: ${{ steps.update-build-deps.outputs.version }} |
| 64 | + with: |
| 65 | + github-token: ${{ secrets.GH_BOT_TOKEN }} |
| 66 | + script: | |
| 67 | + const release = await github.rest.repos.getReleaseByTag({ |
| 68 | + owner: context.repo.owner, |
| 69 | + repo: 'build-deps', |
| 70 | + tag: process.env.BUILD_DEPS_VERSION |
| 71 | + }); |
| 72 | +
|
| 73 | + core.setOutput('body', release.data.body || ''); |
| 74 | +
|
| 75 | + - name: Update Flatpak FFmpeg prebuilts |
| 76 | + if: steps.update-build-deps.outputs.updated == 'true' |
| 77 | + env: |
| 78 | + BUILD_DEPS_VERSION: ${{ steps.update-build-deps.outputs.version }} |
| 79 | + working-directory: repo |
| 80 | + run: | |
| 81 | + module=packaging/linux/flatpak/modules/ffmpeg.json |
| 82 | + release_url="https://github.com/LizardByte/build-deps/releases/download/${BUILD_DEPS_VERSION}" |
| 83 | +
|
| 84 | + if [ ! -f "${module}" ]; then |
| 85 | + echo "Flatpak FFmpeg module not found at ${module}." |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | +
|
| 89 | + for arch in x86_64 aarch64; do |
| 90 | + matches=$(jq --arg arch "${arch}" \ |
| 91 | + '[.sources[] | select(.["only-arches"] == [$arch])] | length' "${module}") |
| 92 | + if [ "${matches}" -ne 1 ]; then |
| 93 | + echo "Expected one Flatpak FFmpeg source for ${arch}, found ${matches}." |
| 94 | + exit 1 |
| 95 | + fi |
| 96 | + done |
| 97 | +
|
| 98 | + x86_64_url="${release_url}/Linux-x86_64-ffmpeg.tar.gz" |
| 99 | + aarch64_url="${release_url}/Linux-aarch64-ffmpeg.tar.gz" |
| 100 | +
|
| 101 | + download_and_hash() { |
| 102 | + local arch="$1" |
| 103 | + local url="$2" |
| 104 | + local output="${RUNNER_TEMP}/Linux-${arch}-ffmpeg.tar.gz" |
| 105 | +
|
| 106 | + curl --fail --location --silent --show-error --retry 3 "${url}" --output "${output}" |
| 107 | + sha256sum "${output}" | awk '{print $1}' |
| 108 | + } |
| 109 | +
|
| 110 | + x86_64_sha=$(download_and_hash x86_64 "${x86_64_url}") |
| 111 | + aarch64_sha=$(download_and_hash aarch64 "${aarch64_url}") |
| 112 | +
|
| 113 | + jq \ |
| 114 | + --arg x86_64_url "${x86_64_url}" \ |
| 115 | + --arg x86_64_sha "${x86_64_sha}" \ |
| 116 | + --arg aarch64_url "${aarch64_url}" \ |
| 117 | + --arg aarch64_sha "${aarch64_sha}" \ |
| 118 | + ' |
| 119 | + .sources |= map( |
| 120 | + if .["only-arches"] == ["x86_64"] then |
| 121 | + .url = $x86_64_url | .sha256 = $x86_64_sha |
| 122 | + elif .["only-arches"] == ["aarch64"] then |
| 123 | + .url = $aarch64_url | .sha256 = $aarch64_sha |
| 124 | + else |
| 125 | + . |
| 126 | + end |
| 127 | + ) |
| 128 | + ' "${module}" > "${RUNNER_TEMP}/ffmpeg.json" |
| 129 | + mv "${RUNNER_TEMP}/ffmpeg.json" "${module}" |
| 130 | +
|
| 131 | + - name: Create/Update Pull Request |
| 132 | + id: create-pr |
| 133 | + if: steps.update-build-deps.outputs.updated == 'true' |
| 134 | + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 |
| 135 | + with: |
| 136 | + author: "${{ vars.GH_BOT_NAME }} <${{ secrets.GH_BOT_EMAIL }}>" |
| 137 | + committer: "${{ vars.GH_BOT_NAME }} <${{ secrets.GH_BOT_EMAIL }}>" |
| 138 | + path: "repo" |
| 139 | + token: ${{ secrets.GH_BOT_TOKEN }} |
| 140 | + commit-message: "chore(deps): Update build-deps to ${{ steps.update-build-deps.outputs.version }}" |
| 141 | + branch: bot/bump-build-deps-${{ steps.update-build-deps.outputs.version }} |
| 142 | + delete-branch: true |
| 143 | + title: "chore(deps): Update build-deps to ${{ steps.update-build-deps.outputs.version }}" |
| 144 | + body: ${{ steps.get-release.outputs.body }} |
| 145 | + labels: dependencies |
0 commit comments