diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml new file mode 100644 index 0000000..94e643c --- /dev/null +++ b/.github/workflows/build_artifacts.yml @@ -0,0 +1,103 @@ +name: "Build primehack Artifacts for RetroDECK" + +on: + push: + branches: + - master + workflow_dispatch: + + +jobs: + + Building_RetroDECK-primehack: + runs-on: ubuntu-latest + steps: + + # Circumventing this bug: https://github.com/flatpak/flatpak-builder/issues/317 + # - name: Remove stuck mounts + # run: sudo umount -f /home/ubuntu/primehack-runner/_work/RetroDECK-primehack/RetroDECK-primehack/.flatpak-builder/rofiles/* + # continue-on-error: true + + - name: Clone repo + uses: actions/checkout@v3 + with: + submodules: 'true' + token: ${{ secrets.TRIGGER_BUILD_TOKEN }} + + - name: "Install dependencies" + run: "automation_tools/install_dependencies.sh" + + # - name: "Creating primehack manifest" + # run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/update_primehack_manifest.sh" + + # - name: "[DEBUG] Outputting manifest" + # run: cat net.retrodeck.primehack.yml + + - name: "Build flatpak" + id: "flatpak-download" + run: | + git config --global protocol.file.allow always + flatpak-builder --user --force-clean \ + --install-deps-from=flathub \ + --install-deps-from=flathub-beta \ + --repo=${GITHUB_WORKSPACE}/primehack-repo \ + "${GITHUB_WORKSPACE}"/primehack-build-dir \ + io.github.shiiion.primehack.yaml + + - name: "Exporting dir tree" + id: tree + run: tree -H ./ > ${GITHUB_WORKSPACE}/tree.html + + - name: Create Artifact for RetroDECK + run: | + tar -czf ${GITHUB_WORKSPACE}/RetroDECK-primehack-Artifact.tar.gz -C ${GITHUB_WORKSPACE}/primehack-build-dir . + hash=($(sha256sum ${GITHUB_WORKSPACE}/RetroDECK-primehack-Artifact.tar.gz)) + echo $hash > ${GITHUB_WORKSPACE}/RetroDECK-Artifact-cooker.sha + mv -f RetroDECK-Artifact-cooker.* ${{ secrets.ARTIFACT_REPO }} + continue-on-error: true + timeout-minutes: 1440 + + - name: Set environment variable with current branch name + run: echo "GITHUB_REF_SLUG=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV + + - name: Get branch name + id: branch_name + run: echo "BRANCH_NAME=$(echo $GITHUB_REF | sed 's|refs/heads/||')" >> $GITHUB_ENV + + - name: Get date + id: date + run: echo "DATE=$(date +'%d%m%y.%S')" >> $GITHUB_ENV + + - name: Publish the artifacts in a new release + uses: ncipollo/release-action@v1 + with: + tag: "${{env.BRANCH_NAME}}-${{env.DATE}}" + body: | + # Release Notes + These are the artifact of RetroDECK primehack, commit: ${{ github.event.repository.full_name }}@${{github.sha}}. + On branch [${{env.BRANCH_NAME}}](https://github.com/XargonWan/RetroDECK-primehack/tree/${{env.BRANCH_NAME}}). + + artifacts: "RetroDECK-primehack-Artifact.tar.gz, tree.html" + allowUpdates: true + makeLatest: true + token: ${{ secrets.TRIGGER_BUILD_TOKEN }} + continue-on-error: true + + # - name: "Committing changes" + # with: + # github_token: ${{ secrets.TRIGGER_BUILD_TOKEN }} + # run: | + # git config user.name "GitHub Actions" + # git config user.email "actions@github.com" + # git add * net.retrodeck.primehack.yml + # git commit -m '[AUTOMATED] Updating primehack after build [skip ci]' + # git push origin main + # continue-on-error: true # TODO: would be good to update the manifest but it's broken + + # - name: GitHub Commit & Push + # uses: actions-js/push@v1.4 + # with: + # github_token: ${{ secrets.TRIGGER_BUILD_TOKEN }} + # message: '[AUTOMATED] Updating primehack after build [skip ci]' + # branch: retrodeck-main + # continue-on-error: true # TODO: would be good to update the manifest but it's broken \ No newline at end of file diff --git a/automation_tools/install_dependencies.sh b/automation_tools/install_dependencies.sh new file mode 100755 index 0000000..3daa4ed --- /dev/null +++ b/automation_tools/install_dependencies.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# This script is installing the required dependencies to correctly run the pipeline and build the flatpak + +unset pkg_mgr + +# rpm-ostree must be checked before dnf because a dnf (wrapper) command also works on rpm-ostree distros (not what we want) +for potential_pkg_mgr in apt pacman rpm-ostree dnf; do + command -v "$potential_pkg_mgr" &> /dev/null && pkg_mgr="$potential_pkg_mgr" && break +done + +case "$pkg_mgr" in + apt) + sudo apt install -y flatpak flatpak-builder p7zip-full xmlstarlet bzip2 curl jq + ;; + pacman) + sudo pacman -S --noconfirm flatpak flatpak-builder p7zip xmlstarlet bzip2 + ;; + rpm-ostree) + echo "When using a distro with rpm-ostree, you shouldn't build directly on the host. Try using a distrobox." + exit 1 + ;; + dnf) + sudo dnf install -y flatpak flatpak-builder p7zip p7zip-plugins xmlstarlet bzip2 curl + ;; + *) + echo "Package manager $pkg_mgr not supported. Please open an issue." + ;; +esac + +flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo diff --git a/io.github.shiiion.primehack.yml b/io.github.shiiion.primehack.yml index d233823..2461856 100644 --- a/io.github.shiiion.primehack.yml +++ b/io.github.shiiion.primehack.yml @@ -86,23 +86,21 @@ modules: sources: - type: git url: https://github.com/shiiion/dolphin.git - commit: bd2591a28ab4a367a3f11f65059e07314a13f081 - # detects whether dolphin is running in a flatpak sandbox - # and makes it use xdg directories if it is. - # prevents dolphin from attempting to write conf files - # in non-writable paths, typically happens when a user - # has leftover files from a previous non-flatpak install + commit: 81bfb9686afd2d190134b44dd72d3cee876fe2ab # This commit refers to the PR 166: https://github.com/shiiion/dolphin/pull/166, please change it when it's approved + # detects whether dolphin is running in a flatpak sandbox + # and makes it use xdg directories if it is. + # prevents dolphin from attempting to write conf files + # in non-writable paths, typically happens when a user + # has leftover files from a previous non-flatpak install - type: patch path: detectflatpak.patch - # version strings must match exactly for online multiplayer + # version strings must match exactly for online multiplayer - type: patch path: nodirtyversion.patch - - type: file - path: appdata.xml - type: script commands: - for i in {0..9}; do - test -S $XDG_RUNTIME_DIR/discord-ipc-$i || ln -sf {app/com.discordapp.Discord,$XDG_RUNTIME_DIR}/discord-ipc-$i; - done - - dolphin-emu "$@" + - primehack "$@" dest-filename: primehack-wrapper diff --git a/update_from_upstream.sh b/update_from_upstream.sh new file mode 100755 index 0000000..681fa10 --- /dev/null +++ b/update_from_upstream.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +git fetch https://github.com/flathub/io.github.shiiion.primehack master # Fetch the latest changes from the remote master branch +git merge FETCH_HEAD # Merge the fetched changes into your current branch \ No newline at end of file