Skip to content

Commit 4930b39

Browse files
committed
CI: Add Flatpak aarch64
Building through QEMU emulation is really slow. So to avoid timing out the job (6h), the original job is split in two. The first job build dependencies (4-5h), if the cache already exist the build is skipped. And the second job build CEF and OBS Studio by relying on the cache of the first job (2-3h). This separation is done by modifying the manifest in the first job to build only dependencies with a fake "obs" module/command. aarch64 builds are not enabled by default on the main workflow, it can be enabled with a dedicated label on PRs.
1 parent 033cc6a commit 4930b39

File tree

2 files changed

+169
-12
lines changed

2 files changed

+169
-12
lines changed

.github/workflows/flatpak.yml

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,71 @@ jobs:
4242
* ) echo 'valid_tag=false' >> $GITHUB_OUTPUT ;;
4343
esac
4444
45+
prepare:
46+
name: Build Dependencies
47+
runs-on: [ubuntu-latest]
48+
needs: check_tag
49+
if: fromJSON(needs.check_tag.outputs.valid_tag)
50+
container:
51+
image: bilelmoussaoui/flatpak-github-actions:kde-6.4
52+
options: --privileged
53+
strategy:
54+
matrix:
55+
arch: [x86_64, aarch64]
56+
outputs:
57+
cache_key: ${{ steps.setup.outputs.cache_key }}
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v3
61+
with:
62+
submodules: 'recursive'
63+
64+
- name: 'Setup build environment'
65+
id: setup
66+
env:
67+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }}
69+
run: |
70+
if [[ "${{ matrix.arch }}" != "x86_64" ]]; then
71+
dnf install -y -q jq gh docker
72+
else
73+
dnf install -y -q jq gh
74+
fi
75+
gh extension install actions/gh-actions-cache
76+
77+
git config --global --add safe.directory $GITHUB_WORKSPACE
78+
79+
KEY="$CACHE_KEY-${{ matrix.arch }}"
80+
CACHE_HIT=$(gh actions-cache list --key $KEY | grep -q $KEY && echo 'true' || echo 'false')
81+
82+
echo "cache_key=$CACHE_KEY" >> $GITHUB_OUTPUT
83+
echo "skip_build=$CACHE_HIT" >> $GITHUB_OUTPUT
84+
85+
- name: Setup QEMU
86+
if: ${{ (matrix.arch != 'x86_64') && !fromJSON(steps.setup.outputs.skip_build) }}
87+
uses: docker/setup-qemu-action@v2
88+
with:
89+
platforms: arm64
90+
91+
- name: 'Shorten Manifest'
92+
if: ${{ !fromJSON(steps.setup.outputs.skip_build) }}
93+
run: |
94+
jq 'del(.modules[-2:]) | .modules += [{"name": "obs", "buildsystem": "simple", "build-commands": ["cp -a /usr/bin/ls /app/bin/obs"]}]' CI/flatpak/com.obsproject.Studio.json > tmp.json
95+
mv tmp.json CI/flatpak/com.obsproject.Studio.json
96+
97+
- name: Build Flatpak Manifest
98+
if: ${{ !fromJSON(steps.setup.outputs.skip_build) }}
99+
uses: flatpak/flatpak-github-actions/flatpak-builder@v5
100+
with:
101+
build-bundle: false
102+
manifest-path: CI/flatpak/com.obsproject.Studio.json
103+
cache-key: ${{ steps.setup.outputs.cache_key }}
104+
arch: ${{ matrix.arch }}
105+
45106
publish:
46107
name: Publish to Flathub
47108
runs-on: [ubuntu-latest]
48-
needs: check_tag
109+
needs: [check_tag, prepare]
49110
if: fromJSON(needs.check_tag.outputs.valid_tag)
50111
env:
51112
FLATPAK_BUILD_PATH: flatpak_app/files/share
@@ -55,6 +116,7 @@ jobs:
55116
strategy:
56117
matrix:
57118
branch: ${{ fromJSON(needs.check_tag.outputs.matrix) }}
119+
arch: [x86_64, aarch64]
58120
steps:
59121
- name: Checkout
60122
uses: actions/checkout@v3
@@ -64,17 +126,27 @@ jobs:
64126
- name: 'Setup build environment'
65127
id: setup
66128
run: |
129+
[[ "${{ matrix.arch }}" != "x86_64" ]] && dnf install -y -q docker
130+
67131
git config --global --add safe.directory $GITHUB_WORKSPACE
68-
echo "commitHash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT
132+
133+
echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT
134+
135+
- name: Setup QEMU
136+
if: ${{ matrix.arch != 'x86_64' }}
137+
uses: docker/setup-qemu-action@v2
138+
with:
139+
platforms: arm64
69140

70141
- name: Build Flatpak Manifest
71142
uses: flatpak/flatpak-github-actions/flatpak-builder@v5
72143
with:
73-
bundle: obs-studio-${{ steps.setup.outputs.commitHash }}.flatpak
144+
bundle: obs-studio-${{ steps.setup.outputs.git_hash }}.flatpak
74145
manifest-path: CI/flatpak/com.obsproject.Studio.json
75-
cache-key: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }}
146+
cache-key: ${{ needs.prepare.outputs.cache_key }}
76147
mirror-screenshots-url: https://dl.flathub.org/repo/screenshots
77148
branch: ${{ matrix.branch }}
149+
arch: ${{ matrix.arch }}
78150

79151
- name: Validate AppStream
80152
shell: bash
@@ -91,7 +163,7 @@ jobs:
91163
92164
- name: Commit screenshots to the OSTree repository
93165
run: |
94-
ostree commit --repo=repo --canonical-permissions --branch=screenshots/x86_64 flatpak_app/screenshots
166+
ostree commit --repo=repo --canonical-permissions --branch=screenshots/${{ matrix.arch }} flatpak_app/screenshots
95167
96168
- name: Publish to Flathub Beta
97169
uses: flatpak/flatpak-github-actions/flat-manager@v5

.github/workflows/main.yml

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
runs-on: [ubuntu-22.04]
7070
outputs:
7171
create_artifacts: ${{ steps.config.outputs.create_artifacts }}
72+
flatpak_matrix: ${{ steps.config.outputs.flatpak_matrix }}
7273
cache_date: ${{ steps.config.outputs.cache_date }}
7374
steps:
7475
- name: 'Configure Build Jobs'
@@ -80,8 +81,15 @@ jobs:
8081
else
8182
echo 'create_artifacts=false' >> $GITHUB_OUTPUT
8283
fi
84+
85+
if test -n "$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s "${{ github.event.pull_request.url }}" | jq -e '.labels[] | select(.name == "Flatpak aarch64")')"; then
86+
echo 'flatpak_matrix=["x86_64", "aarch64"]' >> $GITHUB_OUTPUT
87+
else
88+
echo 'flatpak_matrix=["x86_64"]' >> $GITHUB_OUTPUT
89+
fi
8390
else
8491
echo 'create_artifacts=true' >> $GITHUB_OUTPUT
92+
echo 'flatpak_matrix=["x86_64"]' >> $GITHUB_OUTPUT
8593
fi
8694
echo "cache_date=$(date +"%Y-%m-%d")" >> $GITHUB_OUTPUT
8795
@@ -362,8 +370,8 @@ jobs:
362370
name: 'obs-studio-windows-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}'
363371
path: '${{ env.FILE_NAME }}'
364372

365-
linux_package:
366-
name: '02 - Flatpak'
373+
flatpak_deps_build:
374+
name: '02 - Flatpak Dependencies'
367375
runs-on: [ubuntu-latest]
368376
needs: [config, clang_check]
369377
defaults:
@@ -372,6 +380,74 @@ jobs:
372380
container:
373381
image: bilelmoussaoui/flatpak-github-actions:kde-6.4
374382
options: --privileged
383+
strategy:
384+
matrix:
385+
arch: ${{ fromJSON(needs.config.outputs.flatpak_matrix) }}
386+
outputs:
387+
cache_key: ${{ steps.setup.outputs.cache_key }}
388+
steps:
389+
390+
- name: 'Checkout'
391+
uses: actions/checkout@v3
392+
with:
393+
submodules: 'recursive'
394+
fetch-depth: 0
395+
396+
- name: 'Setup build environment'
397+
id: setup
398+
env:
399+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
400+
CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }}
401+
run: |
402+
if [[ "${{ matrix.arch }}" != "x86_64" ]]; then
403+
dnf install -y -q jq gh docker
404+
else
405+
dnf install -y -q jq gh
406+
fi
407+
gh extension install actions/gh-actions-cache
408+
409+
git config --global --add safe.directory $GITHUB_WORKSPACE
410+
411+
KEY="$CACHE_KEY-${{ matrix.arch }}"
412+
CACHE_HIT=$(gh actions-cache list --key $KEY | grep -q $KEY && echo 'true' || echo 'false')
413+
414+
echo "cache_key=$CACHE_KEY" >> $GITHUB_OUTPUT
415+
echo "skip_build=$CACHE_HIT" >> $GITHUB_OUTPUT
416+
417+
- name: Setup QEMU
418+
if: ${{ (matrix.arch != 'x86_64') && !fromJSON(steps.setup.outputs.skip_build) }}
419+
uses: docker/setup-qemu-action@v2
420+
with:
421+
platforms: arm64
422+
423+
- name: 'Shorten Manifest'
424+
if: ${{ !fromJSON(steps.setup.outputs.skip_build) }}
425+
run: |
426+
jq 'del(.modules[-2:]) | .modules += [{"name": "obs", "buildsystem": "simple", "build-commands": ["cp -a /usr/bin/ls /app/bin/obs"]}]' CI/flatpak/com.obsproject.Studio.json > tmp.json
427+
mv tmp.json CI/flatpak/com.obsproject.Studio.json
428+
429+
- name: Build Flatpak Manifest
430+
if: ${{ !fromJSON(steps.setup.outputs.skip_build) }}
431+
uses: flatpak/flatpak-github-actions/flatpak-builder@v5
432+
with:
433+
build-bundle: false
434+
manifest-path: CI/flatpak/com.obsproject.Studio.json
435+
cache-key: ${{ steps.setup.outputs.cache_key }}
436+
arch: ${{ matrix.arch }}
437+
438+
flatpak_build:
439+
name: '03 - Flatpak'
440+
runs-on: [ubuntu-latest]
441+
needs: [config, flatpak_deps_build]
442+
defaults:
443+
run:
444+
shell: bash
445+
container:
446+
image: bilelmoussaoui/flatpak-github-actions:kde-6.4
447+
options: --privileged
448+
strategy:
449+
matrix:
450+
arch: ${{ fromJSON(needs.config.outputs.flatpak_matrix) }}
375451
steps:
376452

377453
- name: 'Checkout'
@@ -381,19 +457,28 @@ jobs:
381457
fetch-depth: 0
382458

383459
- name: 'Setup build environment'
460+
id: setup
384461
run: |
462+
[[ "${{ matrix.arch }}" != "x86_64" ]] && dnf install -y -q docker
463+
385464
git config --global --add safe.directory $GITHUB_WORKSPACE
386-
echo "OBS_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
387-
echo "OBS_GIT_HASH=$(git rev-parse --short=9 HEAD)" >> $GITHUB_ENV
388-
echo "OBS_GIT_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
465+
466+
echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT
467+
468+
- name: Setup QEMU
469+
if: ${{ matrix.arch != 'x86_64' }}
470+
uses: docker/setup-qemu-action@v2
471+
with:
472+
platforms: arm64
389473

390474
- name: Build Flatpak Manifest
391475
uses: flatpak/flatpak-github-actions/flatpak-builder@v5
392476
with:
393477
build-bundle: ${{ fromJSON(needs.config.outputs.create_artifacts) }}
394-
bundle: obs-studio-flatpak-${{ env.OBS_GIT_HASH }}.flatpak
478+
bundle: obs-studio-flatpak-${{ steps.setup.outputs.git_hash }}.flatpak
395479
manifest-path: CI/flatpak/com.obsproject.Studio.json
396-
cache-key: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }}
480+
cache-key: ${{ needs.flatpak_deps_build.outputs.cache_key }}
481+
arch: ${{ matrix.arch }}
397482

398483
windows_package:
399484
name: '03 - Windows Installer'

0 commit comments

Comments
 (0)