From c34d82453a9557103be58552ff9d746a9b7930d4 Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Mon, 23 Sep 2024 20:53:54 +0200 Subject: [PATCH] CI: automatically update the manifest and create a branch on the flatpak repo for each release --- .github/workflows/Build.yml | 42 ++++++++++- CMakeLists.txt | 2 +- ...wivrn.yml => io.github.wivrn.wivrn.yml.in} | 20 ++--- tools/gen_flatpak_manifest.sh | 73 +++++++++++++++++++ 4 files changed, 125 insertions(+), 12 deletions(-) rename flatpak/{io.github.wivrn.wivrn.yml => io.github.wivrn.wivrn.yml.in} (92%) create mode 100755 tools/gen_flatpak_manifest.sh diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index f237c708..54981992 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -86,11 +86,18 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Create the flatpak manifest + run: | + git config --global --add safe.directory $(pwd) + tools/gen_flatpak_manifest.sh --git > io.github.wivrn.wivrn.yml # TODO: replace with version > v6.3 when it's released - uses: flatpak/flatpak-github-actions/flatpak-builder@b8be6bc0ede43cb3a2cc55895654312b14f84a0d with: - manifest-path: flatpak/io.github.wivrn.wivrn.yml + manifest-path: io.github.wivrn.wivrn.yml bundle: wivrn-server.flatpak upload-artifact: false @@ -279,6 +286,16 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + path: wivrn + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + repository: WiVRn/io.github.wivrn.wivrn + path: flathub + token: ${{ secrets.FLATHUB_TOKEN }} - name: Download artifacts (APK) uses: actions/download-artifact@v4 @@ -303,8 +320,31 @@ jobs: apk/*.apk flatpak/*.flatpak + - name: Update flatpak manifest for flathub + run: | + WIVRN_TAG=$(echo $GITHUB_REF | sed -E -e "s,refs/[^/]*/v?,,") + + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + cd flathub + git remote add upstream https://github.com/flathub/io.github.wivrn.wivrn.git + git fetch upstream + git reset --hard upstream/master + + git config --global --add safe.directory $(pwd) + ../wivrn/tools/gen_flatpak_manifest.sh --git > io.github.wivrn.wivrn.yml + + git checkout -b $WIVRN_TAG + git add io.github.wivrn.wivrn.yml + git commit -m "Version "$WIVRN_TAG + git push --set-upstream origin $WIVRN_TAG + + git show + - name: Update release branch run: | + cd wivrn git fetch origin release git push origin HEAD:release diff --git a/CMakeLists.txt b/CMakeLists.txt index f977e1a6..21261fb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,7 +200,7 @@ FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.co # Server dependencies FetchContent_Declare(monado GIT_REPOSITORY https://gitlab.freedesktop.org/monado/monado - # also change in flatpak/io.github.wivrn.wivrn.yml !!! + # The flatpak manifest is updated automatically GIT_TAG 01806a3ffa62a2440da83d94e7a9297645d9d95a PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${CMAKE_CURRENT_LIST_DIR}/patches/monado/ EXCLUDE_FROM_ALL diff --git a/flatpak/io.github.wivrn.wivrn.yml b/flatpak/io.github.wivrn.wivrn.yml.in similarity index 92% rename from flatpak/io.github.wivrn.wivrn.yml rename to flatpak/io.github.wivrn.wivrn.yml.in index 4586b98c..b2bdec3b 100644 --- a/flatpak/io.github.wivrn.wivrn.yml +++ b/flatpak/io.github.wivrn.wivrn.yml.in @@ -152,20 +152,23 @@ modules: - -DWIVRN_USE_X264=ON - -DWIVRN_USE_NVENC=ON - -DWIVRN_USE_PULSEAUDIO=OFF + - -DWIVRN_CLIENT_URL=https://github.com/WiVRn/WiVRn/releases/latest/download/WiVRn-standard-release.apk + -DWIVRN_WERROR=ON - -DFETCHCONTENT_FULLY_DISCONNECTED=ON - -DFETCHCONTENT_BASE_DIR=deps - - -DXRT_IPC_MSG_SOCK_FILENAME=wivrn/comp_ipc + - -DGIT_DESC=WIVRN_GIT_DESC - -Wno-dev sources: - - type: dir - path: .. + - WIVRN_SRC1 + WIVRN_SRC2 + WIVRN_SRC3 - type: archive - url: https://github.com/boostorg/pfr/archive/refs/tags/2.2.0.tar.gz + url: BOOSTPFR_URL dest: deps/boostpfr-src - sha256: 6f490ec1383de5855dcf801c23f0a967f888eb6e1440b6ca0bf36c12d4ae7ac7 + sha256: BOOSTPFR_SHA256 - type: git url: https://gitlab.freedesktop.org/monado/monado - tag: 01806a3ffa62a2440da83d94e7a9297645d9d95a + tag: MONADO_COMMIT dest: deps/monado-src - type: shell commands: @@ -181,10 +184,7 @@ modules: sources: - type: git url: https://gitlab.com/znixian/OpenOVR.git - tag: 632e5cc50b913e93194ca2970e6f13021182579f - - type: patch - paths: - - opencomposite-0001-Add-install-target.patch + tag: f969a972e9a151de776fa8d1bd6e67056f0a5d5d - name: launcher buildsystem: simple diff --git a/tools/gen_flatpak_manifest.sh b/tools/gen_flatpak_manifest.sh new file mode 100755 index 00000000..5dc77277 --- /dev/null +++ b/tools/gen_flatpak_manifest.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -e + +WIVRN_SRC_TYPE=gitlocal + +while [ ! -z "$1" ] +do + case "$1" in + "--git") + WIVRN_SRC_TYPE=git + ;; + "--gitlocal") + WIVRN_SRC_TYPE=gitlocal + ;; + "--dir") + WIVRN_SRC_TYPE=dir + ;; + esac + + shift +done + +cd $(dirname $0) + +GIT_TAG=$(git describe --exact-match --tags 2>/dev/null || true) +GIT_SHA=$(git rev-parse HEAD) +GIT_COMMIT=$(git describe --exact-match --tags 2>/dev/null || git rev-parse HEAD) +GIT_DESC=$(git describe --tags) + +MONADO_COMMIT=$(grep -zo "FetchContent_Declare(monado[^)]*)" ../CMakeLists.txt | sed -ze "s/^.*GIT_TAG *\([^ )]*\).*$/\1/" | tr -d '\0') +BOOSTPFR_URL=$(grep -zo "FetchContent_Declare(boostpfr[^)]*)" ../CMakeLists.txt | sed -ze "s/^.*URL *\([^ )]*\).*$/\1/" | tr -d '\0') +BOOSTPFR_SHA256=$(curl --silent --location $BOOSTPFR_URL | sha256sum | cut -f1 -d' ') + +if [ -z "$GIT_TAG" ] +then + WIVRN_CLIENT_URL=https://github.com/WiVRn/WiVRn-APK/releases/download/apk-${GIT_SHA}/org.meumeu.wivrn-standard-release.apk +else + WIVRN_CLIENT_URL=https://github.com/WiVRn/WiVRn/releases/download/${GIT_TAG}/WiVRn-standard-release.apk +fi + +if [ $WIVRN_SRC_TYPE = git ] +then + WIVRN_SRC1="type: git" + WIVRN_SRC2="url: https://github.com/WiVRn/WiVRn.git" + WIVRN_SRC3="tag: ${GIT_COMMIT}" +elif [ $WIVRN_SRC_TYPE = gitlocal ] +then + WIVRN_SRC1="type: git" + WIVRN_SRC2="url: "$(realpath $(pwd)/..) + WIVRN_SRC3="tag: ${GIT_COMMIT}" +else + WIVRN_SRC1="type: dir" + WIVRN_SRC2="path: "$(realpath $(pwd)/..) + WIVRN_SRC3="" +fi + +echo "Git commit: $GIT_COMMIT" >&2 +echo "Git tag: $GIT_DESC" >&2 +echo "Client URL: $WIVRN_CLIENT_URL" >&2 +echo "Monado commit: $MONADO_COMMIT" >&2 +echo "Boost.PFR URL: $BOOSTPFR_URL" >&2 +echo "Boost.PFR SHA256: $BOOSTPFR_SHA256" >&2 + +cat ../flatpak/io.github.wivrn.wivrn.yml.in | sed \ + -e s,WIVRN_SRC1,"$WIVRN_SRC1", \ + -e s,WIVRN_SRC2,"$WIVRN_SRC2", \ + -e s,WIVRN_SRC3,"$WIVRN_SRC3", \ + -e s,WIVRN_GIT_DESC,$GIT_DESC, \ + -e s,WIVRN_CLIENT_URL=.*,WIVRN_CLIENT_URL=$WIVRN_CLIENT_URL, \ + -e s,BOOSTPFR_URL,$BOOSTPFR_URL, \ + -e s,BOOSTPFR_SHA256,$BOOSTPFR_SHA256, \ + -e s,MONADO_COMMIT,$MONADO_COMMIT,