From 1db197219506f0a98278e602273c1a8c4f8b3e7b Mon Sep 17 00:00:00 2001 From: XargonWan Date: Thu, 21 Dec 2023 13:43:35 +0100 Subject: [PATCH] WORKFLOW: refact cooker-persistent --- .../cooker-selfhosted-persistent.yml | 8 ++--- automation_tools/flatpak_build_bundle.sh | 13 ++----- .../flatpak_build_bundle_persistent.sh | 12 +++++++ .../flatpak_build_download_only.sh | 27 +++------------ .../flatpak_build_download_only_persistent.sh | 26 ++++++++++++++ automation_tools/flatpak_build_only.sh | 34 ++++--------------- .../flatpak_build_only_persistent.sh | 25 ++++++++++++++ 7 files changed, 79 insertions(+), 66 deletions(-) create mode 100755 automation_tools/flatpak_build_bundle_persistent.sh create mode 100755 automation_tools/flatpak_build_download_only_persistent.sh create mode 100755 automation_tools/flatpak_build_only_persistent.sh diff --git a/.github/workflows/cooker-selfhosted-persistent.yml b/.github/workflows/cooker-selfhosted-persistent.yml index bf45a7b1..dced323f 100644 --- a/.github/workflows/cooker-selfhosted-persistent.yml +++ b/.github/workflows/cooker-selfhosted-persistent.yml @@ -64,7 +64,7 @@ jobs: - name: "Build flatpak: download only" id: "flatpak-download" - run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_download_only.sh" + run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_download_only_persistent.sh" continue-on-error: true # Sometimes flatpak download fails, in this case it tries a second time @@ -76,10 +76,10 @@ jobs: rm -f "{GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml" cp "${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml.bak" "${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml" "${GITHUB_WORKSPACE}/automation_tools/pre_build_automation.sh" - "${GITHUB_WORKSPACE}/automation_tools/flatpak_build_download_only.sh" + "${GITHUB_WORKSPACE}/automation_tools/flatpak_build_download_only_persistent.sh" - name: Build flatpak - run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_only.sh" + run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_only_persistent.sh" - name: Create Artifact for flathub run: | @@ -90,7 +90,7 @@ jobs: continue-on-error: true - name: Create Bundle - run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_bundle.sh" + run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_bundle_persistent.sh" - name: Set environment variable with current branch name run: echo "GITHUB_REF_SLUG=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV diff --git a/automation_tools/flatpak_build_bundle.sh b/automation_tools/flatpak_build_bundle.sh index e0aa0101..3568ebb7 100755 --- a/automation_tools/flatpak_build_bundle.sh +++ b/automation_tools/flatpak_build_bundle.sh @@ -2,17 +2,8 @@ # This is building the bundle RetroDECK.flatpak after the download and build steps are done -if [ $PERSISTENCE==true ]; then - GITHUB_WORKSPACE_BACKUP="$GITHUB_WORKSPACE" - GITHUB_WORKSPACE="$HOME/cooker-persistent" -fi - if [ "${GITHUB_REF##*/}" = "main" ]; then - flatpak build-bundle ${GITHUB_WORKSPACE}/.local $GITHUB_WORKSPACE/RetroDECK.flatpak net.retrodeck.retrodeck + flatpak build-bundle "${GITHUB_WORKSPACE}/.local" "$GITHUB_WORKSPACE/RetroDECK.flatpak" net.retrodeck.retrodeck else - flatpak build-bundle ${GITHUB_WORKSPACE}/.local $GITHUB_WORKSPACE/RetroDECK-cooker.flatpak net.retrodeck.retrodeck -fi - -if [ $PERSISTENCE==true ]; then - GITHUB_WORKSPACE="$GITHUB_WORKSPACE_BACKUP" + flatpak build-bundle "${GITHUB_WORKSPACE}/.local" "$GITHUB_WORKSPACE/RetroDECK-cooker.flatpak" net.retrodeck.retrodeck fi \ No newline at end of file diff --git a/automation_tools/flatpak_build_bundle_persistent.sh b/automation_tools/flatpak_build_bundle_persistent.sh new file mode 100755 index 00000000..ca6f1b5a --- /dev/null +++ b/automation_tools/flatpak_build_bundle_persistent.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# This is building the bundle RetroDECK.flatpak after the download and build steps are done + +BUILD_DIR="$HOME/cooker-persistent" +mkdir -p "$BUILD_DIR" + +if [ "${GITHUB_REF##*/}" = "main" ]; then + flatpak build-bundle "${BUILD_DIR}/.local" "$GITHUB_WORKSPACE/RetroDECK.flatpak" net.retrodeck.retrodeck +else + flatpak build-bundle "${BUILD_DIR}/.local" "$GITHUB_WORKSPACE/RetroDECK-cooker.flatpak" net.retrodeck.retrodeck +fi diff --git a/automation_tools/flatpak_build_download_only.sh b/automation_tools/flatpak_build_download_only.sh index 707c3e40..8c779fbb 100755 --- a/automation_tools/flatpak_build_download_only.sh +++ b/automation_tools/flatpak_build_download_only.sh @@ -12,32 +12,13 @@ else FOLDER=retrodeck-flatpak-cooker fi -if [ $PERSISTENCE==true ]; then - GITHUB_WORKSPACE_BACKUP="$GITHUB_WORKSPACE" - GITHUB_WORKSPACE="$HOME/cooker-persistent" +mkdir -vp "${GITHUB_WORKSPACE}"/{.local,retrodeck-flatpak-cooker} - mkdir -vp "${GITHUB_WORKSPACE}"/{local,retrodeck-flatpak-cooker} - - flatpak-builder --user --force-clean \ +flatpak-builder --user --force-clean \ --install-deps-from=flathub \ --install-deps-from=flathub-beta \ --repo="${GITHUB_WORKSPACE}/.local" \ --download-only \ "${GITHUB_WORKSPACE}/${FOLDER}" \ - "${GITHUB_WORKSPACE_BACKUP}/net.retrodeck.retrodeck.yml" - - GITHUB_WORKSPACE="$GITHUB_WORKSPACE_BACKUP" - -else - - mkdir -vp "${GITHUB_WORKSPACE}"/{.local,retrodeck-flatpak-cooker} - - flatpak-builder --user --force-clean \ - --install-deps-from=flathub \ - --install-deps-from=flathub-beta \ - --repo="${GITHUB_WORKSPACE}/.local" \ - --download-only \ - "${GITHUB_WORKSPACE}/${FOLDER}" \ - net.retrodeck.retrodeck.yml - -fi + net.retrodeck.retrodeck.yml + \ No newline at end of file diff --git a/automation_tools/flatpak_build_download_only_persistent.sh b/automation_tools/flatpak_build_download_only_persistent.sh new file mode 100755 index 00000000..7b05fa57 --- /dev/null +++ b/automation_tools/flatpak_build_download_only_persistent.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# This script is downloading the needed files to prepare the manifest build + +git config --global protocol.file.allow always + +if [[ "${GITHUB_REF##*/}" == "main" ]]; then + BUNDLE_NAME="RetroDECK.flatpak" + FOLDER=retrodeck-flatpak +else + BUNDLE_NAME="RetroDECK-cooker.flatpak" + FOLDER=retrodeck-flatpak-cooker +fi + +BUILD_DIR="$HOME/cooker-persistent" +mkdir -p "$BUILD_DIR" +mkdir -vp "${BUILD_DIR}"/{.local,retrodeck-flatpak-cooker} + +flatpak-builder --user --force-clean \ +--install-deps-from=flathub \ +--install-deps-from=flathub-beta \ +--repo="${BUILD_DIR}/.local" \ +--download-only \ +"${BUILD_DIR}/${FOLDER}" \ +"${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml" + diff --git a/automation_tools/flatpak_build_only.sh b/automation_tools/flatpak_build_only.sh index a72347fb..c7f84d82 100755 --- a/automation_tools/flatpak_build_only.sh +++ b/automation_tools/flatpak_build_only.sh @@ -12,35 +12,13 @@ else FOLDER=retrodeck-flatpak-cooker fi -if [ $PERSISTENCE==true ]; then +mkdir -vp ${GITHUB_WORKSPACE}/.local +mkdir -vp ${GITHUB_WORKSPACE}/"$FOLDER" - GITHUB_WORKSPACE_BACKUP="$GITHUB_WORKSPACE" - GITHUB_WORKSPACE="$HOME/cooker-persistent" - - mkdir -vp ${GITHUB_WORKSPACE}/.local - mkdir -vp ${GITHUB_WORKSPACE}/"$FOLDER" - - flatpak-builder --user --force-clean \ +flatpak-builder --user --force-clean \ --install-deps-from=flathub \ --install-deps-from=flathub-beta \ - --repo="${GITHUB_WORKSPACE}/.local" \ + --repo=${GITHUB_WORKSPACE}/.local \ --disable-download \ - "${GITHUB_WORKSPACE}/${FOLDER}" \ - "${GITHUB_WORKSPACE_BACKUP}/net.retrodeck.retrodeck.yml" - - GITHUB_WORKSPACE="$GITHUB_WORKSPACE_BACKUP" - -else - - mkdir -vp ${GITHUB_WORKSPACE}/.local - mkdir -vp ${GITHUB_WORKSPACE}/"$FOLDER" - - flatpak-builder --user --force-clean \ - --install-deps-from=flathub \ - --install-deps-from=flathub-beta \ - --repo=${GITHUB_WORKSPACE}/.local \ - --disable-download \ - ${GITHUB_WORKSPACE}/"$FOLDER" \ - net.retrodeck.retrodeck.yml - -fi \ No newline at end of file + "${GITHUB_WORKSPACE}/$FOLDER" \ + net.retrodeck.retrodeck.yml \ No newline at end of file diff --git a/automation_tools/flatpak_build_only_persistent.sh b/automation_tools/flatpak_build_only_persistent.sh new file mode 100755 index 00000000..4121cf9f --- /dev/null +++ b/automation_tools/flatpak_build_only_persistent.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# This script is downloading the needed files to prepare the manifest build + +git config protocol.file.allow always + +if [ "${GITHUB_REF##*/}" = "main" ]; then + BUNDLE_NAME="RetroDECK.flatpak" + FOLDER=retrodeck-flatpak-main +else + BUNDLE_NAME="RetroDECK-cooker.flatpak" + FOLDER=retrodeck-flatpak-cooker +fi + +BUILD_DIR="$HOME/cooker-persistent" +mkdir -vp ${$BUILD_DIR}/.local +mkdir -vp ${$BUILD_DIR}/"$FOLDER" + +flatpak-builder --user --force-clean \ +--install-deps-from=flathub \ +--install-deps-from=flathub-beta \ +--repo="${BUILD_DIR}/.local" \ +--disable-download \ +"${BUILD_DIR}/${FOLDER}" \ +"${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml"