Skip to content

Commit 20b7fff

Browse files
committed
CI: Add Flatpak aarch64
1 parent c2946f2 commit 20b7fff

File tree

2 files changed

+157
-20
lines changed

2 files changed

+157
-20
lines changed

.github/workflows/flatpak.yml

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ jobs:
4242
* ) echo 'valid_tag=false' >> $GITHUB_OUTPUT ;;
4343
esac
4444
45-
publish:
46-
name: Publish to Flathub
45+
prepare:
46+
name: Build Dependencies
4747
runs-on: [ubuntu-latest]
4848
needs: check_tag
4949
if: fromJSON(needs.check_tag.outputs.valid_tag)
@@ -54,7 +54,9 @@ jobs:
5454
options: --privileged
5555
strategy:
5656
matrix:
57-
branch: ${{ fromJSON(needs.check_tag.outputs.matrix) }}
57+
arch: [x86_64, aarch64]
58+
output:
59+
cache_key: ${{ steps.setup.outputs.cache_key }}
5860
steps:
5961
- name: Checkout
6062
uses: actions/checkout@v3
@@ -65,29 +67,89 @@ jobs:
6567
id: setup
6668
env:
6769
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68-
CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }}
70+
SKIP_MODULE: 5
6971
run: |
70-
dnf install -y -q gh
72+
if [[ "${{ matrix.arch }}" != "x86_64" ]]; then
73+
dnf install -y -q gh jq docker
74+
else
75+
dnf install -y -q gh jq
76+
fi
7177
gh extension install actions/gh-actions-cache
7278
7379
git config --global --add safe.directory $GITHUB_WORKSPACE
7480
75-
KEY="$CACHE_KEY-x86_64"
81+
# Generating the key without skipped modules and cleanup objects
82+
CACHE_KEY=$(jq "del(.cleanup) | del(.modules[].cleanup) | del(.modules[-$SKIP_MODULE:])" CI/flatpak/com.obsproject.Studio.json | sha256sum | cut -d " " -f 1)
83+
84+
KEY="$CACHE_KEY-${{ matrix.arch }}"
7685
CACHE_HIT=$(gh actions-cache list -B master --key $KEY | grep -q $KEY && echo 'true' || echo 'false')
7786
78-
echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT
7987
echo "cache_key=$CACHE_KEY" >> $GITHUB_OUTPUT
8088
echo "cache_hit=$CACHE_HIT" >> $GITHUB_OUTPUT
89+
echo "stop_at_module=$(jq ".modules[-$SKIP_MODULE].name" CI/flatpak/com.obsproject.Studio.json | tr -d '"')" >> $GITHUB_OUTPUT
90+
91+
- name: Setup QEMU
92+
if: ${{ (matrix.arch != 'x86_64') && !fromJSON(steps.setup.outputs.cache_hit) }}
93+
uses: docker/setup-qemu-action@v2
94+
with:
95+
platform: arm64
8196

8297
- name: Build Flatpak Manifest
98+
if: ${{ !fromJSON(steps.setup.outputs.cache_hit) }}
8399
uses: flatpak/flatpak-github-actions/flatpak-builder@83ec7c1998a152b7d47507a2da5d7a4b21e612ff
84100
with:
85-
bundle: obs-studio-${{ steps.setup.outputs.git_hash }}.flatpak
101+
stop-at-module: ${{ steps.setup.outputs.stop_at_module }}
86102
manifest-path: CI/flatpak/com.obsproject.Studio.json
87-
cache: ${{ fromJSON(steps.setup.outputs.cache_hit) }}
88103
cache-key: ${{ steps.setup.outputs.cache_key }}
104+
arch: ${ {matrix.arch }}
105+
106+
publish:
107+
name: Publish to Flathub
108+
runs-on: [ubuntu-latest]
109+
needs: check_tag
110+
if: fromJSON(needs.check_tag.outputs.valid_tag)
111+
env:
112+
FLATPAK_BUILD_PATH: flatpak_app/files/share
113+
container:
114+
image: bilelmoussaoui/flatpak-github-actions:kde-6.4
115+
options: --privileged
116+
strategy:
117+
matrix:
118+
branch: ${{ fromJSON(needs.check_tag.outputs.matrix) }}
119+
arch: [x86_64, aarch64]
120+
steps:
121+
- name: Checkout
122+
uses: actions/checkout@v3
123+
with:
124+
submodules: 'recursive'
125+
126+
- name: 'Setup build environment'
127+
id: setup
128+
env:
129+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }}
131+
run: |
132+
[[ "${{ matrix.arch }}" != "x86_64" ]] && dnf install -y -q docker
133+
134+
git config --global --add safe.directory $GITHUB_WORKSPACE
135+
136+
echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT
137+
138+
- name: Setup QEMU
139+
if: ${{ matrix.arch != 'x86_64' }}
140+
uses: docker/setup-qemu-action@v2
141+
with:
142+
platform: arm64
143+
144+
- name: Build Flatpak Manifest
145+
uses: flatpak/flatpak-github-actions/flatpak-builder@83ec7c1998a152b7d47507a2da5d7a4b21e612ff
146+
with:
147+
bundle: obs-studio-${{ steps.setup.outputs.git_hash }}.flatpak
148+
manifest-path: CI/flatpak/com.obsproject.Studio.json
149+
cache-key: ${{ needs.prepare.outputs.cache_key }}
89150
mirror-screenshots-url: https://dl.flathub.org/repo/screenshots
90151
branch: ${{ matrix.branch }}
152+
arch: ${{ matrix.arch }}
91153

92154
- name: Validate AppStream
93155
shell: bash
@@ -104,7 +166,7 @@ jobs:
104166
105167
- name: Commit screenshots to the OSTree repository
106168
run: |
107-
ostree commit --repo=repo --canonical-permissions --branch=screenshots/x86_64 flatpak_app/screenshots
169+
ostree commit --repo=repo --canonical-permissions --branch=screenshots/${{ matrix.arch }} flatpak_app/screenshots
108170
109171
- name: Publish to Flathub Beta
110172
uses: flatpak/flatpak-github-actions/flat-manager@v5

.github/workflows/main.yml

Lines changed: 85 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,22 @@ jobs:
6363
outputs:
6464
create_artifacts: ${{ steps.config.outputs.create_artifacts }}
6565
cache_date: ${{ steps.config.outputs.cache_date }}
66+
flatpak_matrix: ${{ steps.config.outputs.flatpak_matrix }}
6667
steps:
6768
- name: 'Configure Build Jobs'
6869
id: config
6970
run: |
7071
if [[ "${{ github.event_name == 'pull_request' }}" == "true" ]]; then
7172
echo "create_artifacts=${{ contains(github.event.pull_request.labels.*.name, 'Seeking Testers') }}" >> $GITHUB_OUTPUT
73+
74+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'Flatpak aarch64') }}" == true ]]; then
75+
echo 'flatpak_matrix=["x86_64", "aarch64"]' >> $GITHUB_OUTPUT
76+
else
77+
echo 'flatpak_matrix=["x86_64"]' >> $GITHUB_OUTPUT
78+
fi
7279
else
7380
echo 'create_artifacts=true' >> $GITHUB_OUTPUT
81+
echo 'flatpak_matrix=["x86_64"]' >> $GITHUB_OUTPUT
7482
fi
7583
echo "cache_date=$(date +"%Y-%m-%d")" >> $GITHUB_OUTPUT
7684
@@ -333,8 +341,8 @@ jobs:
333341
name: 'obs-studio-windows-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}'
334342
path: '${{ env.FILE_NAME }}'
335343

336-
linux_package:
337-
name: '02 - Flatpak'
344+
flatpak_deps_build:
345+
name: '02 - Flatpak Dependencies'
338346
runs-on: [ubuntu-latest]
339347
needs: [config, clang_check]
340348
defaults:
@@ -343,6 +351,11 @@ jobs:
343351
container:
344352
image: bilelmoussaoui/flatpak-github-actions:kde-6.4
345353
options: --privileged
354+
strategy:
355+
matrix:
356+
arch: ${{ fromJSON(needs.config.outputs.flatpak_matrix) }}
357+
outputs:
358+
cache_key: ${{ steps.setup.outputs.cache_key }}
346359
steps:
347360

348361
- name: 'Checkout'
@@ -355,29 +368,91 @@ jobs:
355368
id: setup
356369
env:
357370
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
358-
CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }}
371+
SKIP_MODULE: 5
359372
run: |
360-
dnf install -y -q gh
373+
if [[ "${{ matrix.arch }}" != "x86_64" ]]; then
374+
dnf install -y -q gh jq docker
375+
else
376+
dnf install -y -q gh jq
377+
fi
361378
gh extension install actions/gh-actions-cache
362379
363380
git config --global --add safe.directory $GITHUB_WORKSPACE
364381
365-
KEY="$CACHE_KEY-x86_64"
382+
# Generating the key without skipped modules and cleanup objects
383+
CACHE_KEY=$(jq "del(.cleanup) | del(.modules[].cleanup) | del(.modules[-$SKIP_MODULE:])" CI/flatpak/com.obsproject.Studio.json | sha256sum | cut -d " " -f 1)
384+
385+
KEY="$CACHE_KEY-${{ matrix.arch }}"
366386
CACHE_HIT=$(gh actions-cache list -B master --key $KEY | grep -q $KEY && echo 'true' || echo 'false')
367387
368-
echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT
369388
echo "cache_key=$CACHE_KEY" >> $GITHUB_OUTPUT
370389
echo "cache_hit=$CACHE_HIT" >> $GITHUB_OUTPUT
390+
echo "stop_at_module=$(jq ".modules[-$SKIP_MODULE].name" CI/flatpak/com.obsproject.Studio.json | tr -d '"')" >> $GITHUB_OUTPUT
391+
392+
- name: Setup QEMU
393+
if: ${{ (matrix.arch != 'x86_64') && !fromJSON(steps.setup.outputs.cache_hit) }}
394+
uses: docker/setup-qemu-action@v2
395+
with:
396+
platform: arm64
397+
398+
- name: Build Flatpak Manifest
399+
if: ${{ !fromJSON(steps.setup.outputs.cache_hit) }}
400+
uses: flatpak/flatpak-github-actions/flatpak-builder@83ec7c1998a152b7d47507a2da5d7a4b21e612ff
401+
with:
402+
stop-at-module: ${{ steps.setup.outputs.stop_at_module }}
403+
manifest-path: CI/flatpak/com.obsproject.Studio.json
404+
cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
405+
restore-cache: false
406+
cache-key: ${{ steps.setup.outputs.cache_key }}
407+
arch: ${{ matrix.arch }}
408+
409+
flatpak_build:
410+
name: '03 - Flatpak'
411+
runs-on: [ubuntu-latest]
412+
needs: [config, flatpak_deps_build]
413+
defaults:
414+
run:
415+
shell: bash
416+
container:
417+
image: bilelmoussaoui/flatpak-github-actions:kde-6.4
418+
options: --privileged
419+
strategy:
420+
matrix:
421+
arch: ${{ fromJSON(needs.config.outputs.flatpak_matrix) }}
422+
steps:
423+
424+
- name: 'Checkout'
425+
uses: actions/checkout@v3
426+
with:
427+
submodules: 'recursive'
428+
fetch-depth: 0
429+
430+
- name: 'Setup build environment'
431+
id: setup
432+
env:
433+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
434+
CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }}
435+
run: |
436+
[[ "${{ matrix.arch }}" != "x86_64" ]] && dnf install -y -q docker
437+
438+
git config --global --add safe.directory $GITHUB_WORKSPACE
439+
440+
echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT
441+
442+
- name: Setup QEMU
443+
if: ${{ matrix.arch != 'x86_64' }}
444+
uses: docker/setup-qemu-action@v2
445+
with:
446+
platform: arm64
371447

372448
- name: Build Flatpak Manifest
373449
uses: flatpak/flatpak-github-actions/flatpak-builder@83ec7c1998a152b7d47507a2da5d7a4b21e612ff
374450
with:
375451
build-bundle: ${{ fromJSON(needs.config.outputs.create_artifacts) }}
376452
bundle: obs-studio-flatpak-${{ steps.setup.outputs.git_hash }}.flatpak
377453
manifest-path: CI/flatpak/com.obsproject.Studio.json
378-
cache: ${{ fromJSON(steps.setup.outputs.cache_hit) || (github.event_name == 'push' && github.ref == 'refs/heads/master') }}
379-
restore-cache: ${{ fromJSON(steps.setup.outputs.cache_hit) }}
380-
cache-key: ${{ steps.setup.outputs.cache_key }}
454+
cache-key: ${{ needs.flatpak_deps_build.outputs.cache_key }}
455+
arch: ${{ matrix.arch }}
381456

382457
windows_package:
383458
name: '03 - Windows Installer'
@@ -550,7 +625,7 @@ jobs:
550625
id: branch
551626
run: |
552627
pushd repo
553-
628+
554629
GIT_TAG="$(git describe --tags --abbrev=0)"
555630
if [[ ${GIT_TAG} == *'beta'* || ${GIT_TAG} == *'rc'* ]]; then
556631
echo "branch=beta" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)