Skip to content

Commit bc8165a

Browse files
committed
CI: Add Flatpak aarch64
1 parent 89b43a9 commit bc8165a

File tree

2 files changed

+154
-20
lines changed

2 files changed

+154
-20
lines changed

.github/workflows/flatpak.yml

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

92153
- name: Validate AppStream
93154
shell: bash
@@ -104,7 +165,7 @@ jobs:
104165
105166
- name: Commit screenshots to the OSTree repository
106167
run: |
107-
ostree commit --repo=repo --canonical-permissions --branch=screenshots/x86_64 flatpak_app/screenshots
168+
ostree commit --repo=repo --canonical-permissions --branch=screenshots/${{ matrix.arch }} flatpak_app/screenshots
108169
109170
- name: Publish to Flathub Beta
110171
uses: flatpak/flatpak-github-actions/flat-manager@v5

.github/workflows/main.yml

Lines changed: 83 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,10 @@ jobs:
343351
container:
344352
image: bilelmoussaoui/flatpak-github-actions:kde-6.4
345353
options: --privileged
354+
strategy:
355+
matrix: ${{ fromJSON(needs.config.outputs.flatpak_matrix) }}
356+
outputs:
357+
cache_key: ${{ steps.setup.outputs.cache_key }}
346358
steps:
347359

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

372446
- name: Build Flatpak Manifest
373447
uses: flatpak/flatpak-github-actions/flatpak-builder@83ec7c1998a152b7d47507a2da5d7a4b21e612ff
374448
with:
375449
build-bundle: ${{ fromJSON(needs.config.outputs.create_artifacts) }}
376450
bundle: obs-studio-flatpak-${{ steps.setup.outputs.git_hash }}.flatpak
377451
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 }}
452+
cache-key: ${{ needs.flatpak_deps_build.outputs.cache_key }}
453+
arch: ${{ matrix.arch }}
381454

382455
windows_package:
383456
name: '03 - Windows Installer'
@@ -550,7 +623,7 @@ jobs:
550623
id: branch
551624
run: |
552625
pushd repo
553-
626+
554627
GIT_TAG="$(git describe --tags --abbrev=0)"
555628
if [[ ${GIT_TAG} == *'beta'* || ${GIT_TAG} == *'rc'* ]]; then
556629
echo "branch=beta" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)