From 9040c63845156a02142d90613431750e30ef3150 Mon Sep 17 00:00:00 2001 From: tytan652 Date: Fri, 20 Jan 2023 15:43:27 +0100 Subject: [PATCH 1/4] CI: Remove useless toJSON --- .github/workflows/flatpak.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml index a88317c056b619..509be20777883a 100644 --- a/.github/workflows/flatpak.yml +++ b/.github/workflows/flatpak.yml @@ -32,14 +32,14 @@ jobs: case ${GITHUB_REF##*/} in +([0-9]).+([0-9]).+([0-9]) ) - echo 'valid_tag=${{ toJSON(true) }}' >> $GITHUB_OUTPUT + echo 'valid_tag=true' >> $GITHUB_OUTPUT echo 'matrix=["beta", "stable"]' >> $GITHUB_OUTPUT ;; +([0-9]).+([0-9]).+([0-9])-@(beta|rc)*([0-9]) ) - echo 'valid_tag=${{ toJSON(true) }}' >> $GITHUB_OUTPUT + echo 'valid_tag=true' >> $GITHUB_OUTPUT echo 'matrix=["beta"]' >> $GITHUB_OUTPUT ;; - * ) echo 'valid_tag=${{ toJSON(false) }}' >> $GITHUB_OUTPUT ;; + * ) echo 'valid_tag=false' >> $GITHUB_OUTPUT ;; esac publish: From c2946f2c187fb67f20b7b54055ef84591090410d Mon Sep 17 00:00:00 2001 From: tytan652 Date: Thu, 30 Jun 2022 17:08:27 +0200 Subject: [PATCH 2/4] flatpak: Add aarch64 support --- CI/flatpak/com.obsproject.Studio.json | 36 +++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/CI/flatpak/com.obsproject.Studio.json b/CI/flatpak/com.obsproject.Studio.json index 3e25df8e4e55fa..6f9be22da02fb0 100644 --- a/CI/flatpak/com.obsproject.Studio.json +++ b/CI/flatpak/com.obsproject.Studio.json @@ -201,6 +201,9 @@ "name": "svt-av1", "buildsystem": "cmake-ninja", "builddir": true, + "only-arches": [ + "x86_64" + ], "config-opts": [ "-DCMAKE_BUILD_TYPE=Release", "-DBUILD_SHARED_LIBS=ON", @@ -265,6 +268,15 @@ "commands": [ "patch -Np1 -i obs-deps/deps.ffmpeg/patches/FFmpeg/0001-FFmpeg-6.0-OBS.patch" ] + }, + { + "type": "shell", + "skip-arches": [ + "x86_64" + ], + "commands": [ + "sed -i 's/enabled libsvtav1 &&/disable libsvtav1 #/g' configure # Disable SVT-AV1 on non-x86_64" + ] } ] }, @@ -486,8 +498,28 @@ "sources": [ { "type": "archive", - "url": "https://cdn-fastly.obsproject.com/downloads/cef_binary_5060_linux64.tar.bz2", - "sha256": "ac4e2a8ebf20700e4e36353e314f876623633dd5b474778a2548bb66bdbea11d" + "only-arches": [ + "x86_64" + ], + "url": "https://cdn-fastly.obsproject.com/downloads/cef_binary_5060_linux_x86_64.tar.xz", + "sha256": "bf4aa9388bab7e94fa945cc3bba16b6da63b6a30f9c0342d42235468b39d84bf" + }, + { + "type": "archive", + "only-arches": [ + "aarch64" + ], + "url": "https://cdn-fastly.obsproject.com/downloads/cef_binary_5060_linux_aarch64.tar.xz", + "sha256": "68d915c9ba2639cba762a54cd3430fce2527aa6355d831d3cfcb6157664206b0" + }, + { + "type": "shell", + "only-arches": [ + "aarch64" + ], + "commands": [ + "sed -i 's/set(PROJECT_ARCH \"x86_64\")/set(PROJECT_ARCH \"aarch64\")/g' cmake/cef_variables.cmake # Fix PROJECT_ARCH on aarch64" + ] } ] }, From 5a9fae89939ed75d8e35edc1b121304d158dcb64 Mon Sep 17 00:00:00 2001 From: tytan652 Date: Mon, 27 Mar 2023 22:39:58 +0200 Subject: [PATCH 3/4] CI: Add Flatpak aarch64 --- .github/workflows/flatpak.yml | 82 ++++++++++++++++++++++++++---- .github/workflows/main.yml | 95 +++++++++++++++++++++++++++++++---- 2 files changed, 157 insertions(+), 20 deletions(-) diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml index 509be20777883a..ee18ef056665f0 100644 --- a/.github/workflows/flatpak.yml +++ b/.github/workflows/flatpak.yml @@ -42,8 +42,8 @@ jobs: * ) echo 'valid_tag=false' >> $GITHUB_OUTPUT ;; esac - publish: - name: Publish to Flathub + prepare: + name: Build Dependencies runs-on: [ubuntu-latest] needs: check_tag if: fromJSON(needs.check_tag.outputs.valid_tag) @@ -54,7 +54,9 @@ jobs: options: --privileged strategy: matrix: - branch: ${{ fromJSON(needs.check_tag.outputs.matrix) }} + arch: [x86_64, aarch64] + output: + cache_key: ${{ steps.setup.outputs.cache_key }} steps: - name: Checkout uses: actions/checkout@v3 @@ -65,29 +67,89 @@ jobs: id: setup env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }} + SKIP_MODULE: 5 run: | - dnf install -y -q gh + if [[ "${{ matrix.arch }}" != "x86_64" ]]; then + dnf install -y -q gh jq docker + else + dnf install -y -q gh jq + fi gh extension install actions/gh-actions-cache git config --global --add safe.directory $GITHUB_WORKSPACE - KEY="$CACHE_KEY-x86_64" + # Generating the key without skipped modules and cleanup objects + CACHE_KEY=flatpak-builder-$(jq "del(.cleanup) | del(.modules[].cleanup) | del(.modules[-$SKIP_MODULE:])" CI/flatpak/com.obsproject.Studio.json | sha256sum | cut -d " " -f 1) + + KEY="$CACHE_KEY-${{ matrix.arch }}" CACHE_HIT=$(gh actions-cache list -B master --key $KEY | grep -q $KEY && echo 'true' || echo 'false') - echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT echo "cache_key=$CACHE_KEY" >> $GITHUB_OUTPUT echo "cache_hit=$CACHE_HIT" >> $GITHUB_OUTPUT + echo "stop_at_module=$(jq ".modules[-$SKIP_MODULE].name" CI/flatpak/com.obsproject.Studio.json | tr -d '"')" >> $GITHUB_OUTPUT + + - name: Setup QEMU + if: ${{ (matrix.arch != 'x86_64') && !fromJSON(steps.setup.outputs.cache_hit) }} + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 - name: Build Flatpak Manifest + if: ${{ !fromJSON(steps.setup.outputs.cache_hit) }} uses: flatpak/flatpak-github-actions/flatpak-builder@83ec7c1998a152b7d47507a2da5d7a4b21e612ff with: - bundle: obs-studio-${{ steps.setup.outputs.git_hash }}.flatpak + stop-at-module: ${{ steps.setup.outputs.stop_at_module }} manifest-path: CI/flatpak/com.obsproject.Studio.json - cache: ${{ fromJSON(steps.setup.outputs.cache_hit) }} cache-key: ${{ steps.setup.outputs.cache_key }} + arch: ${ {matrix.arch }} + + publish: + name: Publish to Flathub + runs-on: [ubuntu-latest] + needs: check_tag + if: fromJSON(needs.check_tag.outputs.valid_tag) + env: + FLATPAK_BUILD_PATH: flatpak_app/files/share + container: + image: bilelmoussaoui/flatpak-github-actions:kde-6.4 + options: --privileged + strategy: + matrix: + branch: ${{ fromJSON(needs.check_tag.outputs.matrix) }} + arch: [x86_64, aarch64] + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: 'Setup build environment' + id: setup + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }} + run: | + [[ "${{ matrix.arch }}" != "x86_64" ]] && dnf install -y -q docker + + git config --global --add safe.directory $GITHUB_WORKSPACE + + echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT + + - name: Setup QEMU + if: ${{ matrix.arch != 'x86_64' }} + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + + - name: Build Flatpak Manifest + uses: flatpak/flatpak-github-actions/flatpak-builder@83ec7c1998a152b7d47507a2da5d7a4b21e612ff + with: + bundle: obs-studio-${{ steps.setup.outputs.git_hash }}.flatpak + manifest-path: CI/flatpak/com.obsproject.Studio.json + cache-key: ${{ needs.prepare.outputs.cache_key }} mirror-screenshots-url: https://dl.flathub.org/repo/screenshots branch: ${{ matrix.branch }} + arch: ${{ matrix.arch }} - name: Validate AppStream shell: bash @@ -104,7 +166,7 @@ jobs: - name: Commit screenshots to the OSTree repository run: | - ostree commit --repo=repo --canonical-permissions --branch=screenshots/x86_64 flatpak_app/screenshots + ostree commit --repo=repo --canonical-permissions --branch=screenshots/${{ matrix.arch }} flatpak_app/screenshots - name: Publish to Flathub Beta uses: flatpak/flatpak-github-actions/flat-manager@v5 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5aeb589698082f..23af510ab531fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,14 +63,22 @@ jobs: outputs: create_artifacts: ${{ steps.config.outputs.create_artifacts }} cache_date: ${{ steps.config.outputs.cache_date }} + flatpak_matrix: ${{ steps.config.outputs.flatpak_matrix }} steps: - name: 'Configure Build Jobs' id: config run: | if [[ "${{ github.event_name == 'pull_request' }}" == "true" ]]; then echo "create_artifacts=${{ contains(github.event.pull_request.labels.*.name, 'Seeking Testers') }}" >> $GITHUB_OUTPUT + + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'Flatpak aarch64') }}" == true ]]; then + echo 'flatpak_matrix=["x86_64", "aarch64"]' >> $GITHUB_OUTPUT + else + echo 'flatpak_matrix=["x86_64"]' >> $GITHUB_OUTPUT + fi else echo 'create_artifacts=true' >> $GITHUB_OUTPUT + echo 'flatpak_matrix=["x86_64"]' >> $GITHUB_OUTPUT fi echo "cache_date=$(date +"%Y-%m-%d")" >> $GITHUB_OUTPUT @@ -333,8 +341,8 @@ jobs: name: 'obs-studio-windows-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}' path: '${{ env.FILE_NAME }}' - linux_package: - name: '02 - Flatpak' + flatpak_deps_build: + name: '02 - Flatpak Dependencies' runs-on: [ubuntu-latest] needs: [config, clang_check] defaults: @@ -343,6 +351,11 @@ jobs: container: image: bilelmoussaoui/flatpak-github-actions:kde-6.4 options: --privileged + strategy: + matrix: + arch: ${{ fromJSON(needs.config.outputs.flatpak_matrix) }} + outputs: + cache_key: ${{ steps.setup.outputs.cache_key }} steps: - name: 'Checkout' @@ -355,19 +368,82 @@ jobs: id: setup env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }} + SKIP_MODULE: 5 run: | - dnf install -y -q gh + if [[ "${{ matrix.arch }}" != "x86_64" ]]; then + dnf install -y -q gh jq docker + else + dnf install -y -q gh jq + fi gh extension install actions/gh-actions-cache git config --global --add safe.directory $GITHUB_WORKSPACE - KEY="$CACHE_KEY-x86_64" + # Generating the key without skipped modules and cleanup objects + CACHE_KEY=flatpak-builder-$(jq "del(.cleanup) | del(.modules[].cleanup) | del(.modules[-$SKIP_MODULE:])" CI/flatpak/com.obsproject.Studio.json | sha256sum | cut -d " " -f 1) + + KEY="$CACHE_KEY-${{ matrix.arch }}" CACHE_HIT=$(gh actions-cache list -B master --key $KEY | grep -q $KEY && echo 'true' || echo 'false') - echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT echo "cache_key=$CACHE_KEY" >> $GITHUB_OUTPUT echo "cache_hit=$CACHE_HIT" >> $GITHUB_OUTPUT + echo "stop_at_module=$(jq ".modules[-$SKIP_MODULE].name" CI/flatpak/com.obsproject.Studio.json | tr -d '"')" >> $GITHUB_OUTPUT + + - name: Setup QEMU + if: ${{ (matrix.arch != 'x86_64') && !fromJSON(steps.setup.outputs.cache_hit) }} + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + + - name: Build Flatpak Manifest + if: ${{ !fromJSON(steps.setup.outputs.cache_hit) }} + uses: flatpak/flatpak-github-actions/flatpak-builder@83ec7c1998a152b7d47507a2da5d7a4b21e612ff + with: + stop-at-module: ${{ steps.setup.outputs.stop_at_module }} + manifest-path: CI/flatpak/com.obsproject.Studio.json + cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + restore-cache: false + cache-key: ${{ steps.setup.outputs.cache_key }} + arch: ${{ matrix.arch }} + + flatpak_build: + name: '03 - Flatpak' + runs-on: [ubuntu-latest] + needs: [config, flatpak_deps_build] + defaults: + run: + shell: bash + container: + image: bilelmoussaoui/flatpak-github-actions:kde-6.4 + options: --privileged + strategy: + matrix: + arch: ${{ fromJSON(needs.config.outputs.flatpak_matrix) }} + steps: + + - name: 'Checkout' + uses: actions/checkout@v3 + with: + submodules: 'recursive' + fetch-depth: 0 + + - name: 'Setup build environment' + id: setup + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CACHE_KEY: flatpak-builder-${{ hashFiles('CI/flatpak/com.obsproject.Studio.json') }} + run: | + [[ "${{ matrix.arch }}" != "x86_64" ]] && dnf install -y -q docker + + git config --global --add safe.directory $GITHUB_WORKSPACE + + echo "git_hash=$(git rev-parse --short=9 HEAD)" >> $GITHUB_OUTPUT + + - name: Setup QEMU + if: ${{ matrix.arch != 'x86_64' }} + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 - name: Build Flatpak Manifest uses: flatpak/flatpak-github-actions/flatpak-builder@83ec7c1998a152b7d47507a2da5d7a4b21e612ff @@ -375,9 +451,8 @@ jobs: build-bundle: ${{ fromJSON(needs.config.outputs.create_artifacts) }} bundle: obs-studio-flatpak-${{ steps.setup.outputs.git_hash }}.flatpak manifest-path: CI/flatpak/com.obsproject.Studio.json - cache: ${{ fromJSON(steps.setup.outputs.cache_hit) || (github.event_name == 'push' && github.ref == 'refs/heads/master') }} - restore-cache: ${{ fromJSON(steps.setup.outputs.cache_hit) }} - cache-key: ${{ steps.setup.outputs.cache_key }} + cache-key: ${{ needs.flatpak_deps_build.outputs.cache_key }} + arch: ${{ matrix.arch }} windows_package: name: '03 - Windows Installer' @@ -550,7 +625,7 @@ jobs: id: branch run: | pushd repo - + GIT_TAG="$(git describe --tags --abbrev=0)" if [[ ${GIT_TAG} == *'beta'* || ${GIT_TAG} == *'rc'* ]]; then echo "branch=beta" >> $GITHUB_OUTPUT From c8124ee13ee694aef5582374540694861fac2d83 Mon Sep 17 00:00:00 2001 From: tytan652 Date: Wed, 29 Mar 2023 10:20:31 +0200 Subject: [PATCH 4/4] CI: Allow caching non-master aarch64 branch --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 23af510ab531fe..b6e44fd0acfc17 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -401,7 +401,7 @@ jobs: with: stop-at-module: ${{ steps.setup.outputs.stop_at_module }} manifest-path: CI/flatpak/com.obsproject.Studio.json - cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + cache: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || matrix.arch != 'x86_64' }} restore-cache: false cache-key: ${{ steps.setup.outputs.cache_key }} arch: ${{ matrix.arch }}