Skip to content

Commit 2b0f56b

Browse files
feat: add workflow to update build-deps submodule
1 parent 7b7641d commit 2b0f56b

2 files changed

Lines changed: 152 additions & 1 deletion

File tree

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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+
for (const arch of ['x86_64', 'aarch64']) {
76+
const name = `Linux-${arch}-ffmpeg.tar.gz`;
77+
const assets = release.data.assets.filter(asset => asset.name === name);
78+
79+
if (assets.length !== 1) {
80+
throw new Error(`Expected one release asset named ${name}, found ${assets.length}.`);
81+
}
82+
83+
const asset = assets[0];
84+
const digest = asset.digest || '';
85+
const [algorithm, hash] = digest.split(':', 2);
86+
87+
if (algorithm !== 'sha256' || !/^[0-9a-f]{64}$/i.test(hash)) {
88+
throw new Error(`Release asset ${name} does not have a valid SHA-256 digest.`);
89+
}
90+
91+
core.setOutput(`${arch}_url`, asset.browser_download_url);
92+
core.setOutput(`${arch}_sha`, hash.toLowerCase());
93+
}
94+
95+
- name: Update Flatpak FFmpeg prebuilts
96+
if: steps.update-build-deps.outputs.updated == 'true'
97+
env:
98+
AARCH64_SHA: ${{ steps.get-release.outputs.aarch64_sha }}
99+
AARCH64_URL: ${{ steps.get-release.outputs.aarch64_url }}
100+
X86_64_SHA: ${{ steps.get-release.outputs.x86_64_sha }}
101+
X86_64_URL: ${{ steps.get-release.outputs.x86_64_url }}
102+
working-directory: repo
103+
run: |
104+
module=packaging/linux/flatpak/modules/ffmpeg.json
105+
106+
if [ ! -f "${module}" ]; then
107+
echo "Flatpak FFmpeg module not found at ${module}."
108+
exit 1
109+
fi
110+
111+
for arch in x86_64 aarch64; do
112+
matches=$(jq --arg arch "${arch}" \
113+
'[.sources[] | select(.["only-arches"] == [$arch])] | length' "${module}")
114+
if [ "${matches}" -ne 1 ]; then
115+
echo "Expected one Flatpak FFmpeg source for ${arch}, found ${matches}."
116+
exit 1
117+
fi
118+
done
119+
120+
jq \
121+
--arg x86_64_url "${X86_64_URL}" \
122+
--arg x86_64_sha "${X86_64_SHA}" \
123+
--arg aarch64_url "${AARCH64_URL}" \
124+
--arg aarch64_sha "${AARCH64_SHA}" \
125+
'
126+
.sources |= map(
127+
if .["only-arches"] == ["x86_64"] then
128+
.url = $x86_64_url | .sha256 = $x86_64_sha
129+
elif .["only-arches"] == ["aarch64"] then
130+
.url = $aarch64_url | .sha256 = $aarch64_sha
131+
else
132+
.
133+
end
134+
)
135+
' "${module}" > "${RUNNER_TEMP}/ffmpeg.json"
136+
mv "${RUNNER_TEMP}/ffmpeg.json" "${module}"
137+
138+
- name: Create/Update Pull Request
139+
id: create-pr
140+
if: steps.update-build-deps.outputs.updated == 'true'
141+
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
142+
with:
143+
author: "${{ vars.GH_BOT_NAME }} <${{ secrets.GH_BOT_EMAIL }}>"
144+
committer: "${{ vars.GH_BOT_NAME }} <${{ secrets.GH_BOT_EMAIL }}>"
145+
path: "repo"
146+
token: ${{ secrets.GH_BOT_TOKEN }}
147+
commit-message: "chore(deps): Update build-deps to ${{ steps.update-build-deps.outputs.version }}"
148+
branch: bot/bump-build-deps-${{ steps.update-build-deps.outputs.version }}
149+
delete-branch: true
150+
title: "chore(deps): Update build-deps to ${{ steps.update-build-deps.outputs.version }}"
151+
body: ${{ steps.get-release.outputs.body }}
152+
labels: dependencies

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
</div>
1010

1111
<div align="center">
12-
<a href="https://docs.lizardbyte.dev"><img src="https://img.shields.io/readthedocs/lizardbyte?label=Docs&style=for-the-badge&logo=readthedocs" alt="Read the Docs"></a>
1312
<a href="https://sonarcloud.io/project/overview?id=LizardByte_.github"><img src="https://img.shields.io/sonar/quality_gate/LizardByte_.github?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarqubecloud&label=sonarcloud" alt="SonarCloud"></a>
1413
</div>
1514

0 commit comments

Comments
 (0)