Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 23 additions & 77 deletions .github/workflows/build-project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
notarize: ${{ steps.setup.outputs.notarize }}
config: ${{ steps.setup.outputs.config }}
commitHash: ${{ steps.setup.outputs.commitHash }}
flatpakArch: ${{ steps.setup.outputs.flatpakArch }}
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -28,25 +29,30 @@ jobs:

case "${GITHUB_EVENT_NAME}" in
pull_request)
config_data=('codesign:false' 'notarize:false' 'package:false' 'config:RelWithDebInfo')
if gh pr view ${{ github.event.number }} --json labels \
config_data=('codesign:false' 'notarize:false' 'package:false' 'config:RelWithDebInfo' 'flatpakArch:["x86_64"]')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have this step create a bespoke matrix variable instead of putting this in config_data, as described in the GitHub action documentation:

https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/expressions#example-returning-a-json-object

I'm fine with flatpakArch being set up as a bespoke output variable depending on GitHub event.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assigning a whole matrix looks unnecessary, making the JSON object (only an array) more complex (an array in an object) where there is only one variable does not look worth it.

I was aware of this feature to set up a matrix but for one variable, it looks too much.

label_data=$(gh pr view ${{ github.event.number }} --json labels)
if echo "${label_data}" \
| jq -e -r '.labels[] | select(.name == "Seeking Testers")' > /dev/null; then
config_data[0]='codesign:true'
config_data[2]='package:true'
fi
if echo "${label_data}" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really happy about introducing a bespoke label just for this, but code-wise it's fine.

Copy link
Collaborator Author

@tytan652 tytan652 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could work and make the aarch64 build happen on PR if a cache is there and a label to force the build without cache.
But I would prefer to know, how well/fast it is on master before enabling it on every PR (if cache available).

Note that the label name can be discussed.

| jq -e -r '.labels[] | select(.name == "Flatpak QEMU")' > /dev/null; then
config_data[5]='flatpakArch:["x86_64", "aarch64"]'
fi
;;
push)
config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo')
config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo' 'flatpakArch:["x86_64", "aarch64"]')
if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then
config_data[1]='notarize:true'
config_data[3]='config:Release'
fi
;;
workflow_dispatch)
config_data=('codesign:true' 'notarize:false' 'package:false' 'config:RelWithDebInfo')
config_data=('codesign:true' 'notarize:false' 'package:false' 'config:RelWithDebInfo' 'flatpakArch:["x86_64", "aarch64"]')
;;
schedule)
config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo')
config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo' 'flatpakArch:["x86_64", "aarch64"]')
;;
*) ;;
esac
Expand Down Expand Up @@ -243,79 +249,19 @@ jobs:

flatpak-build:
name: Flatpak 📦
runs-on: ubuntu-22.04
needs: check-event
defaults:
run:
shell: bash
container:
image: bilelmoussaoui/flatpak-github-actions:kde-6.5
options: --privileged
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
set-safe-directory: ${{ env.GITHUB_WORKSPACE }}

- name: Set Up Environment 🔧
id: setup
env:
GH_TOKEN: ${{ github.token }}
run: |
: Set Up Environment 🔧
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi

git config --global --add safe.directory "${GITHUB_WORKSPACE}"

echo '::group::Install GitHub CLI tool'
dnf install -y -q gh
gh extension install actions/gh-actions-cache
echo '::endgroup::'

cache_key='flatpak-builder-${{ hashFiles('build-aux/**/*.json') }}'
cache_ref='master'
read -r key size unit _ ref _ <<< \
"$(gh actions-cache list -B ${cache_ref} --key "${cache_key}-x86_64" | head -1)"

if [[ "${key}" ]]; then
echo "cacheHit=true" >> $GITHUB_OUTPUT
else
echo "cacheHit=false" >> $GITHUB_OUTPUT
fi

echo "cacheKey=${cache_key}" >> $GITHUB_OUTPUT

- name: Validate Flatpak manifest
uses: ./.github/actions/flatpak-builder-lint
with:
artifact: manifest
path: build-aux/com.obsproject.Studio.json
validateToPublish: false

- name: Build Flatpak Manifest 🧾
uses: flatpak/flatpak-github-actions/flatpak-builder@0ab9dd6a6afa6fe7e292db0325171660bf5b6fdf
with:
build-bundle: ${{ fromJSON(needs.check-event.outputs.package) }}
bundle: obs-studio-flatpak-${{ needs.check-event.outputs.commitHash }}.flatpak
manifest-path: ${{ github.workspace }}/build-aux/com.obsproject.Studio.json
cache: ${{ fromJSON(steps.setup.outputs.cacheHit) || (github.event_name == 'push' && github.ref_name == 'master')}}
restore-cache: ${{ fromJSON(steps.setup.outputs.cacheHit) }}
cache-key: ${{ steps.setup.outputs.cacheKey }}

- name: Validate build directory
uses: ./.github/actions/flatpak-builder-lint
with:
artifact: builddir
path: flatpak_app
validateToPublish: false

- name: Validate repository
uses: ./.github/actions/flatpak-builder-lint
with:
artifact: repo
path: repo
validateToPublish: false
uses: ./.github/workflows/flatpak-build.yaml
strategy:
fail-fast: false
matrix:
arch: ${{ fromJson(needs.check-event.outputs.flatpakArch) }}
with:
build-bundle: ${{ fromJSON(needs.check-event.outputs.package) }}
bundle: obs-studio-flatpak-${{ needs.check-event.outputs.commitHash }}-${{ matrix.arch }}.flatpak
arch: ${{ matrix.arch }}
secrets: inherit
permissions:
contents: read

windows-build:
name: Windows 🪟
Expand Down
199 changes: 199 additions & 0 deletions .github/workflows/flatpak-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
name: Flatpak Build
on:
workflow_call:
inputs:
arch:
description: Architecture of the build
default: x86_64
type: string
build-bundle:
description: Build a bundle and upload it as an artifact
default: true
type: boolean
bundle:
description: Name of the bundle
default: obs-studio-flatpak.flatpak
type: string
jobs:
build-until-90:
name: Build Modules Until 90-* 🧾
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
outputs:
cacheKey: ${{ steps.setup.outputs.cacheKey }}
cacheHit: ${{ steps.setup.outputs.cacheHit }}
qemuArch: ${{ steps.setup.outputs.qemuArch }}
container:
image: bilelmoussaoui/flatpak-github-actions:kde-6.5
options: --privileged
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
set-safe-directory: ${{ env.GITHUB_WORKSPACE }}

- name: Set Up Environment 🔧
id: setup
env:
GH_TOKEN: ${{ github.token }}
run: |
: Set Up Environment 🔧
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi

git config --global --add safe.directory "${GITHUB_WORKSPACE}"

echo '::group::Install GitHub CLI and jq tool'
dnf install -y -q gh jq
gh extension install actions/gh-actions-cache
echo '::endgroup::'

if [[ "${{ inputs.arch }}" != "x86_64" ]]; then
echo '::group::Install Docker'
dnf install -y -q docker
echo '::endgroup::'

if [[ "${{ inputs.arch }}" == "aarch64" ]]; then
echo "qemuArch=arm64" >> $GITHUB_OUTPUT
else
echo "qemuArch=${{ inputs.arch }}" >> $GITHUB_OUTPUT
fi
fi

stop_at_module=$(jq -r '.modules[:-1] | map(select(test("90-*")))[0]' build-aux/com.obsproject.Studio.json)
echo "stopAtModule=$(jq -r '.name' build-aux/$stop_at_module)" >> $GITHUB_OUTPUT

cache_key='flatpak-builder-${{ hashFiles('build-aux/**/*.json') }}'
cache_ref='master'
read -r key size unit _ ref _ <<< \
"$(gh actions-cache list -B ${cache_ref} --key "${cache_key}-${{ inputs.arch }}" | head -1)"

if [[ "${key}" ]]; then
echo "cacheHit=true" >> $GITHUB_OUTPUT
else
echo "cacheHit=false" >> $GITHUB_OUTPUT
fi

echo "cacheKey=${cache_key}" >> $GITHUB_OUTPUT

- name: Setup QEMU 🦤
if: ${{ (inputs.arch != 'x86_64') && !fromJSON(steps.setup.outputs.cacheHit) }}
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ steps.setup.outputs.qemuArch }}

- name: Validate Flatpak manifest
uses: ./.github/actions/flatpak-builder-lint
with:
artifact: manifest
path: build-aux/com.obsproject.Studio.json
validateToPublish: false

- name: Build Modules 🧱
if: ${{ !fromJSON(steps.setup.outputs.cacheHit) }}
uses: flatpak/flatpak-github-actions/flatpak-builder@0ab9dd6a6afa6fe7e292db0325171660bf5b6fdf
with:
arch: ${{ inputs.arch }}
manifest-path: ${{ github.workspace }}/build-aux/com.obsproject.Studio.json
stop-at-module: ${{ steps.setup.outputs.stopAtModule }}
cache: false

- name: Prepare Modules Artifact 🗜️
if: ${{ !fromJSON(steps.setup.outputs.cacheHit) }}
run: tar -cvf flatpak-build-until-90-${{ inputs.arch }}.tar .flatpak-builder

- name: Upload Modules Artifact 📡
if: ${{ !fromJSON(steps.setup.outputs.cacheHit) }}
uses: actions/upload-artifact@v3
with:
name: flatpak-build-until-90-${{ inputs.arch }}
path: flatpak-build-until-90-${{ inputs.arch }}.tar
retention-days: 1

build-obs:
name: Build OBS Studio 🧾
runs-on: ubuntu-22.04
needs: build-until-90
defaults:
run:
shell: bash
container:
image: bilelmoussaoui/flatpak-github-actions:kde-6.5
options: --privileged
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
set-safe-directory: ${{ env.GITHUB_WORKSPACE }}

- name: Set Up Environment 🔧
id: setup
env:
GH_TOKEN: ${{ github.token }}
run: |
: Set Up Environment 🔧
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi

git config --global --add safe.directory "${GITHUB_WORKSPACE}"

if [[ "${{ inputs.arch }}" != "x86_64" ]]; then
echo '::group::Install Docker'
dnf install -y -q docker
echo '::endgroup::'
fi

- name: Setup QEMU 🦤
if: ${{ (inputs.arch != 'x86_64') && !fromJSON(needs.build-until-90.outputs.cacheHit) }}
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ needs.build-until-90.outputs.qemuArch }}

- name: Download Modules Artifact 🛰️
if: ${{ !fromJSON(needs.build-until-90.outputs.cacheHit) }}
uses: actions/download-artifact@v3
with:
name: flatpak-build-until-90-${{ inputs.arch }}

- name: Extract Modules Artifact 🗜️
if: ${{ !fromJSON(needs.build-until-90.outputs.cacheHit) }}
run: tar -xvf flatpak-build-until-90-${{ inputs.arch }}.tar

- name: Build Modules 🧱
uses: flatpak/flatpak-github-actions/flatpak-builder@0ab9dd6a6afa6fe7e292db0325171660bf5b6fdf
with:
arch: ${{ inputs.arch }}
build-bundle: ${{ fromJSON(inputs.build-bundle) }}
bundle: ${{ inputs.bundle }}
manifest-path: ${{ github.workspace }}/build-aux/com.obsproject.Studio.json
cache: ${{ fromJSON(needs.build-until-90.outputs.cacheHit) || (github.event_name == 'push' && github.ref_name == 'master')}}
restore-cache: ${{ fromJSON(needs.build-until-90.outputs.cacheHit) }}
cache-key: ${{ needs.build-until-90.outputs.cacheKey }}

- name: Validate build directory
uses: ./.github/actions/flatpak-builder-lint
with:
artifact: builddir
path: flatpak_app
validateToPublish: false

- name: Validate repository
uses: ./.github/actions/flatpak-builder-lint
with:
artifact: repo
path: repo
validateToPublish: false

cleanup-artifact:
name: Cleanup Artifact 🧹
runs-on: ubuntu-22.04
needs: [build-until-90, build-obs]
if: ${{ !fromJSON(needs.build-until-90.outputs.cacheHit) }}
steps:
- name: Delete Modules Artifact 🗑️
uses: geekyeggo/delete-artifact@v2
with:
useGlob: false
name: flatpak-build-until-90-${{ inputs.arch }}
3 changes: 1 addition & 2 deletions build-aux/com.obsproject.Studio.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@
"-DENABLE_RTMPS=ON",
"-DENABLE_VLC=OFF",
"-DENABLE_AJA=ON",
"-DENABLE_LIBFDK=ON",
"-DENABLE_QSV11=ON"
"-DENABLE_LIBFDK=ON"
],
"secret-opts": [
"-DRESTREAM_CLIENTID=$RESTREAM_CLIENTID",
Expand Down
3 changes: 3 additions & 0 deletions build-aux/modules/50-intel-media-sdk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "intel-media-sdk",
"only-arches": [
"x86_64"
],
"buildsystem": "cmake-ninja",
"builddir": true,
"config-opts": [
Expand Down
3 changes: 3 additions & 0 deletions build-aux/modules/50-onevpl-intel-gpu.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "onevpl-intel-gpu",
"only-arches": [
"x86_64"
],
"buildsystem": "cmake-ninja",
"builddir": true,
"config-opts": [
Expand Down
3 changes: 3 additions & 0 deletions build-aux/modules/50-onevpl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "onevpl",
"only-arches": [
"x86_64"
],
"buildsystem": "cmake-ninja",
"builddir": true,
"config-opts": [
Expand Down
Loading